From c14a71ce5f8a891ee3fe00f9ccbe2d3c85062708 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Fri, 16 Sep 2011 13:49:16 -0600 Subject: [PATCH] fdatasync: port to MacOS X 10.7 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 --- ChangeLog | 8 ++++++++ doc/posix-functions/fdatasync.texi | 3 +++ lib/unistd.in.h | 2 +- m4/fdatasync.m4 | 7 ++++++- m4/unistd_h.m4 | 1 + modules/unistd | 1 + 6 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7783d0711..4a2faf744 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2011-09-16 Eric Blake + 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. diff --git a/doc/posix-functions/fdatasync.texi b/doc/posix-functions/fdatasync.texi index 8209ecdcf..238238663 100644 --- a/doc/posix-functions/fdatasync.texi +++ b/doc/posix-functions/fdatasync.texi @@ -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 diff --git a/lib/unistd.in.h b/lib/unistd.in.h index 7c274b404..1c67173d5 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -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 . */ -# if !@HAVE_FDATASYNC@ +# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@ _GL_FUNCDECL_SYS (fdatasync, int, (int fd)); # endif _GL_CXXALIAS_SYS (fdatasync, int, (int fd)); diff --git a/m4/fdatasync.m4 b/m4/fdatasync.m4 index 8eceeb547..cb1194666 100644 --- a/m4/fdatasync.m4 +++ b/m4/fdatasync.m4 @@ -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 ]) diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 index 29f3947b5..720e0fd03 100644 --- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -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]) diff --git a/modules/unistd b/modules/unistd index f843a2ff3..77ce7a823 100644 --- a/modules/unistd +++ b/modules/unistd @@ -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' \ -- 2.11.0