diff options
author | Rob Kendrick (fatigue-freebsd) <rjek@rjek.com> | 2013-01-28 17:13:29 +0000 |
---|---|---|
committer | Rob Kendrick (fatigue-freebsd) <rjek@rjek.com> | 2013-01-28 17:13:29 +0000 |
commit | a563e22ec4828b38709b0ee8caa77fae11f43fa9 (patch) | |
tree | 4040aac8950ff222bfb592a61942aa62859de845 | |
parent | 9a81138648ebe48db4c5059579005f8b6c9a970d (diff) | |
download | luxio-a563e22ec4828b38709b0ee8caa77fae11f43fa9.tar.gz |
Some FreeBSD compatibility work
-rw-r--r-- | config.h | 5 | ||||
-rw-r--r-- | luxio.c | 16 |
2 files changed, 19 insertions, 2 deletions
@@ -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 */ @@ -39,6 +39,7 @@ #include <dirent.h> #include <time.h> #include <limits.h> +#include <signal.h> #ifdef HAVE_SENDFILE # include <sys/sendfile.h> @@ -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 <mqueue.h> @@ -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 } }; |