[commit: packages/unix] master: Adds a more comprehensive check for fdatasync (b06446e)

git at git.haskell.org git at git.haskell.org
Thu Mar 19 15:51:25 UTC 2015


Repository : ssh://git@git.haskell.org/unix

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/b06446edd4753f964a46d27ddae864fad97adc13/unix

>---------------------------------------------------------------

commit b06446edd4753f964a46d27ddae864fad97adc13
Author: Elliot Robinson <elliot.robinson at argiopetech.com>
Date:   Sun Mar 8 15:55:05 2015 -0400

    Adds a more comprehensive check for fdatasync
    
    Some versions of OS X have fdatasync in the headers but don't include implementations in the standard library. This leads to a compile failure in configure.ac when using AC_CHECK_FUNCS.
    
    This change explicitly attempts to compile a file containing a call to fdatasync and properly sets the AC_CHECK_FUNCS flags depending on the result of compilation.


>---------------------------------------------------------------

b06446edd4753f964a46d27ddae864fad97adc13
 configure.ac | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index f7b1afb..c63b45b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -68,7 +68,26 @@ AC_CHECK_FUNCS([lutimes futimes])
 AC_CHECK_FUNCS([mkstemps mkdtemp])
 
 # Functions for file synchronization and allocation control
-AC_CHECK_FUNCS([fsync fdatasync])
+AC_CHECK_FUNCS([fsync])
+
+# A more comprehensive check that fdatasync exits
+# Necessary for platforms that have fdatasync in headers but have no
+# implementation
+dnl Originally provided by user copiousfreetime for the beanstalkd project
+dnl {{{ make sure that fdatasync exits
+AC_CACHE_CHECK([for fdatasync],[ac_cv_func_fdatasync],[
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <unistd.h>
+]],[[
+fdatasync(4);
+]])],
+[ac_cv_func_fdatasync=yes],
+[ac_cv_func_fdatasync=no])
+])
+AS_IF([test "x${ac_cv_func_fdatasync}" = "xyes"],
+ [AC_DEFINE([HAVE_FDATASYNC],[1],[If the system defines fdatasync])])
+dnl }}}
+
 AC_CHECK_FUNCS([posix_fadvise posix_fallocate])
 
 # Avoid adding rt if absent or unneeded



More information about the ghc-commits mailing list