fdatasync: port to MacOS X 10.7
authorEric Blake <eblake@redhat.com>
Fri, 16 Sep 2011 19:49:16 +0000 (13:49 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 16 Sep 2011 19:49:16 +0000 (13:49 -0600)
MacOS X 10.7 added an fdatasync syscall and exports a symbol for it,
but fails to declare it anywhere.  Lacking any hard evidence that this
syscall is broken, we will just provide the declaration and use it.

* m4/fdatasync.m4 (gl_FUNC_FDATASYNC): Check for present but not
declared.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Another default.
* modules/unistd (Makefile.am): Substitute it.
* lib/unistd.in.h (fdatasync): Declare on MacOS.
* doc/posix-functions/fdatasync.texi (fdatasync): Document it.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
doc/posix-functions/fdatasync.texi
lib/unistd.in.h
m4/fdatasync.m4
m4/unistd_h.m4
modules/unistd

index 7783d07..4a2faf7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2011-09-16  Eric Blake  <eblake@redhat.com>
 
+       fdatasync: port to MacOS X 10.7.
+       * m4/fdatasync.m4 (gl_FUNC_FDATASYNC): Check for present but not
+       declared.
+       * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Another default.
+       * modules/unistd (Makefile.am): Substitute it.
+       * lib/unistd.in.h (fdatasync): Declare on MacOS.
+       * doc/posix-functions/fdatasync.texi (fdatasync): Document it.
+
        fdatasync: minor improvements
        * modules/fdatasync (Depends-on): Add condition for fsync.
        * lib/fdatasync.c (fdatasync): Add comment.
index 8209ecd..2382386 100644 (file)
@@ -9,6 +9,9 @@ Gnulib module: fdatasync
 Portability problems fixed by Gnulib:
 @itemize
 @item
+This function is present but not declared on some platforms:
+MacOS X 10.7.
+@item
 This function is missing on some platforms:
 MacOS X 10.5, FreeBSD 6.0, OpenBSD 3.8, Minix 3.1.8, IRIX 5.3, Solaris 2.4, mingw, MSVC 9, Interix 3.5, BeOS.
 @end itemize
index 7c274b4..1c67173 100644 (file)
@@ -489,7 +489,7 @@ _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
    Return 0 if successful, otherwise -1 and errno set.
    See POSIX:2008 specification
    <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>.  */
-# if !@HAVE_FDATASYNC@
+# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
 _GL_FUNCDECL_SYS (fdatasync, int, (int fd));
 # endif
 _GL_CXXALIAS_SYS (fdatasync, int, (int fd));
index 8eceeb5..cb11946 100644 (file)
@@ -1,4 +1,4 @@
-# fdatasync.m4 serial 1
+# fdatasync.m4 serial 2
 dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -11,4 +11,9 @@ AC_DEFUN([gl_FUNC_FDATASYNC],
   if test $ac_cv_func_fdatasync = no; then
     HAVE_FDATASYNC=0
   fi
+  dnl MacOS X 10.7 has fdatasync but does not declare it.
+  AC_CHECK_DECLS_ONCE([fdatasync])
+  if test $ac_cv_have_decl_fdatasync = no; then
+    HAVE_DECL_FDATASYNC=0
+  fi
 ])
index 29f3947..720e0fd 100644 (file)
@@ -136,6 +136,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   HAVE_USLEEP=1;          AC_SUBST([HAVE_USLEEP])
   HAVE_DECL_ENVIRON=1;    AC_SUBST([HAVE_DECL_ENVIRON])
   HAVE_DECL_FCHDIR=1;     AC_SUBST([HAVE_DECL_FCHDIR])
+  HAVE_DECL_FDATASYNC=1;  AC_SUBST([HAVE_DECL_FDATASYNC])
   HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME])
   HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
   HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE])
index f843a2f..77ce7a8 100644 (file)
@@ -108,6 +108,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \
              -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
              -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \
+             -e 's|@''HAVE_DECL_FDATASYNC''@|$(HAVE_DECL_FDATASYNC)|g' \
              -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \
              -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
              -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \