Proper x86_64 mnemonics
[cacao.git] / src / mm / dumpmemory.h
1 /* src/mm/dumpmemory.h - dump memory management
2
3    Copyright (C) 1996-2005, 2006, 2007, 2008
4    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
6    This file is part of CACAO.
7
8    This program is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License as
10    published by the Free Software Foundation; either version 2, or (at
11    your option) any later version.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23 */
24
25
26 #ifndef _DUMPMEMORY_H
27 #define _DUMPMEMORY_H
28
29 /* forward typedefs ***********************************************************/
30
31 typedef struct dumpblock_t dumpblock_t;
32 typedef struct dumpinfo_t  dumpinfo_t;
33
34 #include "config.h"
35
36 #include <stdint.h>
37 #include <string.h>
38
39
40 /* ATTENTION: We need to define dumpblock_t and dumpinfo_t before
41    internal includes, as we need dumpinfo_t as nested structure in
42    threadobject. */
43
44 /* dumpblock ******************************************************************/
45
46 #define DUMPBLOCKSIZE    2 << 13    /* 2 * 8192 bytes */
47 #define ALIGNSIZE        8
48
49 struct dumpblock_t {
50         dumpblock_t *prev;
51         void        *dumpmem;
52         int32_t      size;
53 };
54
55
56 /* dump_allocation *************************************************************
57
58    This struct is used to record dump memory allocations for ENABLE_MEMCHECK.
59
60 *******************************************************************************/
61
62 #if defined(ENABLE_MEMCHECK)
63 typedef struct dump_allocation_t dump_allocation_t;
64
65 struct dump_allocation_t {
66         dump_allocation_t *next;
67         void              *mem;
68         int32_t            used;
69         int32_t            size;
70 };
71 #endif
72
73
74 /* dumpinfo *******************************************************************/
75
76 struct dumpinfo_t {
77         dumpblock_t       *block;                   /* the current top-most block */
78         int32_t            allocated;             /* allocated bytes in this area */
79         int32_t            used;                  /* used bytes in this dump area */
80 #if defined(ENABLE_MEMCHECK)
81         dump_allocation_t *allocations;       /* list of allocations in this area */
82 #endif
83 };
84
85
86 /* convenience macros *********************************************************/
87
88 #define DMARKER               dumpmarker = dumpmemory_marker()
89 #define DRELEASE              dumpmemory_release(dumpmarker)
90
91 #define DNEW(type)            ((type *) dumpmemory_get(sizeof(type)))
92 #define DMNEW(type,num)       ((type *) dumpmemory_get(sizeof(type) * (num)))
93 #define DMREALLOC(ptr,type,num1,num2) dumpmemory_realloc((ptr), sizeof(type) * (num1), \
94                                                           sizeof(type) * (num2))
95
96 /* function prototypes ********************************************************/
97
98 void    *dumpmemory_get(size_t size);
99 void    *dumpmemory_realloc(void *src, int32_t len1, int32_t len2);
100 int32_t  dumpmemory_marker(void);
101 void     dumpmemory_release(int32_t size);
102
103 #endif /* _DUMPMEMORY_H */
104
105
106 /*
107  * These are local overrides for various environment variables in Emacs.
108  * Please do not remove this and leave it at the end of the file, where
109  * Emacs will automagically detect them.
110  * ---------------------------------------------------------------------
111  * Local variables:
112  * mode: c
113  * indent-tabs-mode: t
114  * c-basic-offset: 4
115  * tab-width: 4
116  * End:
117  * vim:noexpandtab:sw=4:ts=4:
118  */