hxmm.h
上传用户:zhongxx05
上传日期:2007-06-06
资源大小:33641k
文件大小:7k
源码类别:

Symbian

开发平台:

C/C++

  1. /* ***** BEGIN LICENSE BLOCK ***** 
  2.  * Version: RCSL 1.0/RPSL 1.0 
  3.  *  
  4.  * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved. 
  5.  *      
  6.  * The contents of this file, and the files included with this file, are 
  7.  * subject to the current version of the RealNetworks Public Source License 
  8.  * Version 1.0 (the "RPSL") available at 
  9.  * http://www.helixcommunity.org/content/rpsl unless you have licensed 
  10.  * the file under the RealNetworks Community Source License Version 1.0 
  11.  * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl, 
  12.  * in which case the RCSL will apply. You may also obtain the license terms 
  13.  * directly from RealNetworks.  You may not use this file except in 
  14.  * compliance with the RPSL or, if you have a valid RCSL with RealNetworks 
  15.  * applicable to this file, the RCSL.  Please see the applicable RPSL or 
  16.  * RCSL for the rights, obligations and limitations governing use of the 
  17.  * contents of the file.  
  18.  *  
  19.  * This file is part of the Helix DNA Technology. RealNetworks is the 
  20.  * developer of the Original Code and owns the copyrights in the portions 
  21.  * it created. 
  22.  *  
  23.  * This file, and the files included with this file, is distributed and made 
  24.  * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 
  25.  * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES, 
  26.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS 
  27.  * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 
  28.  * 
  29.  * Technology Compatibility Kit Test Suite(s) Location: 
  30.  *    http://www.helixcommunity.org/content/tck 
  31.  * 
  32.  * Contributor(s): 
  33.  *  
  34.  * ***** END LICENSE BLOCK ***** */ 
  35. #pragma once
  36. #ifndef _HXMM_
  37. #define _HXMM_
  38. #endif
  39. //#include "pn_macmemory.h"
  40. //#include "pnmm_c.h"
  41. #ifdef _CARBON
  42. #ifdef BUILDING_PNCRT
  43. #include <Carbon.h>
  44. #endif
  45. #ifndef _MAC_MACHO
  46. #include <size_t.h>
  47. #endif
  48. #else
  49. #ifndef size_t
  50. typedef unsigned long size_t;
  51. #endif
  52. #endif
  53. #include "hxtypes.h"
  54. #define kTempMemPoolHandle 'temp'
  55. #define kPoolSign   'POOL'
  56. #define kBlockSignature 'BLOK'
  57. extern Boolean _gInterruptCodeEnabled;
  58. extern  long g_InterruptsOn;
  59. #define USE_PNMM 1 // uncomment this line to enable PNMM code in Player
  60. typedef enum PNMM_MEMORYTYPE_TAG
  61. {
  62. PNMM_MEMORYTYPE_ALL=0,
  63. PNMM_MEMORYTYPE_EXTERNAL,
  64. PNMM_MEMORYTYPE_ALLPOOLS,
  65. PNMM_MEMORYTYPE_FREEPOOLS,
  66. PNMM_MEMORYTYPE_INTERRUPTPOOLS,
  67. PNMM_MEMORYTYPE_NONINTERRUPTPOOLS
  68. } PNMM_MEMORYTYPE;
  69. /*
  70. typedef struct MemPool {
  71. long signature; //  POOL SIGNATURE contains kPoolSign
  72. struct MemPool *next; // pointer to next pool
  73. struct MemPool *prev; //  previous memory pool.
  74. long left; // number of bytes left
  75. long leftlast; // number of bytes after last update.
  76. long locked; // is this block locked?
  77. long* lastfree;
  78. char* endofpool;
  79. // DEALLOCMEM* fpDeleteFunction; // the delete function associated with this pool.
  80. long interrupt_only; // the pool is locked out from non interrupt 
  81. // allocations.
  82. long allocatedblocks; //  Number of allocated blocks in this pool.
  83. long* record;
  84. size_t size; // number of bytes in pool (including header)
  85. char data[]; // variable size user data section
  86. //  time only.  
  87. } MemPool;
  88. */
  89. /*
  90. typedef struct PNMM_MEMORY_INFO
  91. {
  92. long numberOfPools; // Number of pools allocated
  93. MemPool* firstPool; // Ptr to first pool struct.
  94. long totalAllocated; // Total Memory allocated for all pools.
  95. long totalLeft; // Total memory free in all pools.
  96. long totalLocked; // Total Number of pools that are locked.
  97. long totalAllocated_Interrupt; // Total Memory allocated for interrupt time.
  98. long totalLeft_Interrupt; // Total Memory free in interrupt pools.
  99. //
  100. // To get the following information you must have "extendedinfo" set to true
  101. // when you call PNMM_INFO;
  102. //
  103. long totalblocks; // Total Number of blocks that are constructed in
  104. // all pools.
  105. long largestblock; // Largest Unused block, in any block, of any pool.
  106. } PNMM_MEMORY_INFO;
  107. */
  108. //
  109. // This is the block header, it is an enumerated structure.
  110. // Note that the ExternalPtr and PoolPtr, both use the same 4 bytes.
  111. //
  112. #define kBlockHeaderSize 16
  113. enum 
  114. {
  115. kBlockHeader_Signature = 0,
  116. kBlockHeader_DeleteFunction,
  117. kBlockHeader_ExtraSize=kBlockHeader_DeleteFunction,
  118. kBlockHeader_PoolPtr,
  119. kBlockHeader_ExternalPtr=kBlockHeader_PoolPtr,
  120. kBlockHeader_BlockSize
  121. };
  122. //
  123. //
  124. // This is a structure used for keeping track of pools.
  125. // This allows us to make the best choice possible when using Virtual Memory,
  126. // allowing us to not cause page faults when we don't have to.
  127. //
  128. //
  129. /*
  130. typedef struct tag_PoolRecord
  131. {
  132. MemPool* pool;
  133. long poolleft;
  134. long poolend;
  135. long pool_interrupt;
  136. } PNMM_POOLRECORD;
  137. */
  138. typedef void (LOWMEMORYNOTIFIER)(void);
  139. #ifdef __cplusplus
  140. extern "C" {
  141. #endif
  142. /*
  143. //
  144. // Override function.
  145. //
  146. Boolean PNMM_OVERRIDE_ALLOC(ALLOCMEM* pNew, DEALLOCMEM* pDelete);
  147. */
  148. //
  149. // Block allocation functions
  150. //
  151. Boolean PNMM_NEWBLOCK(size_t newsize, Boolean interrupt_only);
  152. //
  153. // Clean up function. 
  154. //
  155. void PNMM_FORCECLEANUP(PNMM_MEMORYTYPE MemType);
  156. //
  157. // Getting information about the state of the memory allocator.
  158. //
  159. void HXMM_COMPACT(void);
  160. //PNMM_MEMORY_INFO* PNMM_INFO(Boolean extendedinfo);
  161. //BOOL HXMM_ATINTERRUPT(void);
  162. BOOL HXMM_ATINTERRUPT(void);
  163. //
  164. // State information to give us an idea of what kind of memory to be using.
  165. //
  166. void HXMM_INTERRUPTON(void);
  167. void HXMM_INTERRUPTOFF(void);
  168. //
  169. // Tells memory allocator to mark the memory as being held.
  170. // In so doing when the program is in virtual memory mode, it marks
  171. // blocks of memory as being held.  This makes access at interrupt time,
  172. // completely safe when in virtual memory mode.
  173. //
  174. void PNMM_HOLDMEMORY_ON(void);
  175. void PNMM_HOLDMEMORY_OFF(void);
  176. BOOL HXMM_VIRTUAL_MEMORY_ON(void);
  177. //
  178. // Allows the user to set a bare minimum which must be left in the application's heap.
  179. //
  180. void PNMM_SETAPPLICATIONMINIMUM(size_t size);
  181. //
  182. // Debugging use only.
  183. //
  184. void HXMM_POOLCHECK(void);
  185. void PNMM_OUTPUTMEMSTATS(void);
  186. void  PNMM_ASSERTPTR(void* ptr);
  187. void PNMM_DUMP_ALLOCATED_BLOCKS(void);
  188. //
  189. // FEATURE CHECKING
  190. //
  191. ULONG32   PNMM_VERSION(void);
  192. //
  193. // Low-memory notification
  194. //
  195. BOOL PNMM_LOWMEMORY(void);
  196. void PNMM_REGISTER_NOTIFICATION_FUNCTION(LOWMEMORYNOTIFIER* theNotifier);
  197. void PNMM_UNREGISTER_NOTIFICATION_FUNCTION(LOWMEMORYNOTIFIER* theNotifier);
  198. //
  199. // INTERNAL USE ONLY
  200. //
  201. void  PNMM_INIT(void);
  202. void  PNMM_SHUTDOWN(void);
  203. #ifdef __cplusplus
  204. }
  205. #endif