diff options
author | Mike Pall <mike> | 2010-01-24 15:50:59 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2010-01-24 15:50:59 +0100 |
commit | 055396a69d9588bf77227f516bf86ff080abdcc4 (patch) | |
tree | 62c33a18a57318744db9144bd91fd0df9b96f5ac /src | |
parent | 43f1e134709b06be7091ad8f6cfaaaa78adec886 (diff) | |
download | luajit-055396a69d9588bf77227f516bf86ff080abdcc4.tar.gz luajit-055396a69d9588bf77227f516bf86ff080abdcc4.tar.bz2 luajit-055396a69d9588bf77227f516bf86ff080abdcc4.zip |
Force error if lua_newstate() is used in 64 bit mode.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib_aux.c | 14 | ||||
-rw-r--r-- | src/lj_state.c | 4 | ||||
-rw-r--r-- | src/lj_state.h | 3 |
3 files changed, 21 insertions, 0 deletions
diff --git a/src/lib_aux.c b/src/lib_aux.c index 419650a9..25a3b5ce 100644 --- a/src/lib_aux.c +++ b/src/lib_aux.c | |||
@@ -18,6 +18,7 @@ | |||
18 | 18 | ||
19 | #include "lj_obj.h" | 19 | #include "lj_obj.h" |
20 | #include "lj_err.h" | 20 | #include "lj_err.h" |
21 | #include "lj_state.h" | ||
21 | #include "lj_lib.h" | 22 | #include "lj_lib.h" |
22 | 23 | ||
23 | /* -- Module registration ------------------------------------------------- */ | 24 | /* -- Module registration ------------------------------------------------- */ |
@@ -349,8 +350,21 @@ static int panic(lua_State *L) | |||
349 | 350 | ||
350 | LUALIB_API lua_State *luaL_newstate(void) | 351 | LUALIB_API lua_State *luaL_newstate(void) |
351 | { | 352 | { |
353 | #if LJ_64 | ||
354 | lua_State *L = lj_state_newstate(mem_alloc, mem_create()); | ||
355 | #else | ||
352 | lua_State *L = lua_newstate(mem_alloc, mem_create()); | 356 | lua_State *L = lua_newstate(mem_alloc, mem_create()); |
357 | #endif | ||
353 | if (L) G(L)->panic = panic; | 358 | if (L) G(L)->panic = panic; |
354 | return L; | 359 | return L; |
355 | } | 360 | } |
356 | 361 | ||
362 | #if LJ_64 | ||
363 | LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) | ||
364 | { | ||
365 | UNUSED(f); UNUSED(ud); | ||
366 | fprintf(stderr, "Must use luaL_newstate() for 64 bit target\n"); | ||
367 | return NULL; | ||
368 | } | ||
369 | #endif | ||
370 | |||
diff --git a/src/lj_state.c b/src/lj_state.c index f7f30117..87043dd5 100644 --- a/src/lj_state.c +++ b/src/lj_state.c | |||
@@ -158,7 +158,11 @@ static void close_state(lua_State *L) | |||
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
161 | #if LJ_64 | ||
162 | lua_State *lj_state_newstate(lua_Alloc f, void *ud) | ||
163 | #else | ||
161 | LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) | 164 | LUA_API lua_State *lua_newstate(lua_Alloc f, void *ud) |
165 | #endif | ||
162 | { | 166 | { |
163 | GG_State *GG = cast(GG_State *, f(ud, NULL, 0, sizeof(GG_State))); | 167 | GG_State *GG = cast(GG_State *, f(ud, NULL, 0, sizeof(GG_State))); |
164 | lua_State *L = &GG->L; | 168 | lua_State *L = &GG->L; |
diff --git a/src/lj_state.h b/src/lj_state.h index 2238be64..cd2f216d 100644 --- a/src/lj_state.h +++ b/src/lj_state.h | |||
@@ -27,5 +27,8 @@ static LJ_AINLINE void lj_state_checkstack(lua_State *L, MSize need) | |||
27 | 27 | ||
28 | LJ_FUNC lua_State *lj_state_new(lua_State *L); | 28 | LJ_FUNC lua_State *lj_state_new(lua_State *L); |
29 | LJ_FUNC void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L); | 29 | LJ_FUNC void LJ_FASTCALL lj_state_free(global_State *g, lua_State *L); |
30 | #if LJ_64 | ||
31 | LJ_FUNC lua_State *lj_state_newstate(lua_Alloc f, void *ud); | ||
32 | #endif | ||
30 | 33 | ||
31 | #endif | 34 | #endif |