part.cc

来自「VRTX 商用嵌入式实时操作系统」· CC 代码 · 共 73 行

CC
73
字号
/***************************************************************************
*
*		Copyright (c) 1993 READY SYSTEMS CORPORATION.
*
*	All rights reserved. READY SYSTEMS' source code is an unpublished
*	work and the use of a copyright notice does not imply otherwise.
*	This source code contains confidential, trade secret material of
*	READY SYSTEMS. Any attempt or participation in deciphering, decoding,
*	reverse engineering or in any way altering the source code is
*	strictly prohibited, unless the prior written consent of
*	READY SYSTEMS is obtained.
*
*
*	Module Name:		partition.cc
*
*	Identification:		@(#) 1.4 partition.cc
*
*	Date:			5/3/93  14:57:08
*
****************************************************************************
*/

#include "part.h"

Partition::Partition (void *base, unsigned length, unsigned block_size, int id)
{
  int err;
  if (id == -1)
    pid = sc_pcreate (id, (char *) base, length, block_size, &err);
  else {
    sc_pcreate (id, (char *) base, length, block_size, &err);
    pid = id;
  }
  bsize = block_size;
}

Partition::~Partition ()
{
  int err;
  sc_pdelete (pid, 1, &err);
}

void *
Partition::malloc (unsigned size)
{
  int err;
  void *ret;
  if (size > bsize)
    return (void *) 0;
  ret = sc_gblock (pid, &err);
  return err == RET_OK ? ret : (void *) 0;
}

void
Partition::free (void *ptr)
{
  int err;
  sc_rblock (pid, (char *) ptr, &err);
}

int
Partition::id ()
{
  return pid;
}

void
Partition::extend (void *base, unsigned length)
{
  int err;
  sc_pextend (pid, (char *) base, length, &err);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?