diff options
author | Eric Wong <e@80x24.org> | 2014-02-21 17:05:55 -0500 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2014-02-21 17:05:55 -0500 |
commit | 35782a1facdc61ae007086657689cf289c96dd92 (patch) | |
tree | 67ba79b600e1984ce2397e137b3c730759d12181 | |
parent | 3d96736835c69b3de698bd3cc9ed12bab1da8d73 (diff) | |
download | cmogstored-35782a1facdc61ae007086657689cf289c96dd92.tar.gz |
Debian GNU/kFreeBSD users may ./configure with LIBS=-lfreebsd-glue to use the FreeBSD sendfile syscall.
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | http_get.c | 22 |
2 files changed, 19 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac index 4e66f84..1ad3b41 100644 --- a/configure.ac +++ b/configure.ac @@ -50,6 +50,9 @@ AC_CHECK_FUNCS([sendfile]) AC_CHECK_FUNCS([open_memstream]) AC_CHECK_FUNCS([posix_fadvise]) +dnl need LIBS=-lfreebsd-glue (but not CFLAGS=-I/usr/include/freebsd) +AC_CHECK_FUNCS([bsd_sendfile]) + dnl non-standard, but common AC_CHECK_FUNCS([pthread_yield]) @@ -5,11 +5,18 @@ #include "cmogstored.h" #include "http.h" -#if defined(HAVE_SENDFILE) -# ifdef HAVE_SYS_SENDFILE_H /* Linux */ -# include <sys/sendfile.h> -# endif -# ifndef __linux__ + +#if defined(HAVE_SYS_SENDFILE_H) && !defined(HAVE_BSD_SENDFILE) +# include <sys/sendfile.h> +#endif + +#if defined(__linux__) +/* all good */ +#elif defined(HAVE_SENDFILE) || defined(HAVE_BSD_SENDFILE) +# if defined(HAVE_BSD_SENDFILE) && !defined(HAVE_SENDFILE)/* Debian kFBSD */ +# define sendfile(fd,s,offset,nbytes,hdtr,sbytes,flags) \ + bsd_sendfile((fd),(s),(offset),(nbytes),(hdtr),(sbytes),(flags)) +# endif /* HAVE_BSD_SENDFILE */ /* * make BSD sendfile look like Linux for now... * we can support SF_NODISKIO later @@ -28,9 +35,12 @@ static ssize_t linux_sendfile(int sockfd, int filefd, off_t *off, size_t count) return (ssize_t)rc; } + +# if defined(HAVE_BSD_SENDFILE) /* Debian GNU/kFreeBSD */ +# undef sendfile +# endif /* HAVE_BSD_SENDFILE */ # define sendfile(out_fd, in_fd, offset, count) \ linux_sendfile((out_fd),(in_fd),(offset),(count)) -# endif #else # include "compat_sendfile.h" #endif |