Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move #define WAITFD_* to .h #80

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gem/gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion gem/ltn012.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ltn012.wiki
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/luasocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 0 additions & 10 deletions src/usocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
* Wait for readable/writable/connected socket with timeout
\*-------------------------------------------------------------------------*/
#ifndef SOCKET_SELECT
#include <sys/poll.h>

#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;
Expand All @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions src/usocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@
#include <netinet/tcp.h>
#include <net/if.h>

#ifndef SOCKET_SELECT
#include <sys/poll.h>
#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
Expand Down
5 changes: 0 additions & 5 deletions src/wsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/wsocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down