Merge pull request #3676 from Tarnyko/master

luci-lib-nixio: allow building with Lua5.2/LuaJIT
This commit is contained in:
Jo-Philipp Wich 2020-06-16 17:27:01 +02:00 committed by GitHub
commit d1134c1a40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 30 additions and 26 deletions

View file

@ -544,7 +544,7 @@ static int nixio_getifaddrs(lua_State *L) {
/* module table */ /* module table */
static const luaL_reg R[] = { static const luaL_Reg R[] = {
#if defined(__linux__) || defined(BSD) #if defined(__linux__) || defined(BSD)
{"getifaddrs", nixio_getifaddrs}, {"getifaddrs", nixio_getifaddrs},
#endif #endif
@ -554,7 +554,7 @@ static const luaL_reg R[] = {
}; };
/* object table */ /* object table */
static const luaL_reg M[] = { static const luaL_Reg M[] = {
{"getsockname", nixio_sock_getsockname}, {"getsockname", nixio_sock_getsockname},
{"getpeername", nixio_sock_getpeername}, {"getpeername", nixio_sock_getpeername},
{NULL, NULL} {NULL, NULL}

View file

@ -296,7 +296,7 @@ static int nixio_bin_b64decode(lua_State *L) {
} }
/* module table */ /* module table */
static const luaL_reg R[] = { static const luaL_Reg R[] = {
{"hexlify", nixio_bin_hexlify}, {"hexlify", nixio_bin_hexlify},
{"unhexlify", nixio_bin_unhexlify}, {"unhexlify", nixio_bin_unhexlify},
{"crc32", nixio_bin_crc32}, {"crc32", nixio_bin_crc32},

View file

@ -269,14 +269,14 @@ static int nixio_sock_accept(lua_State *L) {
} }
/* module table */ /* module table */
static const luaL_reg R[] = { static const luaL_Reg R[] = {
{"bind", nixio_bind}, {"bind", nixio_bind},
{"connect", nixio_connect}, {"connect", nixio_connect},
{NULL, NULL} {NULL, NULL}
}; };
/* object table */ /* object table */
static const luaL_reg M[] = { static const luaL_Reg M[] = {
{"bind", nixio_sock_bind}, {"bind", nixio_sock_bind},
{"connect", nixio_sock_connect}, {"connect", nixio_sock_connect},
{"listen", nixio_sock_listen}, {"listen", nixio_sock_listen},

View file

@ -120,7 +120,7 @@ static int nixio_bit_swap(lua_State *L) {
} }
/* module table */ /* module table */
static const luaL_reg R[] = { static const luaL_Reg R[] = {
{"bor", nixio_bit_or}, {"bor", nixio_bit_or},
{"set", nixio_bit_or}, {"set", nixio_bit_or},
{"band", nixio_bit_and}, {"band", nixio_bit_and},

View file

@ -379,7 +379,7 @@ static int nixio_file__tostring(lua_State *L) {
} }
/* method table */ /* method table */
static const luaL_reg M[] = { static const luaL_Reg M[] = {
{"write", nixio_file_write}, {"write", nixio_file_write},
{"read", nixio_file_read}, {"read", nixio_file_read},
{"tell", nixio_file_tell}, {"tell", nixio_file_tell},
@ -394,7 +394,7 @@ static const luaL_reg M[] = {
}; };
/* module table */ /* module table */
static const luaL_reg R[] = { static const luaL_Reg R[] = {
{"dup", nixio_dup}, {"dup", nixio_dup},
{"open", nixio_open}, {"open", nixio_open},
{"open_flags", nixio_open_flags}, {"open_flags", nixio_open_flags},

View file

@ -519,7 +519,7 @@ static int nixio_statvfs(lua_State *L) {
/* module table */ /* module table */
static const luaL_reg R[] = { static const luaL_Reg R[] = {
#ifndef __WINNT__ #ifndef __WINNT__
{"glob", nixio_glob}, {"glob", nixio_glob},
{"mkfifo", nixio_mkfifo}, {"mkfifo", nixio_mkfifo},

View file

@ -208,7 +208,7 @@ static int nixio_sock_recvfrom(lua_State *L) {
/* module table */ /* module table */
static const luaL_reg M[] = { static const luaL_Reg M[] = {
{"send", nixio_sock_send}, {"send", nixio_sock_send},
{"sendto", nixio_sock_sendto}, {"sendto", nixio_sock_sendto},
{"recv", nixio_sock_recv}, {"recv", nixio_sock_recv},

View file

@ -102,7 +102,7 @@ static int nixio_strerror(lua_State *L) {
} }
/* object table */ /* object table */
static const luaL_reg R[] = { static const luaL_Reg R[] = {
{"errno", nixio_errno}, {"errno", nixio_errno},
{"strerror", nixio_strerror}, {"strerror", nixio_strerror},
{NULL, NULL} {NULL, NULL}

View file

@ -21,6 +21,10 @@
#include <lauxlib.h> #include <lauxlib.h>
#include <luaconf.h> #include <luaconf.h>
#if LUA_VERSION_NUM < 501
#define luaL_Reg luaL_reg
#endif
#define NIXIO_BUFFERSIZE 8192 #define NIXIO_BUFFERSIZE 8192
typedef struct nixio_socket { typedef struct nixio_socket {

View file

@ -197,7 +197,7 @@ static int nixio_poll(lua_State *L) {
} }
/* module table */ /* module table */
static const luaL_reg R[] = { static const luaL_Reg R[] = {
{"gettimeofday", nixio_gettimeofday}, {"gettimeofday", nixio_gettimeofday},
{"nanosleep", nixio_nanosleep}, {"nanosleep", nixio_nanosleep},
{"poll", nixio_poll}, {"poll", nixio_poll},

View file

@ -412,7 +412,7 @@ static int nixio_sysinfo(lua_State *L) {
/* module table */ /* module table */
static const luaL_reg R[] = { static const luaL_Reg R[] = {
#ifdef __linux__ #ifdef __linux__
{"sysinfo", nixio_sysinfo}, {"sysinfo", nixio_sysinfo},
#endif #endif

View file

@ -91,7 +91,7 @@ static int nixio_getproto(lua_State *L) {
} }
/* module table */ /* module table */
static const luaL_reg R[] = { static const luaL_Reg R[] = {
{"getprotobyname", nixio_getprotobyname}, {"getprotobyname", nixio_getprotobyname},
{"getprotobynumber", nixio_getprotobynumber}, {"getprotobynumber", nixio_getprotobynumber},
{"getproto", nixio_getproto}, {"getproto", nixio_getproto},

View file

@ -150,13 +150,13 @@ static int nixio_sock_shutdown(lua_State *L) {
} }
/* module table */ /* module table */
static const luaL_reg R[] = { static const luaL_Reg R[] = {
{"socket", nixio_socket}, {"socket", nixio_socket},
{NULL, NULL} {NULL, NULL}
}; };
/* object table */ /* object table */
static const luaL_reg M[] = { static const luaL_Reg M[] = {
{"close", nixio_sock_close}, {"close", nixio_sock_close},
{"shutdown", nixio_sock_shutdown}, {"shutdown", nixio_sock_shutdown},
{"__gc", nixio_sock__gc}, {"__gc", nixio_sock__gc},

View file

@ -366,7 +366,7 @@ static int nixio_sock_setsockopt(lua_State *L) {
} }
/* module table */ /* module table */
static const luaL_reg M[] = { static const luaL_Reg M[] = {
{"setblocking", nixio_sock_setblocking}, {"setblocking", nixio_sock_setblocking},
{"getsockopt", nixio_sock_getsockopt}, {"getsockopt", nixio_sock_getsockopt},
{"setsockopt", nixio_sock_setsockopt}, {"setsockopt", nixio_sock_setsockopt},

View file

@ -161,7 +161,7 @@ static int nixio_sendfile(lua_State *L) {
} }
/* module table */ /* module table */
static const luaL_reg R[] = { static const luaL_Reg R[] = {
#ifdef _GNU_SOURCE #ifdef _GNU_SOURCE
#ifdef SPLICE_F_MOVE #ifdef SPLICE_F_MOVE
{"splice", nixio_splice}, {"splice", nixio_splice},

View file

@ -102,7 +102,7 @@ static int nixio_syslog(lua_State *L) {
} }
/* module table */ /* module table */
static const luaL_reg R[] = { static const luaL_Reg R[] = {
{"openlog", nixio_openlog}, {"openlog", nixio_openlog},
{"syslog", nixio_syslog}, {"syslog", nixio_syslog},
{"setlogmask", nixio_setlogmask}, {"setlogmask", nixio_setlogmask},

View file

@ -203,13 +203,13 @@ static int nixio_tls_ctx__tostring(lua_State *L) {
} }
/* module table */ /* module table */
static const luaL_reg R[] = { static const luaL_Reg R[] = {
{"tls", nixio_tls_ctx}, {"tls", nixio_tls_ctx},
{NULL, NULL} {NULL, NULL}
}; };
/* ctx function table */ /* ctx function table */
static const luaL_reg CTX_M[] = { static const luaL_Reg CTX_M[] = {
{"set_cert", nixio_tls_ctx_set_cert}, {"set_cert", nixio_tls_ctx_set_cert},
{"set_verify_locations", nixio_tls_ctx_set_verify_locations}, {"set_verify_locations", nixio_tls_ctx_set_verify_locations},
{"set_key", nixio_tls_ctx_set_key}, {"set_key", nixio_tls_ctx_set_key},

View file

@ -154,14 +154,14 @@ static int nixio_crypto_hash__tostring(lua_State *L) {
/* module table */ /* module table */
static const luaL_reg R[] = { static const luaL_Reg R[] = {
{"hash", nixio_crypto_hash}, {"hash", nixio_crypto_hash},
{"hmac", nixio_crypto_hmac}, {"hmac", nixio_crypto_hmac},
{NULL, NULL} {NULL, NULL}
}; };
/* hash table */ /* hash table */
static const luaL_reg M[] = { static const luaL_Reg M[] = {
{"update", nixio_crypto_hash_update}, {"update", nixio_crypto_hash_update},
{"final", nixio_crypto_hash_final}, {"final", nixio_crypto_hash_final},
{"__gc", nixio_crypto_hash__gc}, {"__gc", nixio_crypto_hash__gc},

View file

@ -239,7 +239,7 @@ static int nixio_tls_sock__tostring(lua_State *L) {
/* ctx function table */ /* ctx function table */
static const luaL_reg M[] = { static const luaL_Reg M[] = {
{"recv", nixio_tls_sock_recv}, {"recv", nixio_tls_sock_recv},
{"send", nixio_tls_sock_send}, {"send", nixio_tls_sock_send},
{"read", nixio_tls_sock_recv}, {"read", nixio_tls_sock_recv},

View file

@ -238,7 +238,7 @@ static int nixio_crypt(lua_State *L) {
/* module table */ /* module table */
static const luaL_reg R[] = { static const luaL_Reg R[] = {
{"crypt", nixio_crypt}, {"crypt", nixio_crypt},
{"getgr", nixio_getgr}, {"getgr", nixio_getgr},
{"getpw", nixio_getpw}, {"getpw", nixio_getpw},
@ -252,7 +252,7 @@ static const luaL_reg R[] = {
#else /* __WINNT__ */ #else /* __WINNT__ */
static const luaL_reg R[] = { static const luaL_Reg R[] = {
{NULL, NULL} {NULL, NULL}
}; };