buffer: pragma visibility

This commit is contained in:
E. Westbrook 2019-02-27 20:56:01 -07:00
parent 98800e9129
commit e3ac49efbd
2 changed files with 14 additions and 16 deletions

View File

@ -3,11 +3,6 @@
* LuaSocket toolkit * LuaSocket toolkit
\*=========================================================================*/ \*=========================================================================*/
#include "luasocket.h" #include "luasocket.h"
#include "lua.h"
#include "lauxlib.h"
#include "compat.h"
#include "buffer.h" #include "buffer.h"
/*=========================================================================*\ /*=========================================================================*\
@ -34,7 +29,7 @@ static int sendraw(p_buffer buf, const char *data, size_t count, size_t *sent);
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
* Initializes module * Initializes module
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
LUASOCKET_PRIVATE int buffer_open(lua_State *L) { int buffer_open(lua_State *L) {
(void) L; (void) L;
return 0; return 0;
} }
@ -42,7 +37,7 @@ LUASOCKET_PRIVATE int buffer_open(lua_State *L) {
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
* Initializes C structure * Initializes C structure
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
LUASOCKET_PRIVATE void buffer_init(p_buffer buf, p_io io, p_timeout tm) { void buffer_init(p_buffer buf, p_io io, p_timeout tm) {
buf->first = buf->last = 0; buf->first = buf->last = 0;
buf->io = io; buf->io = io;
buf->tm = tm; buf->tm = tm;
@ -53,7 +48,7 @@ LUASOCKET_PRIVATE void buffer_init(p_buffer buf, p_io io, p_timeout tm) {
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
* object:getstats() interface * object:getstats() interface
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
LUASOCKET_PRIVATE int buffer_meth_getstats(lua_State *L, p_buffer buf) { int buffer_meth_getstats(lua_State *L, p_buffer buf) {
lua_pushnumber(L, (lua_Number) buf->received); lua_pushnumber(L, (lua_Number) buf->received);
lua_pushnumber(L, (lua_Number) buf->sent); lua_pushnumber(L, (lua_Number) buf->sent);
lua_pushnumber(L, timeout_gettime() - buf->birthday); lua_pushnumber(L, timeout_gettime() - buf->birthday);
@ -63,7 +58,7 @@ LUASOCKET_PRIVATE int buffer_meth_getstats(lua_State *L, p_buffer buf) {
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
* object:setstats() interface * object:setstats() interface
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
LUASOCKET_PRIVATE int buffer_meth_setstats(lua_State *L, p_buffer buf) { int buffer_meth_setstats(lua_State *L, p_buffer buf) {
buf->received = (long) luaL_optnumber(L, 2, (lua_Number) buf->received); buf->received = (long) luaL_optnumber(L, 2, (lua_Number) buf->received);
buf->sent = (long) luaL_optnumber(L, 3, (lua_Number) buf->sent); buf->sent = (long) luaL_optnumber(L, 3, (lua_Number) buf->sent);
if (lua_isnumber(L, 4)) buf->birthday = timeout_gettime() - lua_tonumber(L, 4); if (lua_isnumber(L, 4)) buf->birthday = timeout_gettime() - lua_tonumber(L, 4);
@ -74,7 +69,7 @@ LUASOCKET_PRIVATE int buffer_meth_setstats(lua_State *L, p_buffer buf) {
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
* object:send() interface * object:send() interface
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
LUASOCKET_PRIVATE int buffer_meth_send(lua_State *L, p_buffer buf) { int buffer_meth_send(lua_State *L, p_buffer buf) {
int top = lua_gettop(L); int top = lua_gettop(L);
int err = IO_DONE; int err = IO_DONE;
size_t size = 0, sent = 0; size_t size = 0, sent = 0;
@ -107,7 +102,7 @@ LUASOCKET_PRIVATE int buffer_meth_send(lua_State *L, p_buffer buf) {
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
* object:receive() interface * object:receive() interface
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
LUASOCKET_PRIVATE int buffer_meth_receive(lua_State *L, p_buffer buf) { int buffer_meth_receive(lua_State *L, p_buffer buf) {
int err = IO_DONE, top = lua_gettop(L); int err = IO_DONE, top = lua_gettop(L);
luaL_Buffer b; luaL_Buffer b;
size_t size; size_t size;
@ -156,7 +151,7 @@ LUASOCKET_PRIVATE int buffer_meth_receive(lua_State *L, p_buffer buf) {
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
* Determines if there is any data in the read buffer * Determines if there is any data in the read buffer
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
LUASOCKET_PRIVATE int buffer_isempty(p_buffer buf) { int buffer_isempty(p_buffer buf) {
return buf->first >= buf->last; return buf->first >= buf->last;
} }

View File

@ -15,8 +15,7 @@
* The module is built on top of the I/O abstraction defined in io.h and the * The module is built on top of the I/O abstraction defined in io.h and the
* timeout management is done with the timeout.h interface. * timeout management is done with the timeout.h interface.
\*=========================================================================*/ \*=========================================================================*/
#include "lua.h" #include "luasocket.h"
#include "io.h" #include "io.h"
#include "timeout.h" #include "timeout.h"
@ -34,12 +33,16 @@ typedef struct t_buffer_ {
} t_buffer; } t_buffer;
typedef t_buffer *p_buffer; typedef t_buffer *p_buffer;
#pragma GCC visibility push(hidden)
int buffer_open(lua_State *L); int buffer_open(lua_State *L);
void buffer_init(p_buffer buf, p_io io, p_timeout tm); void buffer_init(p_buffer buf, p_io io, p_timeout tm);
int buffer_meth_send(lua_State *L, p_buffer buf);
int buffer_meth_receive(lua_State *L, p_buffer buf);
int buffer_meth_getstats(lua_State *L, p_buffer buf); int buffer_meth_getstats(lua_State *L, p_buffer buf);
int buffer_meth_setstats(lua_State *L, p_buffer buf); int buffer_meth_setstats(lua_State *L, p_buffer buf);
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); int buffer_isempty(p_buffer buf);
#pragma GCC visibility pop
#endif /* BUF_H */ #endif /* BUF_H */