diff --git a/gem/gem.c b/gem/gem.c index 976f74d4..728dedd9 100644 --- a/gem/gem.c +++ b/gem/gem.c @@ -24,7 +24,7 @@ static int pushchar(int c, int last, const char *marker, } static int eol(lua_State *L) { - int context = luaL_checkint(L, 1); + int context = (int)luaL_checkinteger(L, 1); size_t isize = 0; const char *input = luaL_optlstring(L, 2, NULL, &isize); const char *last = input + isize; diff --git a/gem/ltn012.tex b/gem/ltn012.tex index 8027ecca..a745d502 100644 --- a/gem/ltn012.tex +++ b/gem/ltn012.tex @@ -269,7 +269,7 @@ \subsection{The C part of the filter} \begin{C} @stick# static int eol(lua_State *L) { - int context = luaL_checkint(L, 1); + int context = (int)luaL_checkinteger(L, 1); size_t isize = 0; const char *input = luaL_optlstring(L, 2, NULL, &isize); const char *last = input + isize; diff --git a/ltn012.wiki b/ltn012.wiki index 96b13ae4..520ae214 100644 --- a/ltn012.wiki +++ b/ltn012.wiki @@ -89,7 +89,7 @@ static int process(int c, int last, const char *marker, luaL_Buffer *buffer) { The inner function makes use of Lua's auxiliary library's buffer interface for its efficiency and ease of use. The outer function simply interfaces with Lua. It receives the context and the input chunk (as well as an optional end-of-line marker), and returns the transformed output and the new context. {{{ static int eol(lua_State *L) { - int ctx = luaL_checkint(L, 1); + int ctx = (int)luaL_checkinteger(L, 1); size_t isize = 0; const char *input = luaL_optlstring(L, 2, NULL, &isize); const char *last = input + isize; diff --git a/src/luasocket.c b/src/luasocket.c index e6ee7476..cd2990d8 100644 --- a/src/luasocket.c +++ b/src/luasocket.c @@ -64,7 +64,7 @@ static luaL_Reg func[] = { * Skip a few arguments \*-------------------------------------------------------------------------*/ static int global_skip(lua_State *L) { - int amount = luaL_checkint(L, 1); + int amount = (int)luaL_checkinteger(L, 1); int ret = lua_gettop(L) - amount - 1; return ret >= 0 ? ret : 0; } diff --git a/src/mime.c b/src/mime.c index dd37dcf0..e59e6ddc 100644 --- a/src/mime.c +++ b/src/mime.c @@ -661,7 +661,7 @@ static int eolprocess(int c, int last, const char *marker, \*-------------------------------------------------------------------------*/ static int mime_global_eol(lua_State *L) { - int ctx = luaL_checkint(L, 1); + int ctx = (int)luaL_checkinteger(L, 1); size_t isize = 0; const char *input = luaL_optlstring(L, 2, NULL, &isize); const char *last = input + isize; diff --git a/src/usocket.c b/src/usocket.c index 89f774dd..4fe333e3 100644 --- a/src/usocket.c +++ b/src/usocket.c @@ -15,11 +15,6 @@ * Wait for readable/writable/connected socket with timeout \*-------------------------------------------------------------------------*/ #ifndef SOCKET_SELECT -#include - -#define WAITFD_R POLLIN -#define WAITFD_W POLLOUT -#define WAITFD_C (POLLIN|POLLOUT) int socket_waitfd(p_socket ps, int sw, p_timeout tm) { int ret; struct pollfd pfd; @@ -37,11 +32,6 @@ int socket_waitfd(p_socket ps, int sw, p_timeout tm) { return IO_DONE; } #else - -#define WAITFD_R 1 -#define WAITFD_W 2 -#define WAITFD_C (WAITFD_R|WAITFD_W) - int socket_waitfd(p_socket ps, int sw, p_timeout tm) { int ret; fd_set rfds, wfds, *rp, *wp; diff --git a/src/usocket.h b/src/usocket.h index 45f2f99f..ecbcd8e5 100644 --- a/src/usocket.h +++ b/src/usocket.h @@ -31,6 +31,17 @@ #include #include +#ifndef SOCKET_SELECT +#include +#define WAITFD_R POLLIN +#define WAITFD_W POLLOUT +#define WAITFD_C (POLLIN|POLLOUT) +#else +#define WAITFD_R 1 +#define WAITFD_W 2 +#define WAITFD_C (WAITFD_R|WAITFD_W) +#endif + #ifndef SO_REUSEPORT #define SO_REUSEPORT SO_REUSEADDR #endif diff --git a/src/wsocket.c b/src/wsocket.c index b4a4384f..8c7640eb 100644 --- a/src/wsocket.c +++ b/src/wsocket.c @@ -39,11 +39,6 @@ int socket_close(void) { /*-------------------------------------------------------------------------*\ * Wait for readable/writable/connected socket with timeout \*-------------------------------------------------------------------------*/ -#define WAITFD_R 1 -#define WAITFD_W 2 -#define WAITFD_E 4 -#define WAITFD_C (WAITFD_E|WAITFD_W) - int socket_waitfd(p_socket ps, int sw, p_timeout tm) { int ret; fd_set rfds, wfds, efds, *rp = NULL, *wp = NULL, *ep = NULL; diff --git a/src/wsocket.h b/src/wsocket.h index 39866402..c5a4b1ce 100644 --- a/src/wsocket.h +++ b/src/wsocket.h @@ -16,6 +16,11 @@ typedef SOCKADDR_STORAGE t_sockaddr_storage; typedef SOCKET t_socket; typedef t_socket *p_socket; +#define WAITFD_R 1 +#define WAITFD_W 2 +#define WAITFD_E 4 +#define WAITFD_C (WAITFD_E|WAITFD_W) + #ifndef IPV6_V6ONLY #define IPV6_V6ONLY 27 #endif