bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

make openat declarations consistent


From: Eric Blake
Subject: make openat declarations consistent
Date: Thu, 03 Sep 2009 06:09:37 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jim, what do you think of this patch, making it possible to avoid
including "openat.h" if you only use the POSIX 2008 interfaces?

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkqfsgEACgkQ84KuGfSFAYAN0ACdG9ViuIY3IEwQkqvvVt5PZeN5
2r0An3C/ZX8VvOYoPFccpNep+i0ZuQ5x
=ZJ0v
-----END PGP SIGNATURE-----
>From 601bb4476b3e9b8722f79fa05daacb34ae9f6430 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Wed, 2 Sep 2009 17:14:26 -0600
Subject: [PATCH] openat: declare in POSIX headers

* NEWS: Mention this.
* modules/openat (configure.ac): Declare witnesses.
(Depends-on): Add fcntl-h, sys_stat, unistd.
(Include): Mention correct headers.
* modules/fcntl-h (Depends-on): Add link-warning.
(Files): Add openat.m4.
(Makefile.am): Substitute witnesses.
* modules/sys_stat (Files, Makefile.am): Likewise.
* modules/unistd (Files, Makefile.am): Likewise.
* m4/openat.m4 (gl_FUNC_OPENAT, gl_FUNC_FCHOWNAT): Set witnesses.
(gl_OPENAT_DEFAULTS): New macro.
* m4/fcntl_h.m4 (gl_FCNTL_H_DEFAULTS): Use it.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Likewise.
* m4/sys_stat_h.m4 (gl_SYS_STAT_H_DEFAULTS): Likewise.
(SYS_STAT_H): Remove unused variable.
* doc/posix-headers/fcntl.texi (fcntl.h): Update content.
* lib/fcntl--.h (includes): Remove unneeded header.
* lib/openat-safer.c (includes): Likewise.
* lib/openat.h (AT_FDCWD, AT_SYMLINK_NOFOLLOW, AT_REMOVEDIR)
(openat, fstatat, unlinkat, mkdirat, fchmodat, fchownat): Move to
appropriate headers.
(__OPENAT_PREFIX): Delete.
* lib/fcntl.in.h (openat): Provide declaration.
(AT_FDCWD): Fix Solaris bug.
(AT_SYMLINK_NOFOLLOW, AT_REMOVEDIR): Provide macros.
* lib/sys_stat.in.h (fstatat, mkdirat): Provide declaration.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog                    |   30 +++++++++++++++++++++++++
 NEWS                         |   10 +++++++-
 doc/posix-headers/fcntl.texi |   11 ++++++++-
 lib/fcntl--.h                |    1 -
 lib/fcntl.in.h               |   44 +++++++++++++++++++++++++++++++++++++
 lib/openat-safer.c           |    1 -
 lib/openat.h                 |   45 +-------------------------------------
 lib/sys_stat.in.h            |   35 ++++++++++++++++++++++++++++++
 lib/unistd.in.h              |   25 +++++++++++++++++++++
 m4/fcntl_h.m4                |    2 +
 m4/openat.m4                 |   49 ++++++++++++++++++++++++++++-------------
 m4/sys_stat_h.m4             |    5 +--
 m4/unistd_h.m4               |    3 +-
 modules/fcntl-h              |    5 ++++
 modules/openat               |    7 ++++++
 modules/sys_stat             |    8 ++++++-
 modules/unistd               |    5 ++++
 17 files changed, 217 insertions(+), 69 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4eeb067..1a8aca6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2009-09-03  Eric Blake  <address@hidden>
