]> arthur.barton.de Git - netatalk.git/commitdiff
Add Solaris senfile() support and enable sendfile on FreeBSD
authorFrank Lahm <franklahm@googlemail.com>
Mon, 21 Nov 2011 11:14:16 +0000 (12:14 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Mon, 21 Nov 2011 11:14:16 +0000 (12:14 +0100)
configure.ac
libatalk/adouble/ad_sendfile.c

index dc3c0efac5d5715b3d52717d9417daa6f186c0ac..df9941d6ffa16dff97f5295ba75196d0a7da4d3f 100644 (file)
@@ -592,7 +592,7 @@ if test x"$this_os" = "xfreebsd"; then
        AC_MSG_RESULT([ * FreeBSD specific configuration])
        AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
        AC_DEFINE(FREEBSD, 1, [Define if OS is FreeBSD])
-       AC_DEFINE(SENDFILE_FLAVOR_BSD, 1, [Define if the sendfile() function uses BSD semantics])
+
     AC_DEFINE(OPEN_NOFOLLOW_ERRNO, EMLINK, errno returned by open with O_NOFOLLOW)
 fi
 
@@ -666,62 +666,6 @@ fi
        dnl ----- see etc/afpd/quota.c
        AC_DEFINE(HAVE_BROKEN_DBTOB, 1, [Define if dbtob is broken])
 
-       netatalk_cv_linux_sendfile=yes
-       AC_MSG_CHECKING([use sendfile syscall])
-        AC_ARG_ENABLE(sendfile,
-           [  --disable-sendfile       disable linux sendfile syscall],[
-               if test x"$enableval" = x"no"; then
-                       netatalk_cv_linux_sendfile=no
-                       AC_MSG_RESULT([no])
-               else
-                       AC_MSG_RESULT([yes])
-
-               fi
-           ],[
-               AC_MSG_RESULT([yes])
-       ]
-
-       )
-
-       if test x"$netatalk_cv_linux_sendfile" = "xyes"; then 
-           AC_CACHE_CHECK([for linux sendfile support],netatalk_cv_HAVE_SENDFILE,[
-           AC_TRY_LINK([#include <sys/sendfile.h>],
-[\
-int tofd, fromfd;
-off_t offset;
-size_t total;
-ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
-],
-netatalk_cv_HAVE_SENDFILE=yes,netatalk_cv_HAVE_SENDFILE=no)])
-
-# Try and cope with broken Linux sendfile....
-           AC_CACHE_CHECK([for broken linux sendfile support],netatalk_cv_HAVE_BROKEN_LINUX_SENDFILE,[
-           AC_TRY_LINK([\
-#if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
-#undef _FILE_OFFSET_BITS
-#endif
-#include <sys/sendfile.h>],
-[\
-int tofd, fromfd;
-off_t offset;
-size_t total;
-ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
-],
-netatalk_cv_HAVE_BROKEN_LINUX_SENDFILE=yes,netatalk_cv_HAVE_BROKEN_LINUX_SENDFILE=no,netatalk_cv_HAVE_BROKEN_SENDFILE=cross)])
-
-           if test x"$netatalk_cv_HAVE_SENDFILE" = x"yes"; then
-               AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
-               AC_DEFINE(SENDFILE_FLAVOR_LINUX,1,[Whether linux sendfile() API is available])
-               AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
-           elif test x"$netatalk_cv_HAVE_BROKEN_LINUX_SENDFILE" = x"yes"; then
-               AC_DEFINE(SENDFILE_FLAVOR_LINUX,1,[Whether linux sendfile() API is available])
-               AC_DEFINE(LINUX_BROKEN_SENDFILE_API,1,[Whether (linux) sendfile() is broken])
-               AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile should be used])
-           else
-               netatalk_cv_linux_sendfile=no
-               AC_MSG_RESULT(no);
-           fi
-       fi
 
        dnl ----- Linux/alpha specific -----
        if test x"$this_cpu" = "xalpha"; then 
@@ -876,6 +820,77 @@ if test x"$this_os" = "xtru64"; then
        sysv_style=tru64
 fi
 
+dnl ------ Check for sendfile() --------
+netatalk_cv_search_sendfile=yes
+AC_ARG_ENABLE(sendfile,
+    [  --disable-sendfile       disable sendfile syscall],
+    [if test x"$enableval" = x"no"; then
+            netatalk_cv_search_sendfile=no
+        fi]
+)
+
+if test x"$netatalk_cv_search_sendfile" = x"yes"; then
+   case "$host_os" in
+   *linux*)
+       AC_DEFINE(SENDFILE_FLAVOR_LINUX,1,[Whether linux sendfile() API is available])
+       AC_MSG_CHECKING([for sendfile() syscall])
+       AC_CACHE_CHECK([for sendfile support],
+           [netatalk_cv_HAVE_SENDFILE],
+           [AC_TRY_LINK(
+               [#include <sys/sendfile.h>],
+               [int tofd, fromfd;
+                   off_t offset;
+                   size_t total;
+                   ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);],
+               [netatalk_cv_HAVE_SENDFILE=yes]
+            )]
+        )
+
+        # Try and cope with broken Linux sendfile....
+        AC_CACHE_CHECK([for broken Linux sendfile support],
+            [netatalk_cv_HAVE_BROKEN_LINUX_SENDFILE],
+            [AC_TRY_LINK(
+                [#if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
+                    #undef _FILE_OFFSET_BITS
+                    #endif
+                    #include <sys/sendfile.h>],
+                [int tofd, fromfd;
+                    off_t offset;
+                    size_t total;
+                    ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);],
+                [netatalk_cv_HAVE_SENDFILE=yes;
+                    AC_DEFINE(LINUX_BROKEN_SENDFILE_API,1,[Whether Linux sendfile() is broken])]
+            )]
+        )
+        if test x"$netatalk_cv_HAVE_SENDFILE" = x"yes"; then
+            AC_MSG_RESULT(yes);
+        else
+            AC_MSG_RESULT(no);
+        fi
+        ;;
+
+    *solaris*)
+        AC_DEFINE(SENDFILE_FLAVOR_SOLARIS, 1, [Solaris sendfile()])
+        AC_SEARCH_LIBS(sendfile, sendfile)
+        AC_CHECK_FUNC([sendfile], [netatalk_cv_HAVE_SENDFILE=yes])
+        ;;
+
+    *freebsd*)
+        AC_DEFINE(SENDFILE_FLAVOR_BSD, 1, [Define if the sendfile() function uses BSD semantics])
+        AC_CHECK_FUNC([sendfile], [netatalk_cv_HAVE_SENDFILE=yes])
+        ;;
+
+    *)
+        ;;
+
+    esac
+
+    if test x"$netatalk_cv_HAVE_SENDFILE" = x"yes"; then
+        AC_DEFINE(HAVE_SENDFILE,1,[Whether sendfile() is available])
+        AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
+    fi
+fi
+
 dnl -- check for libgcrypt, if found enables DHX UAM
 AM_PATH_LIBGCRYPT([1:1.2.3],[neta_cv_compile_dhx2=yes
                        neta_cv_have_libgcrypt=yes
index 2cc9a1f4470f8e75fe7b35b3fd1b6da52f6aec23..154c89d02473776968a91faec19e6f32c76d168f 100644 (file)
@@ -45,7 +45,7 @@
 #include <atalk/logger.h>
 #include "ad_private.h"
 
-#if defined(LINUX_BROKEN_SENDFILE_API)
+#if defined(SENDFILE_FLAVOR_LINUX) && defined(LINUX_BROKEN_SENDFILE_API)
 
 extern int32_t sendfile (int fdout, int fdin, int32_t *offset, u_int32_t count);
 
@@ -83,9 +83,15 @@ ssize_t sys_sendfile(int tofd, int fromfd, off_t *offset, size_t count)
     return sendfile(tofd, fromfd, offset, count);
 }
 
+#elif defined(SENDFILE_FLAVOR_SOLARIS)
+#include <sys/sendfile.h>
+
+ssize_t sys_sendfile(int tofd, int fromfd, off_t *offset, size_t count)
+{
+    return sendfile(tofd, fromfd, offset, count);
+}
+
 #elif defined(SENDFILE_FLAVOR_BSD )
-/* FIXME untested */
-#error sendfile semantic broken
 #include <sys/sendfile.h>
 ssize_t sys_sendfile(int tofd, int fromfd, off_t *offset, size_t count)
 {