summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Ahern <william@Williams-MacBook-Air.local>2012-10-10 17:28:15 -0700
committerWilliam Ahern <william@Williams-MacBook-Air.local>2012-10-10 17:28:15 -0700
commitfa810e8a50f93add49be889a36c154dd11c90744 (patch)
tree4e06905d6c71422fc2feee9abe17c875c86aa301
parent7bdf2557bbf7267542604567a0db809657b54d97 (diff)
downloadluaossl-fa810e8a50f93add49be889a36c154dd11c90744.tar.gz
luaossl-fa810e8a50f93add49be889a36c154dd11c90744.tar.bz2
luaossl-fa810e8a50f93add49be889a36c154dd11c90744.zip
-n
make build with LuaJIT
-rw-r--r--compat52.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/compat52.h b/compat52.h
index c674f13..a6d36be 100644
--- a/compat52.h
+++ b/compat52.h
@@ -1,3 +1,6 @@
1#if LUA_VERSION_NUM < 502
2
3#define LUA_OK 0
1 4
2 5
3static void luaL_setmetatable(lua_State *L, const char *tname) { 6static void luaL_setmetatable(lua_State *L, const char *tname) {
@@ -47,4 +50,71 @@ static void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup) {
47 (luaL_newlibtable((L), (l)), luaL_setfuncs((L), (l), 0)) 50 (luaL_newlibtable((L), (l)), luaL_setfuncs((L), (l), 0))
48 51
49 52
53static void luaL_requiref(lua_State *L, const char *modname, lua_CFunction openf, int glb) {
54 lua_pushcfunction(L, openf);
55 lua_pushstring(L, modname);
56 lua_call(L, 1, 1);
57
58 lua_getglobal(L, "package");
59 lua_getfield(L, -1, "loaded");
60 lua_pushvalue(L, -3);
61 lua_setfield(L, -2, modname);
62
63 lua_pop(L, 2);
64
65 if (glb) {
66 lua_pushvalue(L, -1);
67 lua_setglobal(L, modname);
68 }
69} /* luaL_requiref() */
70
71
72#define lua_resume(L, from, nargs) lua_resume((L), (nargs))
73
74
75static void lua_rawgetp(lua_State *L, int index, const void *p) {
76 index = lua_absindex(L, index);
77 lua_pushlightuserdata(L, (void *)p);
78 lua_rawget(L, index);
79} /* lua_rawgetp() */
80
81static void lua_rawsetp(lua_State *L, int index, const void *p) {
82 index = lua_absindex(L, index);
83 lua_pushlightuserdata(L, (void *)p);
84 lua_pushvalue(L, -2);
85 lua_rawset(L, index);
86 lua_pop(L, 1);
87} /* lua_rawsetp() */
88
89
90#ifndef LUA_UNSIGNED
91#define LUA_UNSIGNED unsigned
92#endif
93
94typedef LUA_UNSIGNED lua_Unsigned;
95
96
97static void lua_pushunsigned(lua_State *L, lua_Unsigned n) {
98 lua_pushnumber(L, (lua_Number)n);
99} /* lua_pushunsigned() */
100
101static lua_Unsigned luaL_checkunsigned(lua_State *L, int arg) {
102 return (lua_Unsigned)luaL_checknumber(L, arg);
103} /* luaL_checkunsigned() */
104
105
106static lua_Unsigned luaL_optunsigned(lua_State *L, int arg, lua_Unsigned def) {
107 return (lua_Unsigned)luaL_optnumber(L, arg, (lua_Number)def);
108} /* luaL_optunsigned() */
109
110
111/*
112 * Lua 5.1 userdata is a simple FILE *, while LuaJIT is a struct with the
113 * first membe a FILE *, similar to Lua 5.2.
114 */
115typedef struct luaL_Stream {
116 FILE *f;
117} luaL_Stream;
118
50 119
120#endif /* LUA_VERSION_NUM < 502 */