+
+       openat: declare in POSIX headers
+       * NEWS: Mention this.
+       * modules/openat (configure.ac): Declare witnesses.
+       (Depends-on): Add fcntl-h, sys_stat, unistd.
+       (Include): Mention correct headers.
+       * modules/fcntl-h (Depends-on): Add link-warning.
+       (Files): Add openat.m4.
+       (Makefile.am): Substitute witnesses.
+       * modules/sys_stat (Files, Makefile.am): Likewise.
+       * modules/unistd (Files, Makefile.am): Likewise.
+       * m4/openat.m4 (gl_FUNC_OPENAT, gl_FUNC_FCHOWNAT): Set witnesses.
+       (gl_OPENAT_DEFAULTS): New macro.
+       * m4/fcntl_h.m4 (gl_FCNTL_H_DEFAULTS): Use it.
+       * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Likewise.
+       * m4/sys_stat_h.m4 (gl_SYS_STAT_H_DEFAULTS): Likewise.
+       (SYS_STAT_H): Remove unused variable.
+       * doc/posix-headers/fcntl.texi (fcntl.h): Update content.
+       * lib/fcntl--.h (includes): Remove unneeded header.
+       * lib/openat-safer.c (includes): Likewise.
+       * lib/openat.h (AT_FDCWD, AT_SYMLINK_NOFOLLOW, AT_REMOVEDIR)
+       (openat, fstatat, unlinkat, mkdirat, fchmodat, fchownat): Move to
+       appropriate headers.
+       (__OPENAT_PREFIX): Delete.
+       * lib/fcntl.in.h (openat): Provide declaration.
+       (AT_FDCWD): Fix Solaris bug.
+       (AT_SYMLINK_NOFOLLOW, AT_REMOVEDIR): Provide macros.
+       * lib/sys_stat.in.h (fstatat, mkdirat): Provide declaration.
+
 2009-09-02  Eric Blake  <address@hidden>

        errno: use consistently
diff --git a/NEWS b/NEWS
index 6a364a5..4cd0278 100644
--- a/NEWS
+++ b/NEWS
@@ -6,7 +6,15 @@ User visible incompatible changes

 Date        Modules         Changes

-2009-09-30  striconveh      The functions mem_cd_iconveh and str_cd_iconveh
+2009-09-03  openat          The include files are standardized to POSIX 2008.
+                            For openat, include <fcntl.h>; for
+                            fchmodat, fstatat, and mkdirat, include
+                            <sys/stat.h>; for fchownat and unlinkat,
+                            include <unistd.h>.  For all other
+                            functions provided by this module,
+                            continue to include "openat.h".
+
+2009-08-30  striconveh      The functions mem_cd_iconveh and str_cd_iconveh
                             now take an 'iconveh_t *' argument instead of three
                             iconv_t arguments.

diff --git a/doc/posix-headers/fcntl.texi b/doc/posix-headers/fcntl.texi
index 6e770a3..020586c 100644
--- a/doc/posix-headers/fcntl.texi
+++ b/doc/posix-headers/fcntl.texi
@@ -27,7 +27,13 @@ fcntl.h
 mingw

 @item
address@hidden and friends are provided by modules like openat.
address@hidden is defined with a value too large for an int on some
+platforms:
+Solaris 10
+
address@hidden
address@hidden, @samp{AT_SYMLINK_NOFOLLOW}, and @samp{AT_REMOVEDIR}
+are missing on some platforms.
 @end itemize

 Portability problems not fixed by Gnulib:
@@ -55,4 +61,7 @@ fcntl.h
 @samp{POSIX_FADV_NORMAL}, @samp{POSIX_FADV_RANDOM},
 @samp{POSIX_FADV_SEQUENTIAL}, and @samp{POSIX_FADV_WILLNEED} are not
 defined on some platforms.
+
address@hidden
address@hidden and @samp{AT_SYMLINK_FOLLOW} are missing on some platforms.
 @end itemize
diff --git a/lib/fcntl--.h b/lib/fcntl--.h
index 9e311ce..588b69a 100644
--- a/lib/fcntl--.h
+++ b/lib/fcntl--.h
@@ -27,7 +27,6 @@
 #define creat creat_safer

 #if GNULIB_OPENAT_SAFER
