memLib.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:6k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* memLib.h - memory management library header file */
  2. /* Copyright 1984-1996 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 03s,19aug96,dbt  added memPartAlignedAlloc prototype (fixed SPR #6898).
  7. 03r,30oct94,kdl  merge cleanup - removed extra "#ifndef _ASMLANGUAGE".
  8. 03o,15oct93,cd   added #ifndef _ASMLANGUAGE.
  9. 03q,27oct94,ism  Fixed assembly problem from merge
  10. 03p,01dec93,jag  added struct MEM_PART_STATS and function memPartInfoGet.
  11. 03o,02apr93,edm  ifdef'd out non-ASMLANGUAGE portions
  12. 03n,05feb93,smb  added include of vxWorks.h
  13. 03m,22sep92,rrr  added support for c++
  14. 03l,19jul92,pme  added external declarations for sm partition functions.
  15. 03k,13jul92,rdc  added prototype for valloc.
  16. 03j,04jul92,jcf  cleaned up.
  17. 03i,22jun92,rdc  added memalign and memPartAlignedAlloc.
  18. 03h,26may92,rrr  the tree shuffle
  19. 03g,25mar92,jmm  added new options for error handling
  20. 03f,04oct91,rrr  passed through the ansification filter
  21.   -fixed #else and #endif
  22.   -changed VOID to void
  23.   -changed copyright notice
  24. 03e,10jun91.del  added pragma for gnu960 alignment.
  25. 03d,05oct90,dnw  deleted private routines.
  26. 03c,05oct90,shl  added ANSI function prototypes.
  27.                  made #endif ANSI style.
  28.                  added copyright notice.
  29. 03b,10aug90,dnw  added declaration of memPartInit().
  30. 03a,18jul90,jcf  made partitions objects.
  31.  changed malloc(),realloc(),calloc() etc to return void *.
  32. 02c,17mar90,jcf  added structure type definition.
  33. 02b,28jun89,llk  added declaration for free();
  34. 02a,11jun88,dnw  changed for rev 03a of memLib.
  35. 01l,28mar88,gae  added function decl. of calloc().
  36. 01j,13nov87,gae  removed FRAGMENT definition; made function decl.'s IMPORTs.
  37. 01h,23oct87,rdc  added PARTITION defenitions.
  38. 01g,24dec86,gae  changed stsLib.h to vwModNum.h.
  39. 01f,21may86,rdc  added forward declarations for malloc and realloc.
  40.  added FRAGMENT structure.
  41. 01e,13aug84,ecs  changed S_memLib_NO_MORE_MEMORY to S_memLib_NOT_ENOUGH_MEMORY.
  42. 01d,07aug84,ecs  added include of stsLib.h, and status codes.
  43. 01c,15jun84,dnw  removed declaration of memEnd (no longer exists).
  44. 01b,27jan84,ecs  added inclusion test.
  45. 01a,24may83,dnw  written
  46. */
  47. #ifndef __INCmemLibh
  48. #define __INCmemLibh
  49. #ifdef __cplusplus
  50. extern "C" {
  51. #endif
  52. #include "vxWorks.h"
  53. #include "vwModNum.h"
  54. /* status codes */
  55. #define S_memLib_NOT_ENOUGH_MEMORY (M_memLib | 1)
  56. #define S_memLib_INVALID_NBYTES (M_memLib | 2)
  57. #define S_memLib_BLOCK_ERROR (M_memLib | 3)
  58. #define S_memLib_NO_PARTITION_DESTROY (M_memLib | 4)
  59. #define S_memLib_PAGE_SIZE_UNAVAILABLE (M_memLib | 5)
  60. /* types */
  61. #ifndef _ASMLANGUAGE
  62. typedef struct mem_part *PART_ID;
  63. /* Partition statistics structure */
  64. typedef struct
  65.     {
  66.     unsigned long numBytesFree,    /* Number of Free Bytes in Partition       */
  67.   numBlocksFree,   /* Number of Free Blocks in Partition      */
  68.   maxBlockSizeFree,/* Maximum block size that is free.       */
  69.   numBytesAlloc,   /* Number of Allocated Bytes in Partition  */
  70.   numBlocksAlloc;  /* Number of Allocated Blocks in Partition */
  71.     }  MEM_PART_STATS;
  72. #endif /* ~ _ASMLANGUAGE */
  73. /* partition options */
  74. /* optional check for bad blocks */
  75. #define MEM_BLOCK_CHECK 0x10
  76. /* response to errors when allocating memory */
  77. #define MEM_ALLOC_ERROR_LOG_FLAG 0x20
  78. #define MEM_ALLOC_ERROR_SUSPEND_FLAG 0x40
  79. /* response to errors when freeing memory */
  80. #define MEM_BLOCK_ERROR_LOG_FLAG 0x80
  81. #define MEM_BLOCK_ERROR_SUSPEND_FLAG 0x100
  82. /* old style allocation errors - block too big, insufficient space */
  83. #define MEM_ALLOC_ERROR_MASK 0x03
  84. #define MEM_ALLOC_ERROR_RETURN 0
  85. #define MEM_ALLOC_ERROR_LOG_MSG 0x01
  86. #define MEM_ALLOC_ERROR_LOG_AND_SUSPEND 0x02
  87. /* old style bad block found */
  88. #define MEM_BLOCK_ERROR_MASK 0x0c
  89. #define MEM_BLOCK_ERROR_RETURN 0
  90. #define MEM_BLOCK_ERROR_LOG_MSG 0x04
  91. #define MEM_BLOCK_ERROR_LOG_AND_SUSPEND 0x08
  92. #ifndef _ASMLANGUAGE
  93. /* variable declarations */
  94. /* system partition */
  95. extern PART_ID memSysPartId;
  96. /* shared memory manager function pointers */
  97. extern FUNCPTR  smMemPartOptionsSetRtn;
  98. extern FUNCPTR  smMemPartFindMaxRtn;
  99. extern FUNCPTR  smMemPartReallocRtn;
  100. extern FUNCPTR  smMemPartShowRtn;
  101. /* function declarations */
  102. #if defined(__STDC__) || defined(__cplusplus)
  103. extern STATUS  memInit (char *pPool, unsigned poolSize);
  104. extern STATUS  memPartLibInit (char *pPool, unsigned poolSize);
  105. extern PART_ID  memPartCreate (char *pPool, unsigned poolSize);
  106. extern void  memPartInit (PART_ID partId, char *pPool, unsigned poolSize);
  107. extern STATUS  memPartAddToPool (PART_ID partId, char *pPool,
  108.   unsigned poolSize);
  109. extern void  memAddToPool (char *pPool, unsigned poolSize);
  110. extern void * memPartAlloc (PART_ID partId, unsigned nBytes);
  111. extern void *   memPartAlignedAlloc (PART_ID partId, unsigned nBytes,
  112.      unsigned alignment);
  113. extern void * memalign (unsigned alignment, unsigned size);
  114. extern void *   valloc (unsigned size);
  115. extern STATUS  memPartFree (PART_ID partId, char *pBlock);
  116. extern STATUS  memPartOptionsSet (PART_ID partId, unsigned options);
  117. extern int  memFindMax (void);
  118. extern int  memPartFindMax (PART_ID partId);
  119. extern void * memPartRealloc (PART_ID partId, char *pBlock, unsigned nBytes);
  120. extern void  memOptionsSet (unsigned options);
  121. extern STATUS  cfree (char *pBlock);
  122. extern void  memShowInit (void);
  123. extern void  memShow (int type);
  124. extern STATUS  memPartShow (PART_ID partId, int type);
  125. extern STATUS   memPartInfoGet (PART_ID partId, MEM_PART_STATS * ppartStats);
  126. #else /* __STDC__ */
  127. extern STATUS  memInit ();
  128. extern STATUS  memPartLibInit ();
  129. extern PART_ID  memPartCreate ();
  130. extern void  memPartInit ();
  131. extern STATUS  memPartAddToPool ();
  132. extern void  memAddToPool ();
  133. extern void * memPartAlloc ();
  134. extern void *   memPartAlignedAlloc ();
  135. extern void * memalign ();
  136. extern void *   valloc ();
  137. extern STATUS  memPartFree ();
  138. extern STATUS  memPartOptionsSet ();
  139. extern int  memFindMax ();
  140. extern int  memPartFindMax ();
  141. extern void * memPartRealloc ();
  142. extern void  memOptionsSet ();
  143. extern STATUS  cfree ();
  144. extern void  memShowInit ();
  145. extern void  memShow ();
  146. extern STATUS  memPartShow ();
  147. extern STATUS   memPartInfoGet ();
  148. #endif /* __STDC__ */
  149. #endif /* _ASMLANGUAGE */
  150. #ifdef __cplusplus
  151. }
  152. #endif
  153. #endif /* __INCmemLibh */