summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-06-18 09:08:10 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-06-18 09:08:10 -0300
commitaf70905246acfad225904b64d027e5b01c7b10eb (patch)
treeb6d62db411706f5317e1269aff90e05399cd51b8
parentb95e46621873cfb460e1d11dcd153914d5d69f86 (diff)
downloadlua-github-af70905246acfad225904b64d027e5b01c7b10eb.tar.gz
no need to check whether libraries and host use the same kernel;
Lua should work correctly with several copies of the kernel
-rw-r--r--lapi.c9
-rw-r--r--lauxlib.c10
-rw-r--r--lmem.c4
-rw-r--r--lstate.c11
-rw-r--r--lstate.h3
-rw-r--r--lua.h4
6 files changed, 18 insertions, 23 deletions
diff --git a/lapi.c b/lapi.c
index 5d106076..e69215a8 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
/*
-** $Id: lapi.c,v 2.293 2018/06/15 17:30:52 roberto Exp roberto $
+** $Id: lapi.c,v 2.294 2018/06/15 19:31:22 roberto Exp roberto $
** Lua API
** See Copyright Notice in lua.h
*/
@@ -138,10 +138,9 @@ LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
}
-LUA_API const lua_Number *lua_version (lua_State *L) {
- static const lua_Number version = LUA_VERSION_NUM;
- if (L == NULL) return &version;
- else return G(L)->version;
+LUA_API lua_Number lua_version (lua_State *L) {
+ UNUSED(L);
+ return LUA_VERSION_NUM;
}
diff --git a/lauxlib.c b/lauxlib.c
index 215a83b1..a8f2cc2e 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lauxlib.c,v 1.293 2018/02/21 13:48:44 roberto Exp roberto $
+** $Id: lauxlib.c,v 1.294 2018/02/27 18:47:32 roberto Exp roberto $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@@ -950,13 +950,11 @@ LUALIB_API lua_State *luaL_newstate (void) {
LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver, size_t sz) {
- const lua_Number *v = lua_version(L);
+ lua_Number v = lua_version(L);
if (sz != LUAL_NUMSIZES) /* check numeric types */
luaL_error(L, "core and library have incompatible numeric types");
- if (v != lua_version(NULL))
- luaL_error(L, "multiple Lua VMs detected");
- else if (*v != ver)
+ else if (v != ver)
luaL_error(L, "version mismatch: app. needs %f, Lua core provides %f",
- (LUAI_UACNUMBER)ver, (LUAI_UACNUMBER)*v);
+ (LUAI_UACNUMBER)ver, (LUAI_UACNUMBER)v);
}
diff --git a/lmem.c b/lmem.c
index 5c73acd5..56b4affe 100644
--- a/lmem.c
+++ b/lmem.c
@@ -1,5 +1,5 @@
/*
-** $Id: lmem.c,v 1.96 2018/01/28 15:13:26 roberto Exp roberto $
+** $Id: lmem.c,v 1.97 2018/05/30 14:25:52 roberto Exp roberto $
** Interface to Memory Manager
** See Copyright Notice in lua.h
*/
@@ -123,7 +123,7 @@ void luaM_free_ (lua_State *L, void *block, size_t osize) {
static void *tryagain (lua_State *L, void *block,
size_t osize, size_t nsize) {
global_State *g = G(L);
- if (g->version) { /* is state fully build? */
+ if (ttisnil(&g->nilvalue)) { /* is state fully build? */
luaC_fullgc(L, 1); /* try to free some memory... */
return (*g->frealloc)(g->ud, block, osize, nsize); /* try again */
}
diff --git a/lstate.c b/lstate.c
index e369683e..d4b4def8 100644
--- a/lstate.c
+++ b/lstate.c
@@ -1,5 +1,5 @@
/*
-** $Id: lstate.c,v 2.153 2018/06/01 17:40:38 roberto Exp roberto $
+** $Id: lstate.c,v 2.154 2018/06/15 19:31:22 roberto Exp roberto $
** Global State
** See Copyright Notice in lua.h
*/
@@ -215,7 +215,7 @@ static void init_registry (lua_State *L, global_State *g) {
/*
** open parts of the state that may cause memory-allocation errors.
-** ('g->version' != NULL flags that the state was completely build)
+** ('ttisnil(&g->nilvalue)'' flags that the state was completely build)
*/
static void f_luaopen (lua_State *L, void *ud) {
global_State *g = G(L);
@@ -226,7 +226,7 @@ static void f_luaopen (lua_State *L, void *ud) {
luaT_init(L);
luaX_init(L);
g->gcrunning = 1; /* allow gc */
- g->version = lua_version(NULL);
+ setnilvalue(&g->nilvalue);
luai_userstateopen(L);
}
@@ -260,7 +260,7 @@ static void close_state (lua_State *L) {
global_State *g = G(L);
luaF_close(L, L->stack); /* close all upvalues for this thread */
luaC_freeallobjects(L); /* collect all objects */
- if (g->version) /* closing a fully built state? */
+ if (ttisnil(&g->nilvalue)) /* closing a fully built state? */
luai_userstateclose(L);
luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size);
freestack(L);
@@ -332,7 +332,6 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
g->strt.hash = NULL;
setnilvalue(&g->l_registry);
g->panic = NULL;
- g->version = NULL;
g->gcstate = GCSpause;
g->gckind = KGC_INC;
g->gcemergency = 0;
@@ -345,7 +344,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
g->twups = NULL;
g->totalbytes = sizeof(LG);
g->GCdebt = 0;
- setnilvalue(&g->nilvalue);
+ setivalue(&g->nilvalue, 0); /* to signal that state is not yet built */
setgcparam(g->gcpause, LUAI_GCPAUSE);
setgcparam(g->gcstepmul, LUAI_GCMUL);
g->gcstepsize = LUAI_GCSTEPSIZE;
diff --git a/lstate.h b/lstate.h
index 037b2be6..0e173b5b 100644
--- a/lstate.h
+++ b/lstate.h
@@ -1,5 +1,5 @@
/*
-** $Id: lstate.h,v 2.158 2018/03/16 15:33:34 roberto Exp roberto $
+** $Id: lstate.h,v 2.159 2018/06/15 19:31:22 roberto Exp roberto $
** Global State
** See Copyright Notice in lua.h
*/
@@ -181,7 +181,6 @@ typedef struct global_State {
struct lua_State *twups; /* list of threads with open upvalues */
lua_CFunction panic; /* to be called in unprotected errors */
struct lua_State *mainthread;
- const lua_Number *version; /* pointer to version number */
TString *memerrmsg; /* message for memory-allocation errors */
TString *tmname[TM_N]; /* array with tag-method names */
struct Table *mt[LUA_NUMTAGS]; /* metatables for basic types */
diff --git a/lua.h b/lua.h
index 3f76fbea..12d9e2ec 100644
--- a/lua.h
+++ b/lua.h
@@ -1,5 +1,5 @@
/*
-** $Id: lua.h,v 1.345 2018/03/16 15:33:34 roberto Exp roberto $
+** $Id: lua.h,v 1.346 2018/04/04 14:23:41 roberto Exp roberto $
** Lua - A Scripting Language
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
** See Copyright Notice at the end of this file
@@ -149,7 +149,7 @@ LUA_API lua_State *(lua_newthread) (lua_State *L);
LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
-LUA_API const lua_Number *(lua_version) (lua_State *L);
+LUA_API lua_Number (lua_version) (lua_State *L);
/*