support OS Darwin
parent
386a5eb485
commit
e211604368
9
make.sh
9
make.sh
|
|
@ -5,8 +5,8 @@ cat <<EOF > $tmp_src_filename
|
|||
#include <fcntl.h>
|
||||
int main()
|
||||
{
|
||||
printf("%d\n", sizeof(long));
|
||||
printf("%d\n", sizeof(off_t));
|
||||
printf("%d\n", (int)sizeof(long));
|
||||
printf("%d\n", (int)sizeof(off_t));
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
|
|
@ -71,6 +71,9 @@ if [ "$uname" = "Linux" ]; then
|
|||
CFLAGS="$CFLAGS -DOS_LINUX -DIOEVENT_USE_EPOLL"
|
||||
elif [ "$uname" = "FreeBSD" ] || [ "$uname" = "Darwin" ]; then
|
||||
CFLAGS="$CFLAGS -DOS_FREEBSD -DIOEVENT_USE_KQUEUE"
|
||||
if [ "$uname" = "Darwin" ]; then
|
||||
CFLAGS="$CFLAGS -DDARWIN"
|
||||
fi
|
||||
elif [ "$uname" = "SunOS" ]; then
|
||||
CFLAGS="$CFLAGS -DOS_SUNOS -D_THREAD_SAFE -DIOEVENT_USE_PORT"
|
||||
LIBS="$LIBS -lsocket -lnsl -lresolv"
|
||||
|
|
@ -84,7 +87,7 @@ fi
|
|||
|
||||
if [ -f /usr/lib/libpthread.so ] || [ -f /usr/local/lib/libpthread.so ] || [ -f /usr/lib64/libpthread.so ] || [ -f /usr/lib/libpthread.a ] || [ -f /usr/local/lib/libpthread.a ] || [ -f /usr/lib64/libpthread.a ]; then
|
||||
LIBS="$LIBS -lpthread"
|
||||
else
|
||||
elif [ -f /usr/lib/libc_r.so ]; then
|
||||
line=`nm -D /usr/lib/libc_r.so | grep pthread_create | grep -w T`
|
||||
if [ -n "$line" ]; then
|
||||
LIBS="$LIBS -lc_r"
|
||||
|
|
|
|||
|
|
@ -1109,6 +1109,9 @@ int tcpsendfile_ex(int sock, const char *filename, const int64_t file_offset, \
|
|||
off_t offset;
|
||||
#ifdef OS_LINUX
|
||||
int64_t remain_bytes;
|
||||
#elif defined(DARWIN)
|
||||
int64_t remain_bytes;
|
||||
off_t len;
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
|
|
@ -1183,7 +1186,21 @@ int tcpsendfile_ex(int sock, const char *filename, const int64_t file_offset, \
|
|||
#else
|
||||
#ifdef OS_FREEBSD
|
||||
offset = file_offset;
|
||||
if (sendfile(fd, sock, offset, file_bytes, NULL, NULL, 0) != 0)
|
||||
#if defined(DARWIN)
|
||||
result = 0;
|
||||
remain_bytes = file_bytes;
|
||||
while (remain_bytes > 0)
|
||||
{
|
||||
len = remain_bytes;
|
||||
if (sendfile(fd, sock, offset, &len, NULL, 0) != 0) {
|
||||
result = errno != 0 ? errno : EIO;
|
||||
break;
|
||||
}
|
||||
remain_bytes -= len;
|
||||
}
|
||||
*total_send_bytes = file_bytes - remain_bytes;
|
||||
#else
|
||||
if (sendfile(fd, sock, offset, file_offset, NULL, NULL, 0) != 0)
|
||||
{
|
||||
*total_send_bytes = 0;
|
||||
result = errno != 0 ? errno : EIO;
|
||||
|
|
@ -1194,6 +1211,7 @@ int tcpsendfile_ex(int sock, const char *filename, const int64_t file_offset, \
|
|||
result = 0;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (flags & O_NONBLOCK) //restore
|
||||
|
|
|
|||
Loading…
Reference in New Issue