* Add support for other operating systems (kFreeBSD, FreeBSD, and OSX for now).

* Switch to autoconf from genconfig.sh.
This commit is contained in:
Justin Maggard
2011-09-16 23:39:58 +00:00
parent 715af3519b
commit 773e1f6566
40 changed files with 1952 additions and 533 deletions

53
sendfile.h Normal file
View File

@ -0,0 +1,53 @@
#if defined(HAVE_LINUX_SENDFILE_API)
#include <sys/sendfile.h>
int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
{
return sendfile(sock, sendfd, offset, len);
}
#elif defined(HAVE_DARWIN_SENDFILE_API)
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
{
int ret;
ret = sendfile(sendfd, sock, *offset, &len, NULL, 0);
*offset += len;
return ret;
}
#elif defined(HAVE_FREEBSD_SENDFILE_API)
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
{
int ret;
size_t nbytes = len;
ret = sendfile(sendfd, sock, *offset, nbytes, NULL, &len, SF_MNOWAIT);
*offset += len;
return ret;
}
#else
#include <errno.h>
int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
{
errno = EINVAL;
return -1;
}
#endif