From 42a1a732b79fa6153c61da645b786da883bbd0b5 Mon Sep 17 00:00:00 2001 From: "E. Westbrook" Date: Wed, 27 Feb 2019 21:01:16 -0700 Subject: timeout: pragma visibility --- src/timeout.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'src/timeout.c') diff --git a/src/timeout.c b/src/timeout.c index 8fb8f55..0e3ee27 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -4,10 +4,6 @@ \*=========================================================================*/ #include "luasocket.h" -#include "lua.h" -#include "lauxlib.h" -#include "compat.h" - #include "auxiliar.h" #include "timeout.h" @@ -30,6 +26,10 @@ #define MAX(x, y) ((x) > (y) ? x : y) #endif +#ifndef _WIN32 +#pragma GCC visibility push(hidden) +#endif + /*=========================================================================*\ * Internal function prototypes \*=========================================================================*/ @@ -48,7 +48,7 @@ static luaL_Reg func[] = { /*-------------------------------------------------------------------------*\ * Initialize structure \*-------------------------------------------------------------------------*/ -LUASOCKET_PRIVATE void timeout_init(p_timeout tm, double block, double total) { +void timeout_init(p_timeout tm, double block, double total) { tm->block = block; tm->total = total; } @@ -61,7 +61,7 @@ LUASOCKET_PRIVATE void timeout_init(p_timeout tm, double block, double total) { * Returns * the number of ms left or -1 if there is no time limit \*-------------------------------------------------------------------------*/ -LUASOCKET_PRIVATE double timeout_get(p_timeout tm) { +double timeout_get(p_timeout tm) { if (tm->block < 0.0 && tm->total < 0.0) { return -1; } else if (tm->block < 0.0) { @@ -82,7 +82,7 @@ LUASOCKET_PRIVATE double timeout_get(p_timeout tm) { * Returns * start field of structure \*-------------------------------------------------------------------------*/ -LUASOCKET_PRIVATE double timeout_getstart(p_timeout tm) { +double timeout_getstart(p_timeout tm) { return tm->start; } @@ -94,7 +94,7 @@ LUASOCKET_PRIVATE double timeout_getstart(p_timeout tm) { * Returns * the number of ms left or -1 if there is no time limit \*-------------------------------------------------------------------------*/ -LUASOCKET_PRIVATE double timeout_getretry(p_timeout tm) { +double timeout_getretry(p_timeout tm) { if (tm->block < 0.0 && tm->total < 0.0) { return -1; } else if (tm->block < 0.0) { @@ -114,7 +114,7 @@ LUASOCKET_PRIVATE double timeout_getretry(p_timeout tm) { * Input * tm: timeout control structure \*-------------------------------------------------------------------------*/ -LUASOCKET_PRIVATE p_timeout timeout_markstart(p_timeout tm) { +p_timeout timeout_markstart(p_timeout tm) { tm->start = timeout_gettime(); return tm; } @@ -125,7 +125,7 @@ LUASOCKET_PRIVATE p_timeout timeout_markstart(p_timeout tm) { * time in s. \*-------------------------------------------------------------------------*/ #ifdef _WIN32 -LUASOCKET_PRIVATE double timeout_gettime(void) { +double timeout_gettime(void) { FILETIME ft; double t; GetSystemTimeAsFileTime(&ft); @@ -135,7 +135,7 @@ LUASOCKET_PRIVATE double timeout_gettime(void) { return (t - 11644473600.0); } #else -LUASOCKET_PRIVATE double timeout_gettime(void) { +double timeout_gettime(void) { struct timeval v; gettimeofday(&v, (struct timezone *) NULL); /* Unix Epoch time (time since January 1, 1970 (UTC)) */ @@ -146,7 +146,7 @@ LUASOCKET_PRIVATE double timeout_gettime(void) { /*-------------------------------------------------------------------------*\ * Initializes module \*-------------------------------------------------------------------------*/ -LUASOCKET_PRIVATE int timeout_open(lua_State *L) { +int timeout_open(lua_State *L) { luaL_setfuncs(L, func, 0); return 0; } @@ -157,7 +157,7 @@ LUASOCKET_PRIVATE int timeout_open(lua_State *L) { * time: time out value in seconds * mode: "b" for block timeout, "t" for total timeout. (default: b) \*-------------------------------------------------------------------------*/ -LUASOCKET_PRIVATE int timeout_meth_settimeout(lua_State *L, p_timeout tm) { +int timeout_meth_settimeout(lua_State *L, p_timeout tm) { double t = luaL_optnumber(L, 2, -1); const char *mode = luaL_optstring(L, 3, "b"); switch (*mode) { @@ -179,7 +179,7 @@ LUASOCKET_PRIVATE int timeout_meth_settimeout(lua_State *L, p_timeout tm) { * Gets timeout values for IO operations * Lua Output: block, total \*-------------------------------------------------------------------------*/ -LUASOCKET_PRIVATE int timeout_meth_gettimeout(lua_State *L, p_timeout tm) { +int timeout_meth_gettimeout(lua_State *L, p_timeout tm) { lua_pushnumber(L, tm->block); lua_pushnumber(L, tm->total); return 2; @@ -201,7 +201,7 @@ static int timeout_lua_gettime(lua_State *L) * Sleep for n seconds. \*-------------------------------------------------------------------------*/ #ifdef _WIN32 -LUASOCKET_PRIVATE int timeout_lua_sleep(lua_State *L) +int timeout_lua_sleep(lua_State *L) { double n = luaL_checknumber(L, 1); if (n < 0.0) n = 0.0; @@ -211,7 +211,7 @@ LUASOCKET_PRIVATE int timeout_lua_sleep(lua_State *L) return 0; } #else -LUASOCKET_PRIVATE int timeout_lua_sleep(lua_State *L) +int timeout_lua_sleep(lua_State *L) { double n = luaL_checknumber(L, 1); struct timespec t, r; @@ -228,3 +228,7 @@ LUASOCKET_PRIVATE int timeout_lua_sleep(lua_State *L) return 0; } #endif + +#ifndef _WIN32 +#pragma GCC visibility pop +#endif -- cgit v1.2.3-55-g6feb From 21514304be9e98a4386cb18542582068a59c5586 Mon Sep 17 00:00:00 2001 From: "E. Westbrook" Date: Thu, 28 Feb 2019 16:32:07 -0700 Subject: wrap visibility pragmas in #ifndef _WIN32 --- src/auxiliar.h | 4 ++++ src/buffer.h | 4 ++++ src/compat.h | 4 ++++ src/except.h | 4 ++++ src/inet.h | 4 ++++ src/io.h | 5 ++++- src/options.h | 4 ++++ src/select.h | 4 ++++ src/socket.h | 4 ++++ src/tcp.h | 4 ++++ src/timeout.c | 8 -------- src/timeout.h | 4 ++++ src/udp.h | 4 ++++ src/unixdgram.h | 4 ++++ src/unixstream.h | 4 ++++ src/wsocket.c | 8 -------- 16 files changed, 56 insertions(+), 17 deletions(-) (limited to 'src/timeout.c') diff --git a/src/auxiliar.h b/src/auxiliar.h index 234b00a..e8c3ead 100644 --- a/src/auxiliar.h +++ b/src/auxiliar.h @@ -31,7 +31,9 @@ #include "luasocket.h" +#ifndef _WIN32 #pragma GCC visibility push(hidden) +#endif int auxiliar_open(lua_State *L); void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func); @@ -45,6 +47,8 @@ void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx); void *auxiliar_getclassudata(lua_State *L, const char *groupname, int objidx); int auxiliar_typeerror(lua_State *L, int narg, const char *tname); +#ifndef _WIN32 #pragma GCC visibility pop +#endif #endif /* AUXILIAR_H */ diff --git a/src/buffer.h b/src/buffer.h index 4218ea0..a0901fc 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -33,7 +33,9 @@ typedef struct t_buffer_ { } t_buffer; typedef t_buffer *p_buffer; +#ifndef _WIN32 #pragma GCC visibility push(hidden) +#endif int buffer_open(lua_State *L); void buffer_init(p_buffer buf, p_io io, p_timeout tm); @@ -43,6 +45,8 @@ int buffer_meth_send(lua_State *L, p_buffer buf); int buffer_meth_receive(lua_State *L, p_buffer buf); int buffer_isempty(p_buffer buf); +#ifndef _WIN32 #pragma GCC visibility pop +#endif #endif /* BUF_H */ diff --git a/src/compat.h b/src/compat.h index 8c32b07..fa2d7d7 100644 --- a/src/compat.h +++ b/src/compat.h @@ -3,12 +3,16 @@ #if LUA_VERSION_NUM==501 +#ifndef _WIN32 #pragma GCC visibility push(hidden) +#endif void luasocket_setfuncs (lua_State *L, const luaL_Reg *l, int nup); void *luasocket_testudata ( lua_State *L, int arg, const char *tname); +#ifndef _WIN32 #pragma GCC visibility pop +#endif #define luaL_setfuncs luasocket_setfuncs #define luaL_testudata luasocket_testudata diff --git a/src/except.h b/src/except.h index baa7b09..71c31fd 100644 --- a/src/except.h +++ b/src/except.h @@ -33,10 +33,14 @@ #include "luasocket.h" +#ifndef _WIN32 #pragma GCC visibility push(hidden) +#endif int except_open(lua_State *L); +#ifndef _WIN32 #pragma GCC visibility pop +#endif #endif diff --git a/src/inet.h b/src/inet.h index 2e00e58..5618b61 100644 --- a/src/inet.h +++ b/src/inet.h @@ -22,7 +22,9 @@ #define LUASOCKET_INET_ATON #endif +#ifndef _WIN32 #pragma GCC visibility push(hidden) +#endif int inet_open(lua_State *L); @@ -47,6 +49,8 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt); int inet_pton(int af, const char *src, void *dst); #endif +#ifndef _WIN32 #pragma GCC visibility pop +#endif #endif /* INET_H */ diff --git a/src/io.h b/src/io.h index e08eb0e..b8a54df 100644 --- a/src/io.h +++ b/src/io.h @@ -56,12 +56,15 @@ typedef struct t_io_ { } t_io; typedef t_io *p_io; +#ifndef _WIN32 #pragma GCC visibility push(hidden) +#endif void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx); const char *io_strerror(int err); +#ifndef _WIN32 #pragma GCC visibility pop +#endif #endif /* IO_H */ - diff --git a/src/options.h b/src/options.h index 1457f43..41f7337 100644 --- a/src/options.h +++ b/src/options.h @@ -18,7 +18,9 @@ typedef struct t_opt { } t_opt; typedef t_opt *p_opt; +#ifndef _WIN32 #pragma GCC visibility push(hidden) +#endif int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps); int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps); @@ -93,6 +95,8 @@ int opt_get_ip6_v6only(lua_State *L, p_socket ps); int opt_get_error(lua_State *L, p_socket ps); +#ifndef _WIN32 #pragma GCC visibility pop +#endif #endif diff --git a/src/select.h b/src/select.h index 95272db..5d45fe7 100644 --- a/src/select.h +++ b/src/select.h @@ -10,10 +10,14 @@ * true if there is data ready for reading (required for buffered input). \*=========================================================================*/ +#ifndef _WIN32 #pragma GCC visibility push(hidden) +#endif int select_open(lua_State *L); +#ifndef _WIN32 #pragma GCC visibility pop +#endif #endif /* SELECT_H */ diff --git a/src/socket.h b/src/socket.h index 4adc562..e541f27 100644 --- a/src/socket.h +++ b/src/socket.h @@ -36,7 +36,9 @@ typedef struct sockaddr SA; * interface to sockets \*=========================================================================*/ +#ifndef _WIN32 #pragma GCC visibility push(hidden) +#endif int socket_waitfd(p_socket ps, int sw, p_timeout tm); int socket_open(void); @@ -64,6 +66,8 @@ const char *socket_strerror(int err); const char *socket_ioerror(p_socket ps, int err); const char *socket_gaistrerror(int err); +#ifndef _WIN32 #pragma GCC visibility pop +#endif #endif /* SOCKET_H */ diff --git a/src/tcp.h b/src/tcp.h index 9b12b53..9b282ef 100644 --- a/src/tcp.h +++ b/src/tcp.h @@ -30,10 +30,14 @@ typedef struct t_tcp_ { typedef t_tcp *p_tcp; +#ifndef _WIN32 #pragma GCC visibility push(hidden) +#endif int tcp_open(lua_State *L); +#ifndef _WIN32 #pragma GCC visibility pop +#endif #endif /* TCP_H */ diff --git a/src/timeout.c b/src/timeout.c index 0e3ee27..2bdc069 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -26,10 +26,6 @@ #define MAX(x, y) ((x) > (y) ? x : y) #endif -#ifndef _WIN32 -#pragma GCC visibility push(hidden) -#endif - /*=========================================================================*\ * Internal function prototypes \*=========================================================================*/ @@ -228,7 +224,3 @@ int timeout_lua_sleep(lua_State *L) return 0; } #endif - -#ifndef _WIN32 -#pragma GCC visibility pop -#endif diff --git a/src/timeout.h b/src/timeout.h index df05eaf..9e5250d 100644 --- a/src/timeout.h +++ b/src/timeout.h @@ -14,7 +14,9 @@ typedef struct t_timeout_ { } t_timeout; typedef t_timeout *p_timeout; +#ifndef _WIN32 #pragma GCC visibility push(hidden) +#endif void timeout_init(p_timeout tm, double block, double total); double timeout_get(p_timeout tm); @@ -29,7 +31,9 @@ int timeout_open(lua_State *L); int timeout_meth_settimeout(lua_State *L, p_timeout tm); int timeout_meth_gettimeout(lua_State *L, p_timeout tm); +#ifndef _WIN32 #pragma GCC visibility pop +#endif #define timeout_iszero(tm) ((tm)->block == 0.0) diff --git a/src/udp.h b/src/udp.h index 9e80ccd..07d5247 100644 --- a/src/udp.h +++ b/src/udp.h @@ -26,10 +26,14 @@ typedef struct t_udp_ { } t_udp; typedef t_udp *p_udp; +#ifndef _WIN32 #pragma GCC visibility push(hidden) +#endif int udp_open(lua_State *L); +#ifndef _WIN32 #pragma GCC visibility pop +#endif #endif /* UDP_H */ diff --git a/src/unixdgram.h b/src/unixdgram.h index 433fe25..a1a0166 100644 --- a/src/unixdgram.h +++ b/src/unixdgram.h @@ -15,10 +15,14 @@ #include "unix.h" +#ifndef _WIN32 #pragma GCC visibility push(hidden) +#endif int unixdgram_open(lua_State *L); +#ifndef _WIN32 #pragma GCC visibility pop +#endif #endif /* UNIXDGRAM_H */ diff --git a/src/unixstream.h b/src/unixstream.h index 8ffba8f..7916aff 100644 --- a/src/unixstream.h +++ b/src/unixstream.h @@ -16,10 +16,14 @@ \*=========================================================================*/ #include "unix.h" +#ifndef _WIN32 #pragma GCC visibility push(hidden) +#endif int unixstream_open(lua_State *L); +#ifndef _WIN32 #pragma GCC visibility pop +#endif #endif /* UNIXSTREAM_H */ diff --git a/src/wsocket.c b/src/wsocket.c index 1da984c..20da330 100755 --- a/src/wsocket.c +++ b/src/wsocket.c @@ -12,10 +12,6 @@ #include "socket.h" #include "pierror.h" -#ifndef _WIN32 -#pragma GCC visibility push(hidden) -#endif - /* WinSock doesn't have a strerror... */ static const char *wstrerror(int err); @@ -436,7 +432,3 @@ const char *socket_gaistrerror(int err) { default: return gai_strerror(err); } } - -#ifndef _WIN32 -#pragma GCC visibility pop -#endif -- cgit v1.2.3-55-g6feb