diff options
| author | daurnimator <quae@daurnimator.com> | 2017-08-26 22:00:08 +1000 |
|---|---|---|
| committer | daurnimator <quae@daurnimator.com> | 2017-08-30 23:34:48 +1000 |
| commit | 71c54169bb96543a50f90767d351702f63fa0220 (patch) | |
| tree | 426b26a2a73747e457c1947d143b6dc55d4fe0e0 | |
| parent | b8e3766294b6bf11d70a8a202e633b2569675e77 (diff) | |
| download | luaossl-71c54169bb96543a50f90767d351702f63fa0220.tar.gz luaossl-71c54169bb96543a50f90767d351702f63fa0220.tar.bz2 luaossl-71c54169bb96543a50f90767d351702f63fa0220.zip | |
Move over to using lua-compat-5.3
| -rw-r--r-- | src/GNUmakefile | 6 | ||||
| -rw-r--r-- | src/compat52.h | 178 | ||||
| -rw-r--r-- | src/openssl.c | 2 |
3 files changed, 4 insertions, 182 deletions
diff --git a/src/GNUmakefile b/src/GNUmakefile index 4bf5f8d..e257ba6 100644 --- a/src/GNUmakefile +++ b/src/GNUmakefile | |||
| @@ -16,7 +16,7 @@ include $(d)/../GNUmakefile | |||
| 16 | # | 16 | # |
| 17 | # C O M P I L A T I O N F L A G S | 17 | # C O M P I L A T I O N F L A G S |
| 18 | # | 18 | # |
| 19 | CPPFLAGS_$(d) = $(ALL_CPPFLAGS) -DHAVE_CONFIG_H | 19 | CPPFLAGS_$(d) = $(ALL_CPPFLAGS) -DHAVE_CONFIG_H -DCOMPAT53_PREFIX=luaossl |
| 20 | CFLAGS_$(d) = $(ALL_CFLAGS) | 20 | CFLAGS_$(d) = $(ALL_CFLAGS) |
| 21 | SOFLAGS_$(d) = $(ALL_SOFLAGS) | 21 | SOFLAGS_$(d) = $(ALL_SOFLAGS) |
| 22 | LDFLAGS_$(d) = $(ALL_LDFLAGS) | 22 | LDFLAGS_$(d) = $(ALL_LDFLAGS) |
| @@ -25,7 +25,7 @@ LIBS_$(d) = $(ALL_LIBS) | |||
| 25 | # | 25 | # |
| 26 | # C O M P I L A T I O N R U L E S | 26 | # C O M P I L A T I O N R U L E S |
| 27 | # | 27 | # |
| 28 | OBJS_$(d) = openssl.o | 28 | OBJS_$(d) = openssl.o ../vendor/compat53/c-api/compat-5.3.o |
| 29 | 29 | ||
| 30 | $(d)/config.h: $(abspath $(d)/..)/config.h | 30 | $(d)/config.h: $(abspath $(d)/..)/config.h |
| 31 | $(CP) $< $@ | 31 | $(CP) $< $@ |
| @@ -35,7 +35,7 @@ define BUILD_$(d) | |||
| 35 | $$(d)/$(1)/openssl.so: $$(addprefix $$(d)/$(1)/, $$(OBJS_$(d))) | 35 | $$(d)/$(1)/openssl.so: $$(addprefix $$(d)/$(1)/, $$(OBJS_$(d))) |
| 36 | $$(CC) -o $$@ $$^ $$(SOFLAGS_$$(abspath $$(@D)/..)) $$(LDFLAGS_$$(abspath $$(@D)/..)) $$(LIBS_$$(abspath $$(@D)/..)) | 36 | $$(CC) -o $$@ $$^ $$(SOFLAGS_$$(abspath $$(@D)/..)) $$(LDFLAGS_$$(abspath $$(@D)/..)) $$(LIBS_$$(abspath $$(@D)/..)) |
| 37 | 37 | ||
| 38 | $$(d)/$(1)/%.o: $$(d)/%.c $$(d)/compat52.h $$(d)/config.h | 38 | $$(d)/$(1)/%.o: $$(d)/%.c $$(d)/../vendor/compat53/c-api/compat-5.3.h $$(d)/config.h |
| 39 | $$(MKDIR) -p $$(@D) | 39 | $$(MKDIR) -p $$(@D) |
| 40 | $$(CC) $$(CFLAGS_$$(<D)) $$(ALL_LUA$(subst .,,$(1))_CPPFLAGS) $$(CPPFLAGS_$$(<D)) -c -o $$@ $$< | 40 | $$(CC) $$(CFLAGS_$$(<D)) $$(ALL_LUA$(subst .,,$(1))_CPPFLAGS) $$(CPPFLAGS_$$(<D)) -c -o $$@ $$< |
| 41 | 41 | ||
diff --git a/src/compat52.h b/src/compat52.h deleted file mode 100644 index 9b0a48e..0000000 --- a/src/compat52.h +++ /dev/null | |||
| @@ -1,178 +0,0 @@ | |||
| 1 | /* ========================================================================== | ||
| 2 | * compat52.h - Routines for Lua 5.2 compatibility | ||
| 3 | * -------------------------------------------------------------------------- | ||
| 4 | * Copyright (c) 2012 William Ahern | ||
| 5 | * | ||
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
| 7 | * copy of this software and associated documentation files (the | ||
| 8 | * "Software"), to deal in the Software without restriction, including | ||
| 9 | * without limitation the rights to use, copy, modify, merge, publish, | ||
| 10 | * distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 11 | * persons to whom the Software is furnished to do so, subject to the | ||
| 12 | * following conditions: | ||
| 13 | * | ||
| 14 | * The above copyright notice and this permission notice shall be included | ||
| 15 | * in all copies or substantial portions of the Software. | ||
| 16 | * | ||
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
| 18 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 20 | * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 21 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 22 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 23 | * USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 24 | * ========================================================================== | ||
| 25 | */ | ||
| 26 | |||
| 27 | |||
| 28 | #if LUA_VERSION_NUM < 503 | ||
| 29 | |||
| 30 | #define lua_getfield(L, i, f) (lua_getfield(L, (i), (f)), lua_type(L, -1)) | ||
| 31 | |||
| 32 | static int lua_isinteger(lua_State *L, int index) { | ||
| 33 | if (lua_type(L, index) == LUA_TNUMBER) { | ||
| 34 | lua_Number n = lua_tonumber(L, index); | ||
| 35 | lua_Integer i = lua_tointeger(L, index); | ||
| 36 | if (i == n) | ||
| 37 | return 1; | ||
| 38 | } | ||
| 39 | return 0; | ||
| 40 | } | ||
| 41 | |||
| 42 | #endif | ||
| 43 | |||
| 44 | #if LUA_VERSION_NUM < 502 | ||
| 45 | |||
| 46 | #define LUA_OK 0 | ||
| 47 | |||
| 48 | |||
| 49 | static void luaL_setmetatable(lua_State *L, const char *tname) { | ||
| 50 | luaL_getmetatable(L, tname); | ||
| 51 | lua_setmetatable(L, -2); | ||
| 52 | } /* luaL_setmetatable() */ | ||
| 53 | |||
| 54 | |||
| 55 | static int lua_absindex(lua_State *L, int idx) { | ||
| 56 | return (idx > 0 || idx <= LUA_REGISTRYINDEX)? idx : lua_gettop(L) + idx + 1; | ||
| 57 | } /* lua_absindex() */ | ||
| 58 | |||
| 59 | |||
| 60 | static void *luaL_testudata(lua_State *L, int arg, const char *tname) { | ||
| 61 | void *p = lua_touserdata(L, arg); | ||
| 62 | int eq; | ||
| 63 | |||
| 64 | if (!p || !lua_getmetatable(L, arg)) | ||
| 65 | return 0; | ||
| 66 | |||
| 67 | luaL_getmetatable(L, tname); | ||
| 68 | eq = lua_rawequal(L, -2, -1); | ||
| 69 | lua_pop(L, 2); | ||
| 70 | |||
| 71 | return (eq)? p : 0; | ||
| 72 | } /* luaL_testudate() */ | ||
| 73 | |||
| 74 | |||
| 75 | static void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup) { | ||
| 76 | int i, t = lua_absindex(L, -1 - nup); | ||
| 77 | |||
| 78 | for (; l->name; l++) { | ||
| 79 | for (i = 0; i < nup; i++) | ||
| 80 | lua_pushvalue(L, -nup); | ||
| 81 | lua_pushcclosure(L, l->func, nup); | ||
| 82 | lua_setfield(L, t, l->name); | ||
| 83 | } | ||
| 84 | |||
| 85 | lua_pop(L, nup); | ||
| 86 | } /* luaL_setfuncs() */ | ||
| 87 | |||
| 88 | |||
| 89 | #define luaL_newlibtable(L, l) \ | ||
| 90 | lua_createtable(L, 0, (sizeof (l) / sizeof *(l)) - 1) | ||
| 91 | |||
| 92 | #define luaL_newlib(L, l) \ | ||
| 93 | (luaL_newlibtable((L), (l)), luaL_setfuncs((L), (l), 0)) | ||
| 94 | |||
| 95 | |||
| 96 | static void luaL_requiref(lua_State *L, const char *modname, lua_CFunction openf, int glb) { | ||
| 97 | lua_pushcfunction(L, openf); | ||
| 98 | lua_pushstring(L, modname); | ||
| 99 | lua_call(L, 1, 1); | ||
| 100 | |||
| 101 | lua_getglobal(L, "package"); | ||
| 102 | lua_getfield(L, -1, "loaded"); | ||
| 103 | lua_pushvalue(L, -3); | ||
| 104 | lua_setfield(L, -2, modname); | ||
| 105 | |||
| 106 | lua_pop(L, 2); | ||
| 107 | |||
| 108 | if (glb) { | ||
| 109 | lua_pushvalue(L, -1); | ||
| 110 | lua_setglobal(L, modname); | ||
| 111 | } | ||
| 112 | } /* luaL_requiref() */ | ||
| 113 | |||
| 114 | |||
| 115 | #define lua_resume(L, from, nargs) lua_resume((L), (nargs)) | ||
| 116 | |||
| 117 | |||
| 118 | static void lua_rawgetp(lua_State *L, int index, const void *p) { | ||
| 119 | index = lua_absindex(L, index); | ||
| 120 | lua_pushlightuserdata(L, (void *)p); | ||
| 121 | lua_rawget(L, index); | ||
| 122 | } /* lua_rawgetp() */ | ||
| 123 | |||
| 124 | static void lua_rawsetp(lua_State *L, int index, const void *p) { | ||
| 125 | index = lua_absindex(L, index); | ||
| 126 | lua_pushlightuserdata(L, (void *)p); | ||
| 127 | lua_pushvalue(L, -2); | ||
| 128 | lua_rawset(L, index); | ||
| 129 | lua_pop(L, 1); | ||
| 130 | } /* lua_rawsetp() */ | ||
| 131 | |||
| 132 | |||
| 133 | #ifndef LUA_UNSIGNED | ||
| 134 | #define LUA_UNSIGNED unsigned | ||
| 135 | #endif | ||
| 136 | |||
| 137 | typedef LUA_UNSIGNED lua_Unsigned; | ||
| 138 | |||
| 139 | |||
| 140 | static void lua_pushunsigned(lua_State *L, lua_Unsigned n) { | ||
| 141 | lua_pushnumber(L, (lua_Number)n); | ||
| 142 | } /* lua_pushunsigned() */ | ||
| 143 | |||
| 144 | static lua_Unsigned luaL_checkunsigned(lua_State *L, int arg) { | ||
| 145 | return (lua_Unsigned)luaL_checknumber(L, arg); | ||
| 146 | } /* luaL_checkunsigned() */ | ||
| 147 | |||
| 148 | |||
| 149 | static lua_Unsigned luaL_optunsigned(lua_State *L, int arg, lua_Unsigned def) { | ||
| 150 | return (lua_Unsigned)luaL_optnumber(L, arg, (lua_Number)def); | ||
| 151 | } /* luaL_optunsigned() */ | ||
| 152 | |||
| 153 | |||
| 154 | #ifndef LUA_FILEHANDLE /* Not defined by earlier LuaJIT releases */ | ||
| 155 | #define LUA_FILEHANDLE "FILE*" | ||
| 156 | #endif | ||
| 157 | |||
| 158 | /* | ||
| 159 | * Lua 5.1 userdata is a simple FILE *, while LuaJIT is a struct with the | ||
| 160 | * first member a FILE *, similar to Lua 5.2. | ||
| 161 | */ | ||
| 162 | typedef struct luaL_Stream { | ||
| 163 | FILE *f; | ||
| 164 | } luaL_Stream; | ||
| 165 | |||
| 166 | |||
| 167 | #define lua_rawlen(...) lua_objlen(__VA_ARGS__) | ||
| 168 | |||
| 169 | |||
| 170 | #define lua_pushstring(...) lua52_pushstring(__VA_ARGS__) | ||
| 171 | |||
| 172 | static const char *lua52_pushstring(lua_State *L, const char *s) { | ||
| 173 | (lua_pushstring)(L, s); | ||
| 174 | return lua_tostring(L, -1); | ||
| 175 | } /* lua52_pushstring() */ | ||
| 176 | |||
| 177 | |||
| 178 | #endif /* LUA_VERSION_NUM < 502 */ | ||
diff --git a/src/openssl.c b/src/openssl.c index 50ce7d3..ac053fd 100644 --- a/src/openssl.c +++ b/src/openssl.c | |||
| @@ -75,7 +75,7 @@ | |||
| 75 | #include <lualib.h> | 75 | #include <lualib.h> |
| 76 | #include <lauxlib.h> | 76 | #include <lauxlib.h> |
| 77 | 77 | ||
| 78 | #include "compat52.h" | 78 | #include "../vendor/compat53/c-api/compat-5.3.h" |
| 79 | 79 | ||
| 80 | #define GNUC_2VER(M, m, p) (((M) * 10000) + ((m) * 100) + (p)) | 80 | #define GNUC_2VER(M, m, p) (((M) * 10000) + ((m) * 100) + (p)) |
| 81 | #define GNUC_PREREQ(M, m, p) (__GNUC__ > 0 && GNUC_2VER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) >= GNUC_2VER((M), (m), (p))) | 81 | #define GNUC_PREREQ(M, m, p) (__GNUC__ > 0 && GNUC_2VER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) >= GNUC_2VER((M), (m), (p))) |
