From a563e22ec4828b38709b0ee8caa77fae11f43fa9 Mon Sep 17 00:00:00 2001 From: "Rob Kendrick (fatigue-freebsd)" Date: Mon, 28 Jan 2013 17:13:29 +0000 Subject: Some FreeBSD compatibility work --- config.h | 5 +++++ luxio.c | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/config.h b/config.h index 91e5a83..c2a9b89 100644 --- a/config.h +++ b/config.h @@ -11,11 +11,16 @@ # define HAVE_SENDFILE 1 # define HAVE_SPLICE 1 # define HAVE_D_TYPE 1 +# define HAVE_FDATASYNC 1 # define _GNU_SOURCE # define _LARGEFILE64_SOURCE # define _POSIX_SOURCE # define _POSIX_C_SOURCE 1 #endif +#ifndef LOGIN_NAME_MAX +# define LOGIN_NAME_MAX 9 +#endif + #endif /* LUXIO_CONFIG_H */ diff --git a/luxio.c b/luxio.c index 29195e8..4f1ece2 100644 --- a/luxio.c +++ b/luxio.c @@ -39,6 +39,7 @@ #include #include #include +#include #ifdef HAVE_SENDFILE # include @@ -1679,6 +1680,7 @@ luxio_fsync(lua_State *L) /* 6.6.1 */ return 2; } +#ifdef HAVE_FDATASYNC /**% fdatasync * retval = fdatasync(filedes); * retval = fdatasync(filedes) @@ -1693,6 +1695,7 @@ luxio_fdatasync(lua_State *L) /* 6.6.2 */ return 2; } +#endif /* 6.7 Asynchronous input and output */ @@ -1794,7 +1797,11 @@ luxio_nanosleep(lua_State *L) /* 14.2.5 */ /**# Message passing *********************************************************/ -#ifdef _POSIX_MESSAGE_PASSING +#if defined(_POSIX_MESSAGE_PASSING) && defined(__linux__) + +/* TODO: This code assumes mqd_t is an integer. On BSD it is not, so + * this needs to be rewritten using userdata. + */ #include @@ -2806,7 +2813,7 @@ luxio_timeval_tostring(lua_State *L) char buffer[LUXIO_TIME_BUFLEN]; snprintf(buffer, LUXIO_TIME_BUFLEN, "timeval: %ld.%06ld", - a->tv_sec, a->tv_usec); + (long)a->tv_sec, a->tv_usec); lua_pushstring(L, buffer); @@ -2969,7 +2976,9 @@ luxio_functions[] = { { "lseek", luxio_lseek }, { "ftruncate", luxio_ftruncate }, { "fsync", luxio_fsync }, +#ifdef HAVE_FDATASYNC { "fdatasync", luxio_fdatasync }, +#endif { "rename", luxio_rename }, { "link", luxio_link }, { "unlink", luxio_unlink }, @@ -3104,6 +3113,8 @@ luxio_functions[] = { { "nanosleep", luxio_nanosleep }, +#if defined(_POSIX_MESSAGE_PASSING) && defined(__linux__) + #if _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L { "mq_timedsend", luxio_mq_timedsend }, { "mq_timedreceive", luxio_mq_timedreceive }, @@ -3115,6 +3126,7 @@ luxio_functions[] = { { "mq_receive", luxio_mq_receive }, { "mq_setattr", luxio_mq_setattr }, { "mq_getattr", luxio_mq_getattr }, +#endif { NULL, NULL } }; -- cgit v1.2.1