BlitzMax Extended
0.8.17
Pushing Blitz to the Max.
Main Page
Related Pages
Data Structures
Files
File List
Globals
c
blitz_gc.h
Go to the documentation of this file.
1
23
#ifndef BLITZ_GC_H
24
#define BLITZ_GC_H
25
26
#include "_common.h"
27
28
BB_BEGIN_DECLS
29
30
#ifdef BB_THREADED
31
# include "
blitz_thread.h
"
32
# ifndef BB_GC_MS
33
# define BB_GC_MS
34
# endif
35
#else
36
# ifndef BB_GC_RC
37
# define BB_GC_RC
38
# endif
39
#endif
40
41
#define BBGC_MANYREFS 0x40000000
42
43
// Probably shouldn't be here...
44
#if __ppc__
45
# define BBGC_NUM_ROOTREGS 19
46
#else
47
# define BBGC_NUM_ROOTREGS 4
48
#endif // __ppc__
49
50
void
* bbGCRootRegs(
void
*ptr);
51
void
bbGCStartup();
52
57
enum
BBGCMode
58
{
65
BBGC_AUTOMATIC
= 1,
66
74
BBGC_MANUAL
= 2,
75
76
BBGC_AGGRESSIVE = -1
77
};
78
79
#define BBGC_MODE_ISVALID(mode) \
80
( \
81
(mode) == BBGC_AUTOMATIC || \
82
(mode) == BBGC_MANUAL || \
83
(mode) == BBGC_AGGRESSIVE \
84
)
85
91
BBGCMode
bbGCGetMode
();
92
99
void
bbGCSetMode
(
BBGCMode
mode);
100
105
enum
BBGCDebugMode
106
{
111
BBGC_NODEBUG
,
112
114
BBGC_STDOUTDEBUG
115
};
116
123
void
bbGCSetDebug
(
BBGCDebugMode
mode);
124
130
enum
BBGCAllocFlags
131
{
135
BBGC_DEFAULT,
136
140
BBGC_ATOMIC,
141
145
BBGC_FINALIZE
146
};
147
154
void
*
bbGCMalloc
(
BBInt
size,
BBInt
flags);
155
166
BBObject
* bbGCAllocObject(BBSize size,
const
BBClass
*clas,
BBInt
flags);
167
173
BBBool
bbGCValidate
(
const
void
*ptr);
174
179
BBInt
bbGCMemAlloced
();
180
189
BBInt
bbGCCollect
();
190
196
#define BBGC_MAX_SUSPENDED (BBINT_MAX - 1)
197
213
void
bbGCSuspend
();
214
222
BBBool
bbGCIsSuspended
();
223
233
void
bbGCResume
();
234
238
void
bbGCRetain(
BBObject
*obj);
239
243
void
bbGCRelease(
BBObject
*obj);
244
245
// BB_RETAIN/BB_RELEASE should be used to prevent an object from garbage collection.
246
//
247
// This is mainly of use if an object is being stored outside of BlitzMax's 'sight' - say, in a C++ table.
248
// You can also use bbGCRetain/bbGCRelease functions above if necessary - MACROS are just faster.
249
250
#ifdef BB_GC_RC
251
# define BB_RETAIN(obj) { ++(obj)->refs; }
252
# define BB_RELEASE(obj) { if (!--(obj)->refs) { bbGCFree(obj); } }
253
#else
254
# define BB_RETAIN(obj) bbGCRetain(((BBObject *)(obj)));
255
# define BB_RELEASE(obj) bbGCRelease(((BBObject *)(obj)));
256
#endif
257
258
// Internal use only
259
#ifdef BB_GC_RC
260
261
/*
262
* Called when there are no more references (obj->refs == 0)
263
*
264
* \param obj The object to free
265
*/
266
void
bbGCFree(
BBObject
*obj);
267
268
/*
269
* Called after the destructor to send the memory to nirvana.
270
*
271
* \param obj The object to deallocate
272
* \param size The size of the object instance
273
*/
274
void
bbGCDeallocObject(
BBObject
*obj, BBSize size);
275
276
# define BB_INCREFS(obj) { ++(obj)->refs; }
277
# define BB_DECREFS(obj) { if (!--(obj)->refs) { bbGCFree(obj); } }
278
#else
279
# define BB_INCREFS(obj) {}
280
# define BB_DECREFS(obj) {}
281
#endif
282
283
// DEPERECATED
284
285
#ifndef BB_DISABLE_DEPRECATED
286
287
# ifdef BB_GC_RC
288
# define BBINCREFS(obj) { ++(obj)->refs; }
289
# define BBDECREFS(obj) { if (!--(obj)->refs) { bbGCFree(obj); } }
290
# define BBRETAIN(obj) { ++(obj)->refs; }
291
# define BBRELEASE(obj) { if (!--(obj)->refs) { bbGCFree(obj); } }
292
# else
293
# define BBINCREFS(obj) {}
294
# define BBDECREFS(obj) {}
295
# define BB_RETAIN(obj) bbGCRetain(((BBObject *)(obj)));
296
# define BB_RELEASE(obj) bbGCRelease(((BBObject *)(obj)));
297
# endif // !BB_GC_RC
298
299
#endif // !BB_DISABLE_DEPRECATED
300
301
BB_END_DECLS
302
303
#endif // BLITZ_GC_H
Generated on Sun Oct 7 2012 18:14:30 for BlitzMax Extended by
1.8.1.1