diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-06-18 09:08:10 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-06-18 09:08:10 -0300 |
commit | af70905246acfad225904b64d027e5b01c7b10eb (patch) | |
tree | b6d62db411706f5317e1269aff90e05399cd51b8 | |
parent | b95e46621873cfb460e1d11dcd153914d5d69f86 (diff) | |
download | lua-af70905246acfad225904b64d027e5b01c7b10eb.tar.gz lua-af70905246acfad225904b64d027e5b01c7b10eb.tar.bz2 lua-af70905246acfad225904b64d027e5b01c7b10eb.zip |
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.c | 9 | ||||
-rw-r--r-- | lauxlib.c | 10 | ||||
-rw-r--r-- | lmem.c | 4 | ||||
-rw-r--r-- | lstate.c | 11 | ||||
-rw-r--r-- | lstate.h | 3 | ||||
-rw-r--r-- | lua.h | 4 |
6 files changed, 18 insertions, 23 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 2.293 2018/06/15 17:30:52 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.294 2018/06/15 19:31:22 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -138,10 +138,9 @@ LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) { | |||
138 | } | 138 | } |
139 | 139 | ||
140 | 140 | ||
141 | LUA_API const lua_Number *lua_version (lua_State *L) { | 141 | LUA_API lua_Number lua_version (lua_State *L) { |
142 | static const lua_Number version = LUA_VERSION_NUM; | 142 | UNUSED(L); |
143 | if (L == NULL) return &version; | 143 | return LUA_VERSION_NUM; |
144 | else return G(L)->version; | ||
145 | } | 144 | } |
146 | 145 | ||
147 | 146 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.293 2018/02/21 13:48:44 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.294 2018/02/27 18:47:32 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -950,13 +950,11 @@ LUALIB_API lua_State *luaL_newstate (void) { | |||
950 | 950 | ||
951 | 951 | ||
952 | LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver, size_t sz) { | 952 | LUALIB_API void luaL_checkversion_ (lua_State *L, lua_Number ver, size_t sz) { |
953 | const lua_Number *v = lua_version(L); | 953 | lua_Number v = lua_version(L); |
954 | if (sz != LUAL_NUMSIZES) /* check numeric types */ | 954 | if (sz != LUAL_NUMSIZES) /* check numeric types */ |
955 | luaL_error(L, "core and library have incompatible numeric types"); | 955 | luaL_error(L, "core and library have incompatible numeric types"); |
956 | if (v != lua_version(NULL)) | 956 | else if (v != ver) |
957 | luaL_error(L, "multiple Lua VMs detected"); | ||
958 | else if (*v != ver) | ||
959 | luaL_error(L, "version mismatch: app. needs %f, Lua core provides %f", | 957 | luaL_error(L, "version mismatch: app. needs %f, Lua core provides %f", |
960 | (LUAI_UACNUMBER)ver, (LUAI_UACNUMBER)*v); | 958 | (LUAI_UACNUMBER)ver, (LUAI_UACNUMBER)v); |
961 | } | 959 | } |
962 | 960 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lmem.c,v 1.96 2018/01/28 15:13:26 roberto Exp roberto $ | 2 | ** $Id: lmem.c,v 1.97 2018/05/30 14:25:52 roberto Exp roberto $ |
3 | ** Interface to Memory Manager | 3 | ** Interface to Memory Manager |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -123,7 +123,7 @@ void luaM_free_ (lua_State *L, void *block, size_t osize) { | |||
123 | static void *tryagain (lua_State *L, void *block, | 123 | static void *tryagain (lua_State *L, void *block, |
124 | size_t osize, size_t nsize) { | 124 | size_t osize, size_t nsize) { |
125 | global_State *g = G(L); | 125 | global_State *g = G(L); |
126 | if (g->version) { /* is state fully build? */ | 126 | if (ttisnil(&g->nilvalue)) { /* is state fully build? */ |
127 | luaC_fullgc(L, 1); /* try to free some memory... */ | 127 | luaC_fullgc(L, 1); /* try to free some memory... */ |
128 | return (*g->frealloc)(g->ud, block, osize, nsize); /* try again */ | 128 | return (*g->frealloc)(g->ud, block, osize, nsize); /* try again */ |
129 | } | 129 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.c,v 2.153 2018/06/01 17:40:38 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 2.154 2018/06/15 19:31:22 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -215,7 +215,7 @@ static void init_registry (lua_State *L, global_State *g) { | |||
215 | 215 | ||
216 | /* | 216 | /* |
217 | ** open parts of the state that may cause memory-allocation errors. | 217 | ** open parts of the state that may cause memory-allocation errors. |
218 | ** ('g->version' != NULL flags that the state was completely build) | 218 | ** ('ttisnil(&g->nilvalue)'' flags that the state was completely build) |
219 | */ | 219 | */ |
220 | static void f_luaopen (lua_State *L, void *ud) { | 220 | static void f_luaopen (lua_State *L, void *ud) { |
221 | global_State *g = G(L); | 221 | global_State *g = G(L); |
@@ -226,7 +226,7 @@ static void f_luaopen (lua_State *L, void *ud) { | |||
226 | luaT_init(L); | 226 | luaT_init(L); |
227 | luaX_init(L); | 227 | luaX_init(L); |
228 | g->gcrunning = 1; /* allow gc */ | 228 | g->gcrunning = 1; /* allow gc */ |
229 | g->version = lua_version(NULL); | 229 | setnilvalue(&g->nilvalue); |
230 | luai_userstateopen(L); | 230 | luai_userstateopen(L); |
231 | } | 231 | } |
232 | 232 | ||
@@ -260,7 +260,7 @@ static void close_state (lua_State *L) { | |||
260 | global_State *g = G(L); | 260 | global_State *g = G(L); |
261 | luaF_close(L, L->stack); /* close all upvalues for this thread */ | 261 | luaF_close(L, L->stack); /* close all upvalues for this thread */ |
262 | luaC_freeallobjects(L); /* collect all objects */ | 262 | luaC_freeallobjects(L); /* collect all objects */ |
263 | if (g->version) /* closing a fully built state? */ | 263 | if (ttisnil(&g->nilvalue)) /* closing a fully built state? */ |
264 | luai_userstateclose(L); | 264 | luai_userstateclose(L); |
265 | luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size); | 265 | luaM_freearray(L, G(L)->strt.hash, G(L)->strt.size); |
266 | freestack(L); | 266 | freestack(L); |
@@ -332,7 +332,6 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { | |||
332 | g->strt.hash = NULL; | 332 | g->strt.hash = NULL; |
333 | setnilvalue(&g->l_registry); | 333 | setnilvalue(&g->l_registry); |
334 | g->panic = NULL; | 334 | g->panic = NULL; |
335 | g->version = NULL; | ||
336 | g->gcstate = GCSpause; | 335 | g->gcstate = GCSpause; |
337 | g->gckind = KGC_INC; | 336 | g->gckind = KGC_INC; |
338 | g->gcemergency = 0; | 337 | g->gcemergency = 0; |
@@ -345,7 +344,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { | |||
345 | g->twups = NULL; | 344 | g->twups = NULL; |
346 | g->totalbytes = sizeof(LG); | 345 | g->totalbytes = sizeof(LG); |
347 | g->GCdebt = 0; | 346 | g->GCdebt = 0; |
348 | setnilvalue(&g->nilvalue); | 347 | setivalue(&g->nilvalue, 0); /* to signal that state is not yet built */ |
349 | setgcparam(g->gcpause, LUAI_GCPAUSE); | 348 | setgcparam(g->gcpause, LUAI_GCPAUSE); |
350 | setgcparam(g->gcstepmul, LUAI_GCMUL); | 349 | setgcparam(g->gcstepmul, LUAI_GCMUL); |
351 | g->gcstepsize = LUAI_GCSTEPSIZE; | 350 | g->gcstepsize = LUAI_GCSTEPSIZE; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.h,v 2.158 2018/03/16 15:33:34 roberto Exp roberto $ | 2 | ** $Id: lstate.h,v 2.159 2018/06/15 19:31:22 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -181,7 +181,6 @@ typedef struct global_State { | |||
181 | struct lua_State *twups; /* list of threads with open upvalues */ | 181 | struct lua_State *twups; /* list of threads with open upvalues */ |
182 | lua_CFunction panic; /* to be called in unprotected errors */ | 182 | lua_CFunction panic; /* to be called in unprotected errors */ |
183 | struct lua_State *mainthread; | 183 | struct lua_State *mainthread; |
184 | const lua_Number *version; /* pointer to version number */ | ||
185 | TString *memerrmsg; /* message for memory-allocation errors */ | 184 | TString *memerrmsg; /* message for memory-allocation errors */ |
186 | TString *tmname[TM_N]; /* array with tag-method names */ | 185 | TString *tmname[TM_N]; /* array with tag-method names */ |
187 | struct Table *mt[LUA_NUMTAGS]; /* metatables for basic types */ | 186 | struct Table *mt[LUA_NUMTAGS]; /* metatables for basic types */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.345 2018/03/16 15:33:34 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.346 2018/04/04 14:23:41 roberto Exp roberto $ |
3 | ** Lua - A Scripting Language | 3 | ** Lua - A Scripting Language |
4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) | 4 | ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) |
5 | ** See Copyright Notice at the end of this file | 5 | ** See Copyright Notice at the end of this file |
@@ -149,7 +149,7 @@ LUA_API lua_State *(lua_newthread) (lua_State *L); | |||
149 | LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); | 149 | LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); |
150 | 150 | ||
151 | 151 | ||
152 | LUA_API const lua_Number *(lua_version) (lua_State *L); | 152 | LUA_API lua_Number (lua_version) (lua_State *L); |
153 | 153 | ||
154 | 154 | ||
155 | /* | 155 | /* |