mirror of https://github.com/rusefi/lua.git
no more 'luaO_nilobject' to avoid comparison of global variable addresses
(now uses static variables)
This commit is contained in:
parent
fb8fa66136
commit
505fc91222
8
lapi.c
8
lapi.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lapi.c,v 2.290 2018/02/27 20:01:55 roberto Exp roberto $
|
||||
** $Id: lapi.c,v 2.291 2018/04/04 14:23:41 roberto Exp roberto $
|
||||
** Lua API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -38,10 +38,12 @@ const char lua_ident[] =
|
|||
|
||||
|
||||
/* value at a non-valid index */
|
||||
#define NONVALIDVALUE cast(TValue *, luaO_nilobject)
|
||||
|
||||
static const TValue nonvalidvaluep = {NILCONSTANT};
|
||||
#define NONVALIDVALUE cast(TValue *, &nonvalidvaluep)
|
||||
|
||||
/* corresponding test */
|
||||
#define isvalid(o) ((o) != luaO_nilobject)
|
||||
#define isvalid(o) ((o) != &nonvalidvaluep)
|
||||
|
||||
/* test for pseudo index */
|
||||
#define ispseudo(i) ((i) <= LUA_REGISTRYINDEX)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lobject.c,v 2.124 2018/02/27 18:47:32 roberto Exp roberto $
|
||||
** $Id: lobject.c,v 2.125 2018/04/25 16:26:20 roberto Exp roberto $
|
||||
** Some generic functions over Lua objects
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -29,10 +29,6 @@
|
|||
#include "lvm.h"
|
||||
|
||||
|
||||
|
||||
LUAI_DDEF const TValue luaO_nilobject_ = {NILCONSTANT};
|
||||
|
||||
|
||||
/*
|
||||
** converts an integer to a "floating point byte", represented as
|
||||
** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lobject.h,v 2.142 2018/04/04 14:23:41 roberto Exp roberto $
|
||||
** $Id: lobject.h,v 2.143 2018/06/01 16:51:34 roberto Exp roberto $
|
||||
** Type definitions for Lua objects
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -150,10 +150,6 @@ typedef StackValue *StkId; /* index to stack elements */
|
|||
#define setnilvalue(obj) settt_(obj, LUA_TNIL)
|
||||
|
||||
|
||||
/* (address of) a fixed nil value */
|
||||
#define luaO_nilobject (&luaO_nilobject_)
|
||||
|
||||
|
||||
/*
|
||||
** Variant tag, used only in tables to signal an empty slot
|
||||
** (which might be different from a slot containing nil)
|
||||
|
@ -730,8 +726,6 @@ typedef struct Table {
|
|||
#define sizenode(t) (twoto((t)->lsizenode))
|
||||
|
||||
|
||||
LUAI_DDEC const TValue luaO_nilobject_;
|
||||
|
||||
/* size of buffer for 'luaO_utf8esc' function */
|
||||
#define UTF8BUFFSZ 8
|
||||
|
||||
|
|
5
lstate.c
5
lstate.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lstate.c,v 2.151 2018/02/05 17:11:37 roberto Exp roberto $
|
||||
** $Id: lstate.c,v 2.152 2018/05/29 18:02:51 roberto Exp roberto $
|
||||
** Global State
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -69,12 +69,11 @@ typedef struct LG {
|
|||
memcpy(b + p, &t, sizeof(t)); p += sizeof(t); }
|
||||
|
||||
static unsigned int luai_makeseed (lua_State *L) {
|
||||
char buff[4 * sizeof(size_t)];
|
||||
char buff[3 * sizeof(size_t)];
|
||||
unsigned int h = cast_uint(time(NULL));
|
||||
int p = 0;
|
||||
addbuff(buff, p, L); /* heap variable */
|
||||
addbuff(buff, p, &h); /* local variable */
|
||||
addbuff(buff, p, luaO_nilobject); /* global variable */
|
||||
addbuff(buff, p, &lua_newstate); /* public function */
|
||||
lua_assert(p == sizeof(buff));
|
||||
return luaS_hash(buff, p, h);
|
||||
|
|
5
ltm.c
5
ltm.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: ltm.c,v 2.66 2018/02/27 17:48:28 roberto Exp roberto $
|
||||
** $Id: ltm.c,v 2.67 2018/04/04 14:23:41 roberto Exp roberto $
|
||||
** Tag methods
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -69,6 +69,7 @@ const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
|
|||
|
||||
|
||||
const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
|
||||
static const TValue nilobject = {NILCONSTANT};
|
||||
Table *mt;
|
||||
switch (ttype(o)) {
|
||||
case LUA_TTABLE:
|
||||
|
@ -80,7 +81,7 @@ const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
|
|||
default:
|
||||
mt = G(L)->mt[ttype(o)];
|
||||
}
|
||||
return (mt ? luaH_getshortstr(mt, G(L)->tmname[event]) : luaO_nilobject);
|
||||
return (mt ? luaH_getshortstr(mt, G(L)->tmname[event]) : &nilobject);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue