1 #ifndef MP_MEMORY_H 2 #define MP_MEMORY_H 3 4 5 /* 6 * mpatrol 7 * A library for controlling and tracing dynamic memory allocations. 8 * Copyright (C) 1997-2002 Graeme S. Roy <graeme.roy@analog.com> 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Library General Public 12 * License as published by the Free Software Foundation; either 13 * version 2 of the License, or (at your option) any later version. 14 * 15 * This library is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Library General Public License for more details. 19 * 20 * You should have received a copy of the GNU Library General Public 21 * License along with this library; if not, write to the Free 22 * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 23 * MA 02111-1307, USA. 24 */ 25 26 27 /* 28 * Memory handling. All memory allocations made by the mpatrol library 29 * are performed by this module. This provides an interface which shields 30 * the rest of the library source code from the system calls required to 31 * allocate and manipulate memory on different operating systems. 32 */ 33 34 35 /* 36 * $Id: memory.h,v 1.14 2002/01/08 20:13:59 graeme Exp $ 37 */ 38 39 40 #include "config.h" 41 #include <stddef.h> 42 43 44 #define FLG_USEMMAP 1 /* use mmap() to allocate user memory */ 45 46 47 /* The different types of memory access permissions. 48 */ 49 50 typedef enum memaccess 51 { 52 MA_NOACCESS, /* no read or write */ 53 MA_READONLY, /* no write */ 54 MA_READWRITE /* both read and write */ 55 } 56 memaccess; 57 58 59 /* A meminfo structure contains details about the underlying memory 60 * architecture. 61 */ 62 63 typedef struct meminfo 64 { 65 size_t align; /* most restrictive alignment */ 66 size_t page; /* system page size */ 67 int stackdir; /* stack direction */ 68 char *prog; /* program filename */ 69 int mfile; /* memory mapped file handle */ 70 int wfile; /* watch point control file handle */ 71 unsigned char flags; /* control flags */ 72 } 73 meminfo; 74 75 76 #ifdef __cplusplus 77 extern "C" 78 { 79 #endif /* __cplusplus */ 80 81 82 MP_EXPORT void __mp_newmemory(meminfo *); 83 MP_EXPORT void __mp_endmemory(meminfo *); 84 MP_EXPORT unsigned long __mp_processid(void); 85 MP_EXPORT void *__mp_memalloc(meminfo *, size_t *, size_t, int); 86 MP_EXPORT void __mp_memfree(meminfo *, void *, size_t); 87 MP_EXPORT memaccess __mp_memquery(meminfo *, void *); 88 MP_EXPORT int __mp_memprotect(meminfo *, void *, size_t, memaccess); 89 MP_EXPORT int __mp_memwatch(meminfo *, void *, size_t, memaccess); 90 MP_EXPORT void *__mp_memcheck(void *, char, size_t); 91 MP_EXPORT void *__mp_memcompare(void *, void *, size_t); 92 MP_EXPORT void *__mp_memfind(void *, size_t, void *, size_t); 93 MP_EXPORT void __mp_memset(void *, char, size_t); 94 MP_EXPORT void __mp_memcopy(void *, void *, size_t); 95 96 97 #ifdef __cplusplus 98 } 99 #endif /* __cplusplus */ 100 101 102 #endif /* MP_MEMORY_H */ 103