misc/liblua/lgc.h
author Wuzzy <almikes@aol.com>
Sun, 08 Oct 2017 20:24:58 +0200
changeset 12681 2e6dcd97f085
parent 10017 de822cd3df3a
permissions -rw-r--r--
No longer jiggle sticky mines if using portable portal device This fixes the sticky mine sound playing when using portal gun while any sticky mine is placed on ground. We decided that placed sticky mines can't be teleported.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     1
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     2
** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     3
** Garbage Collector
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     4
** See Copyright Notice in lua.h
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     5
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     6
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     7
#ifndef lgc_h
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     8
#define lgc_h
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
     9
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    10
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    11
#include "lobject.h"
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    12
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    13
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    14
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    15
** Possible states of the Garbage Collector
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    16
*/
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    17
#define GCSpause    0
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    18
#define GCSpropagate    1
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    19
#define GCSsweepstring  2
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    20
#define GCSsweep    3
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    21
#define GCSfinalize 4
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    22
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    23
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    24
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    25
** some userful bit tricks
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    26
*/
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    27
#define resetbits(x,m)  ((x) &= cast(lu_byte, ~(m)))
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    28
#define setbits(x,m)    ((x) |= (m))
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    29
#define testbits(x,m)   ((x) & (m))
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    30
#define bitmask(b)  (1<<(b))
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    31
#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2))
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    32
#define l_setbit(x,b)   setbits(x, bitmask(b))
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    33
#define resetbit(x,b)   resetbits(x, bitmask(b))
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    34
#define testbit(x,b)    testbits(x, bitmask(b))
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    35
#define set2bits(x,b1,b2)   setbits(x, (bit2mask(b1, b2)))
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    36
#define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2)))
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    37
#define test2bits(x,b1,b2)  testbits(x, (bit2mask(b1, b2)))
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    38
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    39
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    40
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    41
/*
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    42
** Layout for bit use in `marked' field:
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    43
** bit 0 - object is white (type 0)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    44
** bit 1 - object is white (type 1)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    45
** bit 2 - object is black
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    46
** bit 3 - for userdata: has been finalized
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    47
** bit 3 - for tables: has weak keys
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    48
** bit 4 - for tables: has weak values
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    49
** bit 5 - object is fixed (should not be collected)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    50
** bit 6 - object is "super" fixed (only the main thread)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    51
*/
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    52
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    53
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    54
#define WHITE0BIT   0
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    55
#define WHITE1BIT   1
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    56
#define BLACKBIT    2
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    57
#define FINALIZEDBIT    3
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    58
#define KEYWEAKBIT  3
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    59
#define VALUEWEAKBIT    4
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    60
#define FIXEDBIT    5
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    61
#define SFIXEDBIT   6
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    62
#define WHITEBITS   bit2mask(WHITE0BIT, WHITE1BIT)
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    63
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    64
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    65
#define iswhite(x)      test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT)
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    66
#define isblack(x)      testbit((x)->gch.marked, BLACKBIT)
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    67
#define isgray(x)   (!isblack(x) && !iswhite(x))
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    68
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    69
#define otherwhite(g)   (g->currentwhite ^ WHITEBITS)
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    70
#define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS)
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    71
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    72
#define changewhite(x)  ((x)->gch.marked ^= WHITEBITS)
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    73
#define gray2black(x)   l_setbit((x)->gch.marked, BLACKBIT)
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    74
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    75
#define valiswhite(x)   (iscollectable(x) && iswhite(gcvalue(x)))
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    76
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    77
#define luaC_white(g)   cast(lu_byte, (g)->currentwhite & WHITEBITS)
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    78
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    79
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    80
#define luaC_checkGC(L) { \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    81
  condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    82
  if (G(L)->totalbytes >= G(L)->GCthreshold) \
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    83
    luaC_step(L); }
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    84
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    85
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    86
#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p)))  \
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    87
    luaC_barrierf(L,obj2gco(p),gcvalue(v)); }
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    88
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    89
#define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t)))  \
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    90
    luaC_barrierback(L,t); }
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    91
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    92
#define luaC_objbarrier(L,p,o)  \
10017
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    93
    { if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \
de822cd3df3a fixwhitespace and dos2unix
koda
parents: 2812
diff changeset
    94
        luaC_barrierf(L,obj2gco(p),obj2gco(o)); }
2812
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    95
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    96
#define luaC_objbarriert(L,t,o)  \
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    97
   { if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); }
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    98
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
    99
LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   100
LUAI_FUNC void luaC_callGCTM (lua_State *L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   101
LUAI_FUNC void luaC_freeall (lua_State *L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   102
LUAI_FUNC void luaC_step (lua_State *L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   103
LUAI_FUNC void luaC_fullgc (lua_State *L);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   104
LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   105
LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   106
LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   107
LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t);
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   108
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   109
0a24853de796 add liblua to sources for macosx
koda
parents:
diff changeset
   110
#endif