-# include "openat.h" /* FIXME - <fcntl.h> should be sufficient.  */
 # undef openat
 # define openat openat_safer
 #endif
diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h
index 5c63afd..6c88b47 100644
--- a/lib/fcntl.in.h
+++ b/lib/fcntl.in.h
@@ -44,6 +44,9 @@
 #define _GL_FCNTL_H


+/* The definition of GL_LINK_WARNING is copied here.  */
+
+
 /* Declare overridden functions.  */

 #ifdef __cplusplus
@@ -58,6 +61,20 @@ extern int open (const char *filename, int flags, ...);
 # endif
 #endif

+#if @GNULIB_OPENAT@
+# if address@hidden@
+#  undef openat
+#  define openat rpl_openat
+int openat (int fd, char const *file, int flags, /* mode_t mode */ ...);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef openat
+# define openat(f,u,g) \
+    (GL_LINK_WARNING ("openat is not portable - " \
+                      "use gnulib module openat for portability"), \
+     openat)
+#endif
+
 #ifdef __cplusplus
 }
 #endif
@@ -148,6 +165,33 @@ extern int open (const char *filename, int flags, ...);
 # define O_TEXT 0
 #endif

+/* Fix up the AT_* macros.  */
+
+/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive.  Its
+   value exceeds INT_MAX, so its use as an int doesn't conform to the
+   C standard, and GCC and Sun C complain in some cases.  If the bug
+   is present, undef AT_FDCWD here, so it can be redefined below.  */
+#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
+# undef AT_FDCWD
+#endif
+
+/* Use the same bit pattern as Solaris 9, but with the proper
+   signedness.  The bit pattern is important, in case this actually is
+   Solaris with the above workaround.  */
+#ifndef AT_FDCWD
+# define AT_FDCWD (-3041965)
+#endif
+
+/* Use the same values as Solaris 9.  This shouldn't matter, but
+   there's no real reason to differ.  */
+#ifndef AT_SYMLINK_NOFOLLOW
+# define AT_SYMLINK_NOFOLLOW 4096
+#endif
+
+#ifndef AT_REMOVEDIR
+# define AT_REMOVEDIR 1
+#endif
+

 #endif /* _GL_FCNTL_H */
 #endif /* _GL_FCNTL_H */
diff --git a/lib/openat-safer.c b/lib/openat-safer.c
index f6977fd..58d9a5e 100644
--- a/lib/openat-safer.c
+++ b/lib/openat-safer.c
@@ -22,7 +22,6 @@
 #include "fcntl-safer.h"

 #include <fcntl.h>
-#include "openat.h" /* FIXME - <fcntl.h> should be sufficient.  */
 #include <stdarg.h>
 #include "unistd-safer.h"

diff --git a/lib/openat.h b/lib/openat.h
index df52691..1d8596f 100644
--- a/lib/openat.h
+++ b/lib/openat.h
@@ -37,42 +37,10 @@
 # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
 #endif

-/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive.  Its
-   value exceeds INT_MAX, so its use as an int doesn't conform to the
-   C standard, and GCC and Sun C complain in some cases.  If the bug
-   is present, undef AT_FDCWD here, so it can be redefined below.  */
-#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
-# undef AT_FDCWD
-#endif
-
-/* Use the same bit pattern as Solaris 9, but with the proper
-   signedness.  The bit pattern is important, in case this actually is
-   Solaris with the above workaround.  */
-#ifndef AT_FDCWD
-# define AT_FDCWD (-3041965)
-#endif
-
-/* Use the same values as Solaris 9.  This shouldn't matter, but
-   there's no real reason to differ.  */
-#ifndef AT_SYMLINK_NOFOLLOW
-# define AT_SYMLINK_NOFOLLOW 4096
-# define AT_REMOVEDIR 1
-#endif
+#if !HAVE_OPENAT

