summaryrefslogtreecommitdiff
path: root/lgc.h
blob: 29adec24548a2546c81137230a80a5a75090a63e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
** $Id: lgc.h,v 1.21 2003/07/29 19:25:37 roberto Exp roberto $
** Garbage Collector
** See Copyright Notice in lua.h
*/

#ifndef lgc_h
#define lgc_h


#include "lobject.h"


/*
 * ** some userful bit tricks
 * */
#define bitmask(b)	(1<<(b))
#define setbit(x,b)	((x) |= bitmask(b))
#define resetbit(x,b)	((x) &= cast(lu_byte, ~bitmask(b)))
#define testbit(x,b)	((x) & bitmask(b))



/*
** Layout for bit use in `marked' field:
** bit 0 - object is white (not used yet)
** bit 1 - object is black
** bit 2 - For userdata: is finalized;
           for tables: has weak keys
** bit 3 - for tables: has weak values
** bit 4 - for strings: is fixed (should not be collected)
*/

#define WHITEBIT	0
#define BLACKBIT	1
#define FINALIZEDBIT	2
#define KEYWEAKBIT	2
#define VALUEWEAKBIT	3
#define FIXEDBIT	4



#define luaC_checkGC(L) { if (G(L)->nblocks >= G(L)->GCthreshold) \
	luaC_collectgarbage(L); }


size_t luaC_separateudata (lua_State *L);
void luaC_callGCTM (lua_State *L);
void luaC_sweep (lua_State *L, int all);
void luaC_collectgarbage (lua_State *L);
void luaC_link (lua_State *L, GCObject *o, lu_byte tt);


#endif