Created
September 15, 2009 13:05
-
-
Save kazuho/187277 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -u ../IO-AIO-3.3.orig/libeio/libeio.m4 libeio/libeio.m4 | |
--- ../IO-AIO-3.3.orig/libeio/libeio.m4 2008-10-23 02:54:19.000000000 +0900 | |
+++ libeio/libeio.m4 2009-09-16 11:05:46.000000000 +0900 | |
@@ -67,6 +67,11 @@ | |
#elif __freebsd | |
# include <sys/socket.h> | |
# include <sys/uio.h> | |
+#elif __APPLE__ | |
+# include <sys/socket.h> | |
+# include <sys/types.h> | |
+# include <sys/uio.h> | |
+# include <stddef.h> | |
#elif __hpux | |
# include <sys/socket.h> | |
#else | |
@@ -82,6 +87,9 @@ | |
res = sendfile (fd, fd, offset, count); | |
#elif __freebsd | |
res = sendfile (fd, fd, offset, count, 0, &offset, 0); | |
+#elif __APPLE__ | |
+ off_t bytes = count; | |
+ res = sendfile (fd, fd, offset, &bytes, NULL, 0); | |
#elif __hpux | |
res = sendfile (fd, fd, offset, count, 0, 0); | |
#endif | |
diff -u ../IO-AIO-3.3.orig/libeio/eio.c libeio/eio.c | |
--- ../IO-AIO-3.3.orig/libeio/eio.c 2009-07-15 10:34:38.000000000 +0900 | |
+++ libeio/eio.c 2009-09-16 01:20:05.000000000 +0900 | |
@@ -111,6 +111,11 @@ | |
# elif __freebsd | |
# include <sys/socket.h> | |
# include <sys/uio.h> | |
+# elif __APPLE__ | |
+# include <sys/socket.h> | |
+# include <sys/types.h> | |
+# include <sys/uio.h> | |
+# include <stddef.h> | |
# elif __hpux | |
# include <sys/socket.h> | |
# elif __solaris /* not yet */ | |
@@ -917,12 +922,24 @@ | |
* wasted on making it similar to other I/O functions. | |
*/ | |
{ | |
- off_t sbytes; | |
- res = sendfile (ifd, ofd, offset, count, 0, &sbytes, 0); | |
+ off_t sbytes = 0; /* seems not necessary, but just in case */ | |
+ int r = sendfile (ifd, ofd, offset, count, 0, &sbytes, 0); | |
- if (res < 0 && sbytes) | |
+ if (! (r == -1 && sbytes == 0)) | |
/* maybe only on EAGAIN: as usual, the manpage leaves you guessing */ | |
res = sbytes; | |
+ else | |
+ res = -1; | |
+ } | |
+ | |
+# elif __APPLE__ | |
+ { | |
+ off_t bytes = count; | |
+ int r = sendfile (ifd, ofd, offset, &bytes, NULL, 0); | |
+ if (r == 0 || (errno == EAGAIN || errno == EINTR)) | |
+ res = bytes; | |
+ else | |
+ res = -1; | |
} | |
# elif __hpux |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment