nixio: FreeBSD compatibility #1

This commit is contained in:
Steven Barth 2009-03-12 13:06:19 +00:00
parent e401b4a620
commit 35f40376c3
3 changed files with 8 additions and 3 deletions

View file

@ -1,8 +1,8 @@
OS ?= $(shell uname)
LUA_SHLIBS = $(shell pkg-config --silence-errors --libs lua5.1 || pkg-config --silence-errors --libs lua)
LUA_SHLIBS = $(shell pkg-config --silence-errors --libs lua5.1 || pkg-config --silence-errors --libs lua-5.1 || pkg-config --silence-errors --libs lua)
LUA_LIBS = $(if $(LUA_SHLIBS),$(LUA_SHLIBS),$(firstword $(wildcard /usr/lib/liblua.a /usr/local/lib/liblua.a /opt/local/lib/liblua.a)))
LUA_CFLAGS = $(shell pkg-config --silence-errors --cflags lua5.1 || pkg-config --silence-errors --cflags lua)
LUA_CFLAGS = $(shell pkg-config --silence-errors --cflags lua5.1 || pkg-config --silence-errors --cflags lua-5.1 || pkg-config --silence-errors --cflags lua)
CC = gcc
AR = ar

View file

@ -179,7 +179,7 @@ LUALIB_API int luaopen_nixio(lua_State *L) {
NIXIO_PUSH_CONSTANT(SIGQUIT);
NIXIO_PUSH_CONSTANT(SIGUSR1);
NIXIO_PUSH_CONSTANT(SIGUSR2);
NIXIO_PUSH_CONSTANT(SIGPOLL);
NIXIO_PUSH_CONSTANT(SIGIO);
NIXIO_PUSH_CONSTANT(SIGURG);
lua_setfield(L, -2, "const");

View file

@ -17,6 +17,7 @@
*/
#include "nixio.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
@ -148,7 +149,11 @@ static int nixio__getsetsockopt(lua_State *L, int set) {
return luaL_error(L, "not a TCP socket");
}
if (!strcmp(option, "cork")) {
#ifdef TCP_CORK
return nixio__gso_int(L, sock->fd, IPPROTO_TCP, TCP_CORK, set);
#else
return nixio__pstatus(L, !(errno = ENOPROTOOPT));
#endif
} else if (!strcmp(option, "nodelay")) {
return nixio__gso_int(L, sock->fd, IPPROTO_TCP, TCP_NODELAY, set);
} else {