mirror of
https://github.com/1dot13/source.git
synced 2026-08-26 14:30:26 +02:00
The tree carried two prebuilt Lua static libraries and a copy of the Lua public headers. lua51.lib is 5.1.2 and matched the headers; lua51.vc9.lib is 5.1.4 and was dead weight — it came second in Ja2_Libraries, so the linker resolved every Lua symbol out of lua51.lib and never pulled an object from it. Just as well, since it asks for /DEFAULTLIB:MSVCRT while we build /MT. ext/lua-5.1.5 is the upstream tarball unmodified, built as lua51 the way the other vendored libraries are, and its src directory replaces lua/ as the home of lua.h, luaconf.h, lauxlib.h and lualib.h. Those four headers were stock 5.1.2 retabbed, so 5.1.5 is bugfix-only against what the game compiled against; the bytecode format is unchanged across 5.1.x and every script under gamedir is plain source anyway. lua/lua.hpp had no includers and returns to etc/ where upstream keeps it. /SAFESEH:NO goes with it. Its two stated reasons were lua51.lib and the smackw32 import library, and both are now gone: every remaining prebuilt static library is SAFESEH-clean (libexpatMT.lib 5 of 5 members with @feat.00 = 0x1, RakNetLibStatic.lib 79 of 79), and lld-link emits a 3155-entry SEHandlerTable without it. The /MT comment blamed the wrong library. lua51.lib carried no linker directives at all; RakNetLibStatic.lib is what pins us to the static runtime, with /DEFAULTLIB:LIBCMT and /DEFAULTLIB:libcpmt. Verified by building all four applications in Debug and Release, and by linking the tarball's own lua.c against our lua51.lib with the build's clang-cl flags and running it under Wine: 5.1 stdlib, GC, coroutines and the x86 __asm fld/fistp lua_number2int fast path all behave. The game itself could not be launched here — this checkout's gamedir has loose Data directories but no SLF archives, so VFS aborts on Data\Ambient.slf long before any script runs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
111 lines
3.1 KiB
C
111 lines
3.1 KiB
C
/*
|
|
** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $
|
|
** Garbage Collector
|
|
** See Copyright Notice in lua.h
|
|
*/
|
|
|
|
#ifndef lgc_h
|
|
#define lgc_h
|
|
|
|
|
|
#include "lobject.h"
|
|
|
|
|
|
/*
|
|
** Possible states of the Garbage Collector
|
|
*/
|
|
#define GCSpause 0
|
|
#define GCSpropagate 1
|
|
#define GCSsweepstring 2
|
|
#define GCSsweep 3
|
|
#define GCSfinalize 4
|
|
|
|
|
|
/*
|
|
** some userful bit tricks
|
|
*/
|
|
#define resetbits(x,m) ((x) &= cast(lu_byte, ~(m)))
|
|
#define setbits(x,m) ((x) |= (m))
|
|
#define testbits(x,m) ((x) & (m))
|
|
#define bitmask(b) (1<<(b))
|
|
#define bit2mask(b1,b2) (bitmask(b1) | bitmask(b2))
|
|
#define l_setbit(x,b) setbits(x, bitmask(b))
|
|
#define resetbit(x,b) resetbits(x, bitmask(b))
|
|
#define testbit(x,b) testbits(x, bitmask(b))
|
|
#define set2bits(x,b1,b2) setbits(x, (bit2mask(b1, b2)))
|
|
#define reset2bits(x,b1,b2) resetbits(x, (bit2mask(b1, b2)))
|
|
#define test2bits(x,b1,b2) testbits(x, (bit2mask(b1, b2)))
|
|
|
|
|
|
|
|
/*
|
|
** Layout for bit use in `marked' field:
|
|
** bit 0 - object is white (type 0)
|
|
** bit 1 - object is white (type 1)
|
|
** bit 2 - object is black
|
|
** bit 3 - for userdata: has been finalized
|
|
** bit 3 - for tables: has weak keys
|
|
** bit 4 - for tables: has weak values
|
|
** bit 5 - object is fixed (should not be collected)
|
|
** bit 6 - object is "super" fixed (only the main thread)
|
|
*/
|
|
|
|
|
|
#define WHITE0BIT 0
|
|
#define WHITE1BIT 1
|
|
#define BLACKBIT 2
|
|
#define FINALIZEDBIT 3
|
|
#define KEYWEAKBIT 3
|
|
#define VALUEWEAKBIT 4
|
|
#define FIXEDBIT 5
|
|
#define SFIXEDBIT 6
|
|
#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT)
|
|
|
|
|
|
#define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT)
|
|
#define isblack(x) testbit((x)->gch.marked, BLACKBIT)
|
|
#define isgray(x) (!isblack(x) && !iswhite(x))
|
|
|
|
#define otherwhite(g) (g->currentwhite ^ WHITEBITS)
|
|
#define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS)
|
|
|
|
#define changewhite(x) ((x)->gch.marked ^= WHITEBITS)
|
|
#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT)
|
|
|
|
#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x)))
|
|
|
|
#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS)
|
|
|
|
|
|
#define luaC_checkGC(L) { \
|
|
condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1)); \
|
|
if (G(L)->totalbytes >= G(L)->GCthreshold) \
|
|
luaC_step(L); }
|
|
|
|
|
|
#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \
|
|
luaC_barrierf(L,obj2gco(p),gcvalue(v)); }
|
|
|
|
#define luaC_barriert(L,t,v) { if (valiswhite(v) && isblack(obj2gco(t))) \
|
|
luaC_barrierback(L,t); }
|
|
|
|
#define luaC_objbarrier(L,p,o) \
|
|
{ if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \
|
|
luaC_barrierf(L,obj2gco(p),obj2gco(o)); }
|
|
|
|
#define luaC_objbarriert(L,t,o) \
|
|
{ if (iswhite(obj2gco(o)) && isblack(obj2gco(t))) luaC_barrierback(L,t); }
|
|
|
|
LUAI_FUNC size_t luaC_separateudata (lua_State *L, int all);
|
|
LUAI_FUNC void luaC_callGCTM (lua_State *L);
|
|
LUAI_FUNC void luaC_freeall (lua_State *L);
|
|
LUAI_FUNC void luaC_step (lua_State *L);
|
|
LUAI_FUNC void luaC_fullgc (lua_State *L);
|
|
LUAI_FUNC void luaC_link (lua_State *L, GCObject *o, lu_byte tt);
|
|
LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv);
|
|
LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v);
|
|
LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t);
|
|
|
|
|
|
#endif
|