-#ifdef __OPENAT_PREFIX
-
-# undef openat
-# define __OPENAT_CONCAT(x, y) x ## y
-# define __OPENAT_XCONCAT(x, y) __OPENAT_CONCAT (x, y)
-# define __OPENAT_ID(y) __OPENAT_XCONCAT (__OPENAT_PREFIX, y)
-# define openat __OPENAT_ID (openat)
-int openat (int fd, char const *file, int flags, /* mode_t mode */ ...);
 int openat_permissive (int fd, char const *file, int flags, mode_t mode,
                       int *cwd_errno);
-# define fstatat __OPENAT_ID (fstatat)
-int fstatat (int fd, char const *file, struct stat *st, int flag);
-# define unlinkat __OPENAT_ID (unlinkat)
-int unlinkat (int fd, char const *file, int flag);
 bool openat_needs_fchdir (void);

 #else
@@ -83,19 +51,8 @@ bool openat_needs_fchdir (void);

 #endif

-#if HAVE_OPENAT && ! LSTAT_FOLLOWS_SLASHED_SYMLINK
-int rpl_fstatat (int fd, char const *file, struct stat *st, int flag);
-# if !COMPILING_FSTATAT
-#  undef fstatat
-#  define fstatat rpl_fstatat
-# endif
-#endif
-
-int mkdirat (int fd, char const *file, mode_t mode);
 void openat_restore_fail (int) ATTRIBUTE_NORETURN;
 void openat_save_fail (int) ATTRIBUTE_NORETURN;
-int fchmodat (int fd, char const *file, mode_t mode, int flag);
-int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag);

 /* Using these function names makes application code
    slightly more readable than it would be with
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index b034168..2d89beb 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -302,6 +302,41 @@ extern int rpl_lstat (const char *name, struct stat *buf);
    lstat (p, b))
 #endif

+#if @GNULIB_OPENAT@
+# if @REPLACE_FSTATAT@
+#  undef fstatat
+#  define fstatat rpl_fstatat
+# endif
+# if address@hidden@ || @REPLACE_FSTATAT@
+int fstatat (int fd, char const *name, struct stat *st, int flags);
+# endif
+
+# if address@hidden@
+int fchmodat (int fd, char const *file, mode_t mode, int flag);
+# endif
+
+# if address@hidden@
+int mkdirat (int fd, char const *file, mode_t mode);
+#endif
+
+#elif defined GNULIB_POSIXCHECK
+# undef fchmodat
+# define fchmodat(d,n,m,f)                         \
+    (GL_LINK_WARNING ("fchmodat is not portable - " \
+                      "use gnulib module openat for portability"), \
+     fchmodat (d, n, m, f))
+# undef fstatat
+# define fstatat(d,n,s,f)                         \
+    (GL_LINK_WARNING ("fstatat is not portable - " \
+                      "use gnulib module openat for portability"), \
+     fstatat (d, n, s, f))
+# undef mkdirat
+# define mkdirat(d,n,m)                         \
+    (GL_LINK_WARNING ("mkdirat is not portable - " \
+                      "use gnulib module openat for portability"), \
+     mkdirat (d, n, m))
+#endif /* @GNULIB_OPENAT@ */
+
 #if @REPLACE_FCHDIR@
 # define fstat rpl_fstat
 extern int fstat (int fd, struct stat *buf);
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index fe645b7..e6db70b 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -138,6 +138,31 @@ extern int chown (const char *file, uid_t uid, gid_t gid);
 #endif


