no more 'luaO_nilobject' to avoid comparison of global variable addresses
(now uses static variables)
diff --git a/lapi.c b/lapi.c
index 877fb2a..8855289 100644
--- a/lapi.c
+++ b/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 @@
/* 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)
diff --git a/lobject.c b/lobject.c
index 43dc1a2..8b8de37 100644
--- a/lobject.c
+++ b/lobject.c
@@ -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
diff --git a/lobject.h b/lobject.h
index a7b4318..da89666 100644
--- a/lobject.h
+++ b/lobject.h
@@ -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 @@
#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 @@
#define sizenode(t) (twoto((t)->lsizenode))
-LUAI_DDEC const TValue luaO_nilobject_;
-
/* size of buffer for 'luaO_utf8esc' function */
#define UTF8BUFFSZ 8
diff --git a/lstate.c b/lstate.c
index 5a2c357..2622a1d 100644
--- a/lstate.c
+++ b/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 @@
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);
diff --git a/ltm.c b/ltm.c
index 6d28551..f078430 100644
--- a/ltm.c
+++ b/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_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 @@
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);
}