00001 /* 00002 * $Id: memuser.h,v 1.3 2002/08/27 15:47:48 fabio Exp $ 00003 * 00004 */ 00005 00006 /* Memory management user-visible definitions */ 00007 00008 00009 #if !defined(_MEMUSERH) 00010 #define _MEMUSERH 00011 00012 #ifndef ARGS 00013 # ifdef __STDC__ 00014 # define ARGS(args) args 00015 # else 00016 # define ARGS(args) () 00017 # endif 00018 #endif 00019 00020 #ifdef __cplusplus 00021 # define EXTERN extern "C" 00022 #else 00023 # define EXTERN extern 00024 #endif 00025 00026 #include <stdio.h> 00027 00028 00029 00030 /* >>> Potentially machine dependent stuff */ 00031 /* See memint.h as well. */ 00032 00033 typedef unsigned long INT_PTR; /* Integral type that can hold a pointer */ 00034 typedef unsigned long SIZE_T; /* Integral type that can hold the maximum */ 00035 /* size of an object */ 00036 00037 /* REQUIRED_ALIGNMENT is the alignment required by the machine hardware; */ 00038 /* it is provided for user use. */ 00039 00040 #define REQUIRED_ALIGNMENT 4 00041 00042 00043 /* Types */ 00044 00045 #if defined(__STDC__) 00046 typedef void *pointer; 00047 #else 00048 typedef char *pointer; 00049 #endif 00050 00051 00052 typedef struct rec_mgr_ *rec_mgr; 00053 00054 00055 /* ALLOC_ALIGNMENT is the alignment for all storage returned by the */ 00056 /* storage allocation routines. */ 00057 00058 #define ALLOC_ALIGNMENT 8 00059 00060 00061 /* Round a size up for alignment */ 00062 00063 #define ROUNDUP(size) ((((size)+ALLOC_ALIGNMENT-1)/ALLOC_ALIGNMENT)*ALLOC_ALIGNMENT) 00064 #define ALIGN(size) ((((size)+REQUIRED_ALIGNMENT-1)/REQUIRED_ALIGNMENT)*REQUIRED_ALIGNMENT) 00065 00066 00067 /* Block storage management routines */ 00068 00069 EXTERN pointer mem_get_block ARGS((SIZE_T)); 00070 EXTERN void mem_free_block ARGS((pointer)); 00071 EXTERN pointer mem_resize_block ARGS((pointer, SIZE_T)); 00072 EXTERN void mem_copy ARGS((pointer, pointer, SIZE_T)); 00073 EXTERN void mem_zero ARGS((pointer, SIZE_T)); 00074 EXTERN void mem_fatal ARGS((char *)); 00075 EXTERN SIZE_T mem_allocation ARGS((void)); 00076 00077 00078 /* Record manager routines */ 00079 00080 EXTERN pointer mem_new_rec ARGS((rec_mgr)); 00081 EXTERN void mem_free_rec ARGS((rec_mgr, pointer)); 00082 EXTERN rec_mgr mem_new_rec_mgr ARGS((int)); 00083 EXTERN void mem_free_rec_mgr ARGS((rec_mgr)); 00084 00085 00086 #undef ARGS 00087 #undef EXTERN 00088 00089 #endif