Patchwork [05/10] configure: Fix check for fdatasync()

login
register
mail settings
Submitter Andreas Färber
Date June 14, 2011, 1:22 a.m.
Message ID <1308014527-60251-6-git-send-email-andreas.faerber@web.de>
Download mbox | patch
Permalink /patch/100214/
State New
Headers show

Comments

Andreas Färber - June 14, 2011, 1:22 a.m.
From: Alexandre Raymond <cerbere@gmail.com>

Under Darwin, a symbol exists for the fdatasync() function, so that our
link test succeeds. However _POSIX_SYNCHRONIZED_IO is set to '-1'.

According to POSIX:2008, a value of -1 means the feature is not supported.
A value of 0 means supported at compilation time, and a value greater 0
means supported at both compilation and run time.

Enable fdatasync() only if _POSIX_SYNCHRONIZED_IO is '>0'.

Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
 configure |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

Patch

diff --git a/configure b/configure
index c931ae8..6101f4e 100755
--- a/configure
+++ b/configure
@@ -2461,7 +2461,13 @@  fi
 fdatasync=no
 cat > $TMPC << EOF
 #include <unistd.h>
-int main(void) { return fdatasync(0); }
+int main(void) {
+#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
+return fdatasync(0);
+#else
+#abort Not supported
+#endif
+}
 EOF
 if compile_prog "" "" ; then
     fdatasync=yes