xm_alloc.h

00001 /* 
00002    EyeDB Object Database Management System
00003    Copyright (C) 1994-2008 SYSRA
00004    
00005    EyeDB is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009    
00010    EyeDB is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014    
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with this library; if not, write to the Free Software
00017    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA 
00018 */
00019 
00020 /*
00021   Author: Eric Viara <viara@sysra.com>
00022 */
00023 
00024 
00025 #ifndef _EYEDBSM_XM_MALLOC_H
00026 #define _EYEDBSM_XM_MALLOC_H
00027 
00028 namespace eyedbsm {
00029 
00030   typedef struct XMMap XMMap;
00031 
00032   struct XMHandle {
00033     XMMap *map;
00034     struct Mutex *mp;
00035     int fd;
00036     void *x;
00037   };
00038 
00039   typedef unsigned int XMOffset;
00040 
00041   extern XMHandle *XMCreate(char *, unsigned int, void *);
00042   extern XMHandle *XMOpen(char *, void *x);
00043   extern void XMInit(XMHandle *);
00044   extern void XMClose(XMHandle *);
00045 
00046   extern void  *XMAlloc(XMHandle *, unsigned int);
00047   extern void  *XMAllocZero(XMHandle *, unsigned int);
00048   extern void  *XMRealloc(XMHandle *, void *, unsigned int);
00049   extern int   XMFree(XMHandle *, void *);
00050 
00051   extern int   XMGetSize(XMHandle *, void *);
00052   extern void  XMShowMemory(XMHandle *);
00053   extern int   XMCheckMemory(XMHandle *);
00054   extern void  XMGetInfo(XMHandle *, int *, int *, int *, int *);
00055   extern void  XMLock(XMHandle *);
00056   extern void  XMUnlock(XMHandle *);
00057 
00058 #define XM_ADDR_(MAP, OFFSET) \
00059         ((OFFSET) ? ((char *)(MAP) + (OFFSET)) : (char *)0)
00060 
00061 #define XM_OFFSET_(MAP, ADDR) \
00062         ((eyedbsm::XMOffset)((ADDR) ? ((char *)(ADDR) - (char *)(MAP)) : 0))
00063 
00064 #define XM_ADDR(XMH, OFFSET) XM_ADDR_((XMH)->map, OFFSET)
00065 
00066 #define XM_OFFSET(XMH, ADDR) XM_OFFSET_((XMH)->map, ADDR)
00067 
00068 #define XM_NULLOFFSET ((eyedbsm::XMOffset)0)
00069 
00070 }
00071 
00072 #endif

Generated on Mon Dec 22 18:16:15 2008 for eyedb by  doxygen 1.5.3