From 42a1a732b79fa6153c61da645b786da883bbd0b5 Mon Sep 17 00:00:00 2001 From: "E. Westbrook" Date: Wed, 27 Feb 2019 21:01:16 -0700 Subject: [PATCH] timeout: pragma visibility --- src/timeout.c | 36 ++++++++++++++++++++---------------- src/timeout.h | 13 ++++++++++--- 2 files changed, 30 insertions(+), 19 deletions(-) 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 diff --git a/src/timeout.h b/src/timeout.h index af90231..df05eaf 100644 --- a/src/timeout.h +++ b/src/timeout.h @@ -4,7 +4,7 @@ * Timeout management functions * LuaSocket toolkit \*=========================================================================*/ -#include "lua.h" +#include "luasocket.h" /* timeout control structure */ typedef struct t_timeout_ { @@ -14,16 +14,23 @@ typedef struct t_timeout_ { } t_timeout; typedef t_timeout *p_timeout; -int timeout_open(lua_State *L); +#pragma GCC visibility push(hidden) + void timeout_init(p_timeout tm, double block, double total); double timeout_get(p_timeout tm); +double timeout_getstart(p_timeout tm); double timeout_getretry(p_timeout tm); p_timeout timeout_markstart(p_timeout tm); -double timeout_getstart(p_timeout tm); + double timeout_gettime(void); + +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); +#pragma GCC visibility pop + #define timeout_iszero(tm) ((tm)->block == 0.0) #endif /* TIMEOUT_H */