[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: make openat declarations consistent
From: |
Bruno Haible |
Subject: |
Re: make openat declarations consistent |
Date: |
Sun, 6 Sep 2009 23:14:13 +0200 |
User-agent: |
KMail/1.9.9 |
Eric Blake wrote:
> --- 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
So every package that needs <unistd.h> now needs to include a file named
openat.m4? It we had gone this route, the generation of <unistd.h> would
now depend on chown.m4, close.m4, dup2.m4, dup3.m4, fsync.m4,
getdtablesize.m4 etc. etc. up until sleep.m4.
No, really, all macros needed for constructing the <unistd.h> replacement
are supposed to sit in m4/unistd_h.m4.
Instead of calling out from unistd_h.m4 to openat.m4, it's better to call
out from openat.m4 to unistd_h.m4, like we have done for years. Here is the
proposed patch.
Additionally, this patch fixes a bug: gl_FUNC_OPENAT did not AC_REQUIRE
gl_OPENAT_DEFAULTS. So it could happen that gl_FUNC_OPENAT gets expanded
before gl_UNISTD_H_DEFAULTS, and then the variable GNULIB_OPENAT would have
the value 0 instead of 1.
Another plus is that it separates the blocks for different functions in
unistd.in.h and sys_stat.in.h, for legibility.
OK to apply?
2009-09-06 Bruno Haible <address@hidden>
* lib/sys_stat.in.h (fchmodat): Declare if GNULIB_FCHMODAT is set.
(fstatat): Declare if GNULIB_FSTATAT is set.
(mkdirat): Declare if GNULIB_MKDIRAT is set.
* lib/unistd.in.h (fchownat): Declare if GNULIB_FCHOWNAT is set.
(unlinkat): Declare if GNULIB_UNLINKAT is set.
* modules/fcntl-h (Files): Remove m4/openat.m4.
* modules/sys_stat (Files): Remove m4/openat.m4.
(Makefile.am): Substitute GNULIB_FCHMODAT, GNULIB_FSTATAT,
GNULIB_MKDIRAT instead of GNULIB_OPENAT.
* modules/unistd (Files): Remove m4/openat.m4.
(Makefile.am): Substitute GNULIB_FCHOWNAT, GNULIB_UNLINKAT instead of
GNULIB_OPENAT.
* m4/fcntl_h.m4 (gl_FCNTL_H_DEFAULTS): Initialize GNULIB_OPENAT,
HAVE_OPENAT here. Don't require gl_OPENAT_DEFAULTS.
* m4/sys_stat_h.m4 (gl_SYS_STAT_H_DEFAULTS): Initialize
GNULIB_FCHMODAT, GNULIB_FSTATAT, GNULIB_MKDIRAT, HAVE_FCHMODAT,
HAVE_FSTATAT, HAVE_MKDIRAT, REPLACE_FSTATAT here. Don't require
gl_OPENAT_DEFAULTS.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize GNULIB_FCHOWNAT,
GNULIB_UNLINKAT, HAVE_FCHOWNAT, HAVE_UNLINKAT, REPLACE_FCHOWNAT here.
Don't require gl_OPENAT_DEFAULTS.
* m4/openat.m4 (gl_FUNC_OPENAT): Require gl_FCNTL_H_DEFAULTS,
gl_SYS_STAT_H_DEFAULTS, gl_UNISTD_H_DEFAULTS. Set GNULIB_FCHMODAT,
GNULIB_FSTATAT, GNULIB_MKDIRAT, GNULIB_FCHOWNAT, GNULIB_UNLINKAT.
(gl_OPENAT_DEFAULTS): Remove macro.
--- lib/sys_stat.in.h.orig 2009-09-06 22:24:24.000000000 +0200
+++ lib/sys_stat.in.h 2009-09-06 22:09:29.000000000 +0200
@@ -302,40 +302,49 @@
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 @GNULIB_FCHMODAT@
# 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);
+extern int fchmodat (int fd, char const *file, mode_t mode, int flag);
# 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))
+#endif
+
+
+#if @GNULIB_FSTATAT@
+# if @REPLACE_FSTATAT@
+# undef fstatat
+# define fstatat rpl_fstatat
+# endif
+# if address@hidden@ || @REPLACE_FSTATAT@
+extern int fstatat (int fd, char const *name, struct stat *st, int flags);
+# endif
+#elif defined GNULIB_POSIXCHECK
# 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))
+#endif
+
+
+#if @GNULIB_MKDIRAT@
+# if address@hidden@
+extern int mkdirat (int fd, char const *file, mode_t mode);
+# endif
+#elif defined GNULIB_POSIXCHECK
# 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@ */
+#endif
+
#if @REPLACE_FCHDIR@
# define fstat rpl_fstat
--- lib/unistd.in.h.orig 2009-09-06 22:24:24.000000000 +0200
+++ lib/unistd.in.h 2009-09-06 22:07:14.000000000 +0200
@@ -147,16 +147,13 @@
#endif
-#if @GNULIB_OPENAT@
+#if @GNULIB_FCHOWNAT@
# 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);
+extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int
flag);
# endif
#elif defined GNULIB_POSIXCHECK
# undef fchownat
@@ -164,12 +161,20 @@
(GL_LINK_WARNING ("fchownat is not portable - " \
"use gnulib module openat for portability"), \
fchownat (d, n, o, g, f))
+#endif
+
+
+#if @GNULIB_UNLINKAT@
+# if address@hidden@
+extern int unlinkat (int fd, char const *file, int flag);
+# endif
+#elif defined GNULIB_POSIXCHECK
# 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@ */
+#endif
#if @GNULIB_FACCESSAT@
--- modules/fcntl-h.orig 2009-09-06 22:24:24.000000000 +0200
+++ modules/fcntl-h 2009-09-06 21:55:40.000000000 +0200
@@ -4,7 +4,6 @@
Files:
lib/fcntl.in.h
m4/fcntl_h.m4
-m4/openat.m4
Depends-on:
include_next
--- modules/sys_stat.orig 2009-09-06 22:24:24.000000000 +0200
+++ modules/sys_stat 2009-09-06 21:59:02.000000000 +0200
@@ -4,7 +4,6 @@
Files:
lib/sys_stat.in.h
m4/sys_stat_h.m4
-m4/openat.m4
m4/unistd_h.m4
Depends-on:
@@ -27,9 +26,11 @@
sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
+ -e 's|@''GNULIB_FCHMODAT''@|$(GNULIB_FCHMODAT)|g' \
+ -e 's|@''GNULIB_FSTATAT''@|$(GNULIB_FSTATAT)|g' \
-e 's|@''GNULIB_LCHMOD''@|$(GNULIB_LCHMOD)|g' \
-e 's|@''GNULIB_LSTAT''@|$(GNULIB_LSTAT)|g' \
- -e 's|@''GNULIB_OPENAT''@|$(GNULIB_OPENAT)|g' \
+ -e 's|@''GNULIB_MKDIRAT''@|$(GNULIB_MKDIRAT)|g' \
-e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \
-e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \
-e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
--- modules/unistd.orig 2009-09-06 22:24:24.000000000 +0200
+++ modules/unistd 2009-09-06 22:13:38.000000000 +0200
@@ -4,7 +4,6 @@
Files:
m4/unistd_h.m4
lib/unistd.in.h
-m4/openat.m4
Depends-on:
include_next
@@ -34,6 +33,7 @@
-e 's|@''GNULIB_EUIDACCESS''@|$(GNULIB_EUIDACCESS)|g' \
-e 's|@''GNULIB_FACCESSAT''@|$(GNULIB_FACCESSAT)|g' \
-e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \
+ -e 's|@''GNULIB_FCHOWNAT''@|$(GNULIB_FCHOWNAT)|g' \
-e 's|@''GNULIB_FSYNC''@|$(GNULIB_FSYNC)|g' \
-e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \
-e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \
@@ -46,13 +46,13 @@
-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' \
-e 's|@''GNULIB_SYMLINKAT''@|$(GNULIB_SYMLINKAT)|g' \
-e 's|@''GNULIB_UNISTD_H_GETOPT''@|$(GNULIB_UNISTD_H_GETOPT)|g' \
-e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g'
\
+ -e 's|@''GNULIB_UNLINKAT''@|$(GNULIB_UNLINKAT)|g' \
-e 's|@''GNULIB_WRITE''@|$(GNULIB_WRITE)|g' \
-e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
-e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \
--- m4/fcntl_h.m4.orig 2009-09-06 22:24:24.000000000 +0200
+++ m4/fcntl_h.m4 2009-09-06 22:11:37.000000000 +0200
@@ -1,4 +1,4 @@
-# serial 2
+# serial 3
# Configure fcntl.h.
dnl Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
@@ -91,8 +91,9 @@
AC_DEFUN([gl_FCNTL_H_DEFAULTS],
[
- AC_REQUIRE([gl_OPENAT_DEFAULTS]) dnl for GNULIB_OPENAT
- GNULIB_OPEN=0; AC_SUBST([GNULIB_OPEN])
+ GNULIB_OPEN=0; AC_SUBST([GNULIB_OPEN])
+ GNULIB_OPENAT=0; AC_SUBST([GNULIB_OPENAT])
dnl Assume proper GNU behavior unless another module says otherwise.
+ HAVE_OPENAT=1; AC_SUBST([HAVE_OPENAT])
REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN])
])
--- m4/sys_stat_h.m4.orig 2009-09-06 22:24:24.000000000 +0200
+++ m4/sys_stat_h.m4 2009-09-06 22:01:25.000000000 +0200
@@ -1,4 +1,4 @@
-# sys_stat_h.m4 serial 12 -*- Autoconf -*-
+# sys_stat_h.m4 serial 13 -*- 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,
@@ -49,11 +49,17 @@
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])
+ GNULIB_FCHMODAT=0; AC_SUBST([GNULIB_FCHMODAT])
+ GNULIB_FSTATAT=0; AC_SUBST([GNULIB_FSTATAT])
+ GNULIB_LCHMOD=0; AC_SUBST([GNULIB_LCHMOD])
+ GNULIB_LSTAT=0; AC_SUBST([GNULIB_LSTAT])
+ GNULIB_MKDIRAT=0; AC_SUBST([GNULIB_MKDIRAT])
dnl Assume proper GNU behavior unless another module says otherwise.
- HAVE_LCHMOD=1; AC_SUBST([HAVE_LCHMOD])
- REPLACE_LSTAT=0; AC_SUBST([REPLACE_LSTAT])
- REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR])
+ HAVE_FCHMODAT=1; AC_SUBST([HAVE_FCHMODAT])
+ HAVE_FSTATAT=1; AC_SUBST([HAVE_FSTATAT])
+ HAVE_LCHMOD=1; AC_SUBST([HAVE_LCHMOD])
+ HAVE_MKDIRAT=1; AC_SUBST([HAVE_MKDIRAT])
+ REPLACE_FSTATAT=0; AC_SUBST([REPLACE_FSTATAT])
+ REPLACE_LSTAT=0; AC_SUBST([REPLACE_LSTAT])
+ REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR])
])
--- m4/unistd_h.m4.orig 2009-09-06 22:24:24.000000000 +0200
+++ m4/unistd_h.m4 2009-09-06 22:03:51.000000000 +0200
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 22
+# unistd_h.m4 serial 23
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,7 +32,6 @@
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])
@@ -41,6 +40,7 @@
GNULIB_EUIDACCESS=0; AC_SUBST([GNULIB_EUIDACCESS])
GNULIB_FACCESSAT=0; AC_SUBST([GNULIB_FACCESSAT])
GNULIB_FCHDIR=0; AC_SUBST([GNULIB_FCHDIR])
+ GNULIB_FCHOWNAT=0; AC_SUBST([GNULIB_FCHOWNAT])
GNULIB_FSYNC=0; AC_SUBST([GNULIB_FSYNC])
GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE])
GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD])
@@ -59,12 +59,14 @@
GNULIB_SYMLINKAT=0; AC_SUBST([GNULIB_SYMLINKAT])
GNULIB_UNISTD_H_GETOPT=0; AC_SUBST([GNULIB_UNISTD_H_GETOPT])
GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
+ GNULIB_UNLINKAT=0; AC_SUBST([GNULIB_UNLINKAT])
GNULIB_WRITE=0; AC_SUBST([GNULIB_WRITE])
dnl Assume proper GNU behavior unless another module says otherwise.
HAVE_DUP2=1; AC_SUBST([HAVE_DUP2])
HAVE_DUP3=1; AC_SUBST([HAVE_DUP3])
HAVE_EUIDACCESS=1; AC_SUBST([HAVE_EUIDACCESS])
HAVE_FACCESSAT=1; AC_SUBST([HAVE_FACCESSAT])
+ HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT])
HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC])
HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE])
HAVE_GETDOMAINNAME=1; AC_SUBST([HAVE_GETDOMAINNAME])
@@ -82,10 +84,12 @@
HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
HAVE_OS_H=0; AC_SUBST([HAVE_OS_H])
HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H])
+ HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT])
REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN])
REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE])
REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2])
REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR])
+ REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT])
REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE])
REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN])
--- m4/openat.m4.orig 2009-09-06 22:24:24.000000000 +0200
+++ m4/openat.m4 2009-09-06 22:12:16.000000000 +0200
@@ -1,4 +1,4 @@
-# serial 20
+# serial 21
# See if we need to use our replacement for Solaris' openat et al functions.
dnl Copyright (C) 2004-2009 Free Software Foundation, Inc.
@@ -10,6 +10,18 @@
AC_DEFUN([gl_FUNC_OPENAT],
[
+ AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
+ GNULIB_OPENAT=1
+
+ AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
+ GNULIB_FCHMODAT=1
+ GNULIB_FSTATAT=1
+ GNULIB_MKDIRAT=1
+
+ AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+ GNULIB_FCHOWNAT=1
+ GNULIB_UNLINKAT=1
+
AC_LIBOBJ([openat-proc])
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
AC_CHECK_FUNCS_ONCE([lchmod])
@@ -34,7 +46,6 @@
HAVE_MKDIRAT=0
fi
gl_FUNC_FCHOWNAT
- GNULIB_OPENAT=1
])
# gl_FUNC_FCHOWNAT_DEREF_BUG([ACTION-IF-BUGGY[, ACTION-IF-NOT_BUGGY]])
@@ -92,17 +103,3 @@
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])
-])