diff options
author | William Ahern <william@Williams-MacBook-Air.local> | 2012-10-10 16:46:28 -0700 |
---|---|---|
committer | William Ahern <william@Williams-MacBook-Air.local> | 2012-10-10 16:46:28 -0700 |
commit | 7bdf2557bbf7267542604567a0db809657b54d97 (patch) | |
tree | 13ba523c6f40b70536bc4ca8c4cc661948f831a8 | |
parent | ac93581c90d8a1612ce01e3a308d572f98002924 (diff) | |
download | luaossl-7bdf2557bbf7267542604567a0db809657b54d97.tar.gz luaossl-7bdf2557bbf7267542604567a0db809657b54d97.tar.bz2 luaossl-7bdf2557bbf7267542604567a0db809657b54d97.zip |
-n
fix compile for LuaJIT
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | compat52.h | 50 | ||||
-rw-r--r-- | openssl.c | 7 |
3 files changed, 58 insertions, 1 deletions
@@ -40,7 +40,7 @@ all: openssl.so openssl.so: openssl.o $(CC) -o $@ $^ $(SOFLAGS) $(LDFLAGS) -openssl.o: openssl.c +openssl.o: openssl.c compat52.h $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< diff --git a/compat52.h b/compat52.h new file mode 100644 index 0000000..c674f13 --- /dev/null +++ b/compat52.h @@ -0,0 +1,50 @@ + + +static void luaL_setmetatable(lua_State *L, const char *tname) { + luaL_getmetatable(L, tname); + lua_setmetatable(L, -2); +} /* luaL_setmetatable() */ + + +static int lua_absindex(lua_State *L, int idx) { + return (idx > 0 || idx <= LUA_REGISTRYINDEX)? idx : lua_gettop(L) + idx + 1; +} /* lua_absindex() */ + + +static void *luaL_testudata(lua_State *L, int arg, const char *tname) { + void *p = lua_touserdata(L, arg); + int eq; + + if (!p || !lua_getmetatable(L, arg)) + return 0; + + luaL_getmetatable(L, tname); + eq = lua_rawequal(L, -2, -1); + lua_pop(L, 2); + + return (eq)? p : 0; +} /* luaL_testudate() */ + + +static void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup) { + int i, t = lua_absindex(L, -1 - nup); + + for (; l->name; l++) { + for (i = 0; i < nup; i++) + lua_pushvalue(L, -nup); + lua_pushcclosure(L, l->func, nup); + lua_setfield(L, t, l->name); + } + + return lua_pop(L, nup); +} /* luaL_setfuncs() */ + + +#define luaL_newlibtable(L, l) \ + lua_createtable(L, 0, (sizeof (l) / sizeof *(l)) - 1) + +#define luaL_newlib(L, l) \ + (luaL_newlibtable((L), (l)), luaL_setfuncs((L), (l), 0)) + + + @@ -52,6 +52,9 @@ #include <lualib.h> #include <lauxlib.h> +#if LUA_VERSION_NUM < 502 +#include "compat52.h" +#endif #define BIGNUM_CLASS "OpenSSL Bignum" #define PUBKEY_CLASS "OpenSSL Pubkey" @@ -1665,7 +1668,11 @@ static int xc_digest(lua_State *L) { luaL_Buffer B; unsigned i; +#if LUA_VERSION_NUM < 502 + luaL_buffinit(L, &B); +#else luaL_buffinitsize(L, &B, 2 * len); +#endif for (i = 0; i < len; i++) { luaL_addchar(&B, x[0x0f & (md[i] >> 4)]); |