--- libeio/eio.c 2010/01/02 14:24:32 1.49 +++ libeio/eio.c 2010/01/07 17:18:08 1.50 @@ -82,7 +82,7 @@ # include /* POSIX_SOURCE is useless on bsd's, and XOPEN_SOURCE is unreliable there, too */ -# if __freebsd || defined __NetBSD__ || defined __OpenBSD__ +# if __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__ # define _DIRENT_HAVE_D_TYPE /* sigh */ # define D_INO(de) (de)->d_fileno # define D_NAMLEN(de) (de)->d_namlen @@ -108,7 +108,7 @@ #if HAVE_SENDFILE # if __linux # include -# elif __freebsd || defined __APPLE__ +# elif __FreeBSD__ || defined __APPLE__ # include # include # elif __hpux @@ -911,7 +911,7 @@ # if __linux res = sendfile (ofd, ifd, &offset, count); -# elif __freebsd +# elif __FreeBSD__ /* * Of course, the freebsd sendfile is a dire hack with no thoughts * wasted on making it similar to other I/O functions. @@ -920,7 +920,8 @@ off_t sbytes; res = sendfile (ifd, ofd, offset, count, 0, &sbytes, 0); - if (res < 0 && sbytes) + /* freebsd' sendfile will return 0 when success */ + if (res == 0 && sbytes) /* maybe only on EAGAIN: as usual, the manpage leaves you guessing */ res = sbytes; } @@ -931,7 +932,7 @@ off_t sbytes = count; res = sendfile (ifd, ofd, offset, &sbytes, 0, 0); - if (res < 0 && errno == EAGAIN && sbytes) + if (res == 0 && errno == EAGAIN && sbytes) res = sbytes; }