+#if @GNULIB_OPENAT@
+# if @REPLACE_FCHOWNAT@
+#  undef fchownat
+#  define fchownat rpl_fchownat
+# endif
+# if address@hidden@ || @REPLACE_FCHOWNAT@
+int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag);
+# endif
+# if address@hidden@
+int unlinkat (int fd, char const *file, int flag);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef fchownat
+# define fchownat(d,n,o,g,f)                       \
+    (GL_LINK_WARNING ("fchownat is not portable - " \
+                      "use gnulib module openat for portability"), \
+     fchownat (d, n, o, g, f))
+# undef unlinkat
+# define unlinkat(d,n,f)                         \
+    (GL_LINK_WARNING ("unlinkat is not portable - " \
+                      "use gnulib module openat for portability"), \
+     unlinkat (d, n, f))
+#endif /* @GNULIB_OPENAT@ */
+
+
 #if @GNULIB_CLOSE@
 # if @REPLACE_CLOSE@
 /* Automatically included by modules that need a replacement for close.  */
diff --git a/m4/fcntl_h.m4 b/m4/fcntl_h.m4
index 1ae0b15..fdea01f 100644
--- a/m4/fcntl_h.m4
+++ b/m4/fcntl_h.m4
@@ -1,3 +1,4 @@
+# serial 2
 # Configure fcntl.h.
 dnl Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
@@ -90,6 +91,7 @@ AC_DEFUN([gl_FCNTL_MODULE_INDICATOR],

 AC_DEFUN([gl_FCNTL_H_DEFAULTS],
 [
+  AC_REQUIRE([gl_OPENAT_DEFAULTS]) dnl for GNULIB_OPENAT
   GNULIB_OPEN=0;  AC_SUBST([GNULIB_OPEN])
   dnl Assume proper GNU behavior unless another module says otherwise.
   REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN])
diff --git a/m4/openat.m4 b/m4/openat.m4
index c8403a1..51f38d0 100644
--- a/m4/openat.m4
+++ b/m4/openat.m4
@@ -1,4 +1,4 @@
-# serial 19
+# serial 20
 # See if we need to use our replacement for Solaris' openat et al functions.

 dnl Copyright (C) 2004-2009 Free Software Foundation, Inc.
@@ -17,13 +17,24 @@ AC_DEFUN([gl_FUNC_OPENAT],
   AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
   case $ac_cv_func_openat+$ac_cv_func_lstat_dereferences_slashed_symlink in
   yes+yes) ;;
-  yes+*) AC_LIBOBJ([fstatat]);;
+  yes+*)
+    AC_LIBOBJ([fstatat])
+    REPLACE_FSTATAT=1
+    ;;
   *)
-    AC_DEFINE([__OPENAT_PREFIX], [[rpl_]],
-      [Define to rpl_ if the openat replacement function should be used.])
+    HAVE_OPENAT=0
+    HAVE_UNLINKAT=0 # No known system with unlinkat but not openat
+    HAVE_FSTATAT=0 # No known system with fstatat but not openat
     gl_PREREQ_OPENAT;;
   esac
+  if test $ac_cv_func_fchmodat != yes; then
+    HAVE_FCHMODAT=0
+  fi
+  if test $ac_cv_func_mkdirat != yes; then
+    HAVE_MKDIRAT=0
+  fi
   gl_FUNC_FCHOWNAT
+  GNULIB_OPENAT=1
 ])

 # gl_FUNC_FCHOWNAT_DEREF_BUG([ACTION-IF-BUGGY[, ACTION-IF-NOT_BUGGY]])
@@ -68,19 +79,11 @@ main ()
 # Also use the replacement function if fchownat is simply not available.
 AC_DEFUN([gl_FUNC_FCHOWNAT],
 [
-  # Assume we'll use the replacement function.
-  # The only case in which we won't is when we have fchownat, and it works.
-  use_replacement_fchownat=yes
-
-  AC_CHECK_FUNC([fchownat], [have_fchownat=yes], [have_fchownat=no])
-  if test $have_fchownat = yes; then
-    gl_FUNC_FCHOWNAT_DEREF_BUG([], [use_replacement_fchownat=no])
-  fi
-
-  if test $use_replacement_fchownat = yes; then
+  AC_CHECK_FUNC([fchownat],
+    [gl_FUNC_FCHOWNAT_DEREF_BUG([REPLACE_FCHOWNAT=1])],
+    [HAVE_FCHOWNAT=0])
+  if test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1; then
     AC_LIBOBJ([fchownat])
-    AC_DEFINE([fchownat], [rpl_fchownat],
-      [Define to rpl_fchownat if the replacement function should be used.])
   fi
 ])

@@ -89,3 +92,17 @@ AC_DEFUN([gl_PREREQ_OPENAT],
   AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T])
   :
 ])
+
+AC_DEFUN([gl_OPENAT_DEFAULTS],
+[
+  GNULIB_OPENAT=0;            AC_SUBST([GNULIB_OPENAT])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_FCHMODAT=1;            AC_SUBST([HAVE_FCHMODAT])
+  HAVE_FCHOWNAT=1;            AC_SUBST([HAVE_FCHOWNAT])
+  HAVE_FSTATAT=1;             AC_SUBST([HAVE_FSTATAT])
+  HAVE_MKDIRAT=1;             AC_SUBST([HAVE_MKDIRAT])
+  HAVE_OPENAT=1;              AC_SUBST([HAVE_OPENAT])
+  HAVE_UNLINKAT=1;            AC_SUBST([HAVE_UNLINKAT])
+  REPLACE_FCHOWNAT=0;         AC_SUBST([REPLACE_FCHOWNAT])
+  REPLACE_FSTATAT=0;          AC_SUBST([REPLACE_FSTATAT])
+])
diff --git a/m4/sys_stat_h.m4 b/m4/sys_stat_h.m4
index 5113e55..634a33f 100644
--- a/m4/sys_stat_h.m4
+++ b/m4/sys_stat_h.m4
@@ -1,4 +1,4 @@
-# sys_stat_h.m4 serial 11   -*- Autoconf -*-
+# sys_stat_h.m4 serial 12   -*- Autoconf -*-
 dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -28,8 +28,6 @@ AC_DEFUN([gl_HEADER_SYS_STAT_H],
   AC_REQUIRE([AC_HEADER_STAT])

   gl_CHECK_NEXT_HEADERS([sys/stat.h])
-  SYS_STAT_H='sys/stat.h'
-  AC_SUBST([SYS_STAT_H])

   dnl Define types that are supposed to be defined in <sys/types.h> or
   dnl <sys/stat.h>.
@@ -51,6 +49,7 @@ AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR],
 AC_DEFUN([gl_SYS_STAT_H_DEFAULTS],
 [
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl for REPLACE_FCHDIR
+  AC_REQUIRE([gl_OPENAT_DEFAULTS]) dnl for GNULIB_OPENAT
   GNULIB_LCHMOD=0; AC_SUBST([GNULIB_LCHMOD])
   GNULIB_LSTAT=0;  AC_SUBST([GNULIB_LSTAT])
   dnl Assume proper GNU behavior unless another module says otherwise.
diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4
index 53fc330..c8e93da 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 21
+# unistd_h.m4 serial 22
 dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -32,6 +32,7 @@ AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],

 AC_DEFUN([gl_UNISTD_H_DEFAULTS],
 [
+  AC_REQUIRE([gl_OPENAT_DEFAULTS]) dnl for GNULIB_OPENAT
   GNULIB_CHOWN=0;            AC_SUBST([GNULIB_CHOWN])
   GNULIB_CLOSE=0;            AC_SUBST([GNULIB_CLOSE])
   GNULIB_DUP2=0;             AC_SUBST([GNULIB_DUP2])
diff --git a/modules/fcntl-h b/modules/fcntl-h
index 8e2af03..d86f572 100644
--- a/modules/fcntl-h
+++ b/modules/fcntl-h
@@ -4,9 +4,11 @@ Like <fcntl.h>, but with non-working flags defined to 0.
 Files:
 lib/fcntl.in.h
 m4/fcntl_h.m4
+m4/openat.m4

 Depends-on:
 include_next
+link-warning
 unistd
 extensions

@@ -25,7 +27,10 @@ fcntl.h: fcntl.in.h
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
              -e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \
              -e 's|@''GNULIB_OPEN''@|$(GNULIB_OPEN)|g' \
+             -e 's|@''GNULIB_OPENAT''@|$(GNULIB_OPENAT)|g' \
              -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \
+             -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \
+             -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
              < $(srcdir)/fcntl.in.h; \
        } > address@hidden && \
        mv address@hidden $@
diff --git a/modules/openat b/modules/openat
index 3ea5b4d..e1dda71 100644
--- a/modules/openat
+++ b/modules/openat
@@ -19,6 +19,7 @@ dirname
 errno
 extensions
 fchdir
+fcntl-h
 fdopendir
 gettext-h
 intprops
@@ -29,13 +30,19 @@ rmdir
 same-inode
 save-cwd
 stdbool
+sys_stat
+unistd

 configure.ac:
 gl_FUNC_OPENAT
+gl_MODULE_INDICATOR([openat])

 Makefile.am:

 Include:
+<fcntl.h>
+<sys/stat.h>
+<unistd.h>
 "openat.h"

 License:
diff --git a/modules/sys_stat b/modules/sys_stat
index 40f1c18..bad77be 100644
--- a/modules/sys_stat
+++ b/modules/sys_stat
@@ -4,6 +4,7 @@ A <sys/stat.h> for systems with missing declarations.
 Files:
 lib/sys_stat.in.h
 m4/sys_stat_h.m4
+m4/openat.m4
 m4/unistd_h.m4

 Depends-on:
@@ -15,7 +16,7 @@ gl_HEADER_SYS_STAT_H
 AC_PROG_MKDIR_P

 Makefile.am:
-BUILT_SOURCES += $(SYS_STAT_H)
+BUILT_SOURCES += sys/stat.h

 # We need the following in order to create <sys/stat.h> when the system
 # has one that is incomplete.
@@ -28,11 +29,16 @@ sys/stat.h: sys_stat.in.h
              -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
              -e 's|@''GNULIB_LCHMOD''@|$(GNULIB_LCHMOD)|g' \
              -e 's|@''GNULIB_LSTAT''@|$(GNULIB_LSTAT)|g' \
+             -e 's|@''GNULIB_OPENAT''@|$(GNULIB_OPENAT)|g' \
+             -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \
+             -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \
              -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
              -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
+             -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \
              -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
              -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
              -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
+             -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
              -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
              < $(srcdir)/sys_stat.in.h; \
        } > address@hidden && \
diff --git a/modules/unistd b/modules/unistd
index 66fc1a3..4c5add7 100644
--- a/modules/unistd
+++ b/modules/unistd
@@ -4,6 +4,7 @@ A GNU-like <unistd.h>.
 Files:
 m4/unistd_h.m4
 lib/unistd.in.h
+m4/openat.m4

 Depends-on:
 include_next
@@ -44,6 +45,7 @@ unistd.h: unistd.in.h
              -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \
              -e 's|@''GNULIB_LINK''@|$(GNULIB_LINK)|g' \
              -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \
+             -e 's|@''GNULIB_OPENAT''@|$(GNULIB_OPENAT)|g' \
              -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \
              -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
              -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \
@@ -53,6 +55,7 @@ unistd.h: unistd.in.h
              -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
              -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \
              -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \
+             -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \
              -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \
              -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
              -e 's|@''HAVE_GETDOMAINNAME''@|$(HAVE_GETDOMAINNAME)|g' \
@@ -64,6 +67,7 @@ unistd.h: unistd.in.h
              -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \
              -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
              -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
+             -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \
              -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
              -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
              -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
@@ -72,6 +76,7 @@ unistd.h: unistd.in.h
              -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
              -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
              -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
+             -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
              -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
              -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
              -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
-- 
1.6.3.3.334.g916e1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]