pgMTraps.h

Go to the documentation of this file.
00001 
00002 /*  $Id: pgMTraps.h 414 2005-01-24 02:50:53Z terry_teague $    */
00003 
00004 #ifndef PGMTRAPS_H
00005 #define PGMTRAPS_H
00006 
00007 
00008 /*************** PAIGE machine-dependent memory definitions ******************/
00009 
00010 /* This file defines all memory-related functions such as allocation, resizing,
00011 etc. for memory_ref types. It is controlled by CPUDefs.h that defines the
00012 platform.  */
00013 
00014 /* File I/O has moved to pgIO.h - TRS OITC */
00015 
00016 
00017 #include "CPUDEFS.H"
00018 #include "pgMemMgr.h"
00019 
00020 #define DEF_MASTER_QTY      256
00021 
00022 #ifdef MAC_PLATFORM
00023 
00024 #if !TARGET_API_MAC_CARBON
00025 #include <MacTypes.h>       /* 2004-09-29 AR: renamed from Types.h */
00026 #include <Files.h>
00027 #include <Memory.h>
00028 #endif
00029 
00030 #define MASTER_ENTRY_SIZE   sizeof(memory_ref)
00031 #define MASTER_ENTRY_NULL   MEM_NULL;
00032 #define SPARE_TIRE_SIZE     0x00004000
00033 
00034 #define pgMemoryPtr(ref) (mem_rec_ptr) *((Handle) ref)
00035 #define pgFreePtr(ref) {}
00036 #define pgAllocMemory(bytesize) (generic_var)NewHandle(bytesize)
00037 #define pgAllocMemoryClear(bytesize) (generic_var)NewHandleClear(bytesize)
00038 #define pgLockMemory(ref) HLock((Handle) ref)
00039 #define pgLockMemoryHi(ref) HLockHi((Handle) ref)
00040 #define pgUnlockMemory(ref) HUnlock((Handle) ref)
00041 #define pgResizeMemory(globals, ref, bytesize) { \
00042         SetHandleSize((Handle) ref, bytesize);          \
00043         }
00044 #define pgMemorySize(ref) GetHandleSize((Handle) ref)
00045 #define pgFreeMemory(ref) DisposeHandle((Handle) ref)
00046 #define pgMemoryError(globals) MemError()
00047 #define pgRecoverMemory(ptr) (memory_ref)RecoverHandle((Ptr) ptr)
00048 
00049 #endif
00050 
00051 #ifdef WINDOWS_PLATFORM
00052 
00053 #ifdef WINDOWS_EMULATE_COMPILE
00054 
00055 #include "WinMac.h"
00056 
00057 #else
00058 #include <WINDOWS.H>
00059 #endif
00060 
00061 #include <string.h>
00062 
00063 
00064 #define MASTER_ENTRY_SIZE   (sizeof(HANDLE))
00065 #define MASTER_ENTRY_NULL   (HANDLE)NULL;
00066 #define SPARE_TIRE_SIZE     0x00000400
00067 #define MAX_HANDLE_ENTRIES  (DEF_MASTER_QTY - 1)
00068 
00069 #define pgMemoryPtr(ref) (mem_rec_ptr) GlobalLock((HANDLE) *((HANDLE PG_FAR *)ref))
00070 #define pgFreePtr(ref) GlobalUnlock(*((HANDLE PG_FAR *)ref))
00071 #define pgAllocMemory(bytesize) GlobalAlloc(GMEM_MOVEABLE, bytesize)
00072 #define pgAllocMemoryClear(bytesize) GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, bytesize)
00073 #define pgLockMemory(ref) {}
00074 #define pgLockMemoryHi(ref) {}
00075 #define pgUnlockMemory(ref) {}
00076 #define pgResizeMemory(globals, ref, bytesize) {  \
00077     if (*((HANDLE PG_FAR *)ref) = GlobalReAlloc((HANDLE) *((HANDLE PG_FAR *)ref), bytesize, 0)) \
00078         globals->last_error = NO_ERROR; \
00079     else                                \
00080         globals->last_error = NO_MEMORY_ERR; \
00081         }
00082 
00083 #define pgMemorySize(ref) GlobalSize(*((HANDLE PG_FAR *)ref))
00084 #define pgFreeMemory(ref) GlobalFree(*((HANDLE PG_FAR *)ref))
00085 #define pgMemoryError(globals) globals->last_error
00086 
00087 
00088 #ifdef WIN32_COMPILE
00089 #define BlockMove(src, dest, size) MoveMemory(dest, src, size)
00090 #define pgRecoverMemory(ptr) ((HGLOBAL)GlobalHandle(ptr))
00091 #else
00092 #define pgRecoverMemory(ptr) ((HGLOBAL)LOWORD(GlobalHandle(SELECTOROF(ptr))))
00093 #define BlockMove(src, dest, size) hmemcpy(dest, src, size)
00094 #endif
00095 
00096 /* Misc. */
00097 
00098 #ifndef WINDOWS_EMULATE_COMPILE
00099 #define Debugger() DebugBreak()
00100 #define DebugStr OutputDebugString
00101 #define ExitToShell()  PostQuitMessage(1)
00102 #endif
00103 
00104 #endif
00105 
00106 #endif

Generated on Wed May 31 18:19:59 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6