]> Savannah Git Hosting - gnulib.git/commitdiff
fchdir: Override properly on OS/2 kLIBC.
authorBruno Haible <bruno@clisp.org>
Fri, 29 Sep 2023 08:46:15 +0000 (10:46 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 29 Sep 2023 08:46:15 +0000 (10:46 +0200)
* lib/unistd.in.h (fchdir): Override if REPLACE_FCHDIR is 1.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_FCHDIR.
* modules/unistd (Makefile.am): Substitute REPLACE_FCHDIR.
* modules/fchdir (Depends-on, configure.ac): Test REPLACE_FCHDIR.
* m4/fchdir.m4 (gl_FUNC_FCHDIR): Instead of setting HAVE_FCHDIR to 0,
set REPLACE_FCHDIR to 1.

ChangeLog
lib/unistd.in.h
m4/fchdir.m4
m4/unistd_h.m4
modules/fchdir
modules/unistd

index f84e227f0b40918453a5604bd5be45360f7a3c1a..29e704fc9d55e6770f0e46c5d53729e64ec6350a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-09-29  Bruno Haible  <bruno@clisp.org>
+
+       fchdir: Override properly on OS/2 kLIBC.
+       * lib/unistd.in.h (fchdir): Override if REPLACE_FCHDIR is 1.
+       * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_FCHDIR.
+       * modules/unistd (Makefile.am): Substitute REPLACE_FCHDIR.
+       * modules/fchdir (Depends-on, configure.ac): Test REPLACE_FCHDIR.
+       * m4/fchdir.m4 (gl_FUNC_FCHDIR): Instead of setting HAVE_FCHDIR to 0,
+       set REPLACE_FCHDIR to 1.
+
 2023-09-29  KO Myung-Hun  <komh78@gmail.com>
 
        fdopendir: Use Windows code path on OS/2 kLIBC
index 2ae040a76b3e2a68d413ca1bf15fc3ae889d606a..ac9f50eb3e5ad800e4fb0fc34d12c88626dd0a62 100644 (file)
@@ -971,23 +971,28 @@ _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
    Return 0 if successful, otherwise -1 and errno set.
    See the POSIX:2008 specification
    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>.  */
-# if ! @HAVE_FCHDIR@
+# if @REPLACE_FCHDIR@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef fchdir
+#   define fchdir rpl_fchdir
+#  endif
+_GL_FUNCDECL_RPL (fchdir, int, (int /*fd*/));
+_GL_CXXALIAS_RPL (fchdir, int, (int /*fd*/));
+# else
+#  if !@HAVE_FCHDIR@ || !@HAVE_DECL_FCHDIR@
 _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
-
+#  endif
+_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
+# endif
+_GL_CXXALIASWARN (fchdir);
+# if @REPLACE_FCHDIR@ || !@HAVE_FCHDIR@
 /* Gnulib internal hooks needed to maintain the fchdir metadata.  */
 _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
      _GL_ARG_NONNULL ((2));
 _GL_EXTERN_C void _gl_unregister_fd (int fd);
 _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
 _GL_EXTERN_C const char *_gl_directory_name (int fd);
-
-# else
-#  if !@HAVE_DECL_FCHDIR@
-_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
-#  endif
 # endif
-_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
-_GL_CXXALIASWARN (fchdir);
 #elif defined GNULIB_POSIXCHECK
 # undef fchdir
 # if HAVE_RAW_DECL_FCHDIR
index 49d37b5641811285b6007c8f78bce778802c51b4..ff92ceca2eed5713ee993da8d9bcd2793f7a4a3e 100644 (file)
@@ -1,4 +1,4 @@
-# fchdir.m4 serial 30
+# fchdir.m4 serial 31
 dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -20,7 +20,7 @@ AC_DEFUN([gl_FUNC_FCHDIR],
     AC_REQUIRE([gl_DIRENT_DIR])
     if test $DIR_HAS_FD_MEMBER = 0; then
       dnl fchdir() should be replaced if dirfd() does not work.
-      HAVE_FCHDIR=0
+      REPLACE_FCHDIR=1
     fi
   fi
 
index 1c96158155a78415643ab0342857a0b2d10851f0..8fa0fa3255d6e72f704368272274ee0ed4c82983 100644 (file)
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 94
+# unistd_h.m4 serial 95
 dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -234,6 +234,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   REPLACE_EXECVP=0;                  AC_SUBST([REPLACE_EXECVP])
   REPLACE_EXECVPE=0;                 AC_SUBST([REPLACE_EXECVPE])
   REPLACE_FACCESSAT=0;               AC_SUBST([REPLACE_FACCESSAT])
+  REPLACE_FCHDIR=0;                  AC_SUBST([REPLACE_FCHDIR])
   REPLACE_FCHOWNAT=0;                AC_SUBST([REPLACE_FCHOWNAT])
   REPLACE_FDATASYNC=0;               AC_SUBST([REPLACE_FDATASYNC])
   REPLACE_FTRUNCATE=0;               AC_SUBST([REPLACE_FTRUNCATE])
index 847624a54828b044e16a5793c7893c391ac66833..084806941be368cc6c9709b7a3d98a5fe23b82b8 100644 (file)
@@ -8,29 +8,30 @@ m4/fchdir.m4
 Depends-on:
 dirent
 unistd
-assure           [test $HAVE_FCHDIR = 0]
-chdir            [test $HAVE_FCHDIR = 0]
-close            [test $HAVE_FCHDIR = 0]
-dirfd            [test $HAVE_FCHDIR = 0]
-dup2             [test $HAVE_FCHDIR = 0]
-fcntl            [test $HAVE_FCHDIR = 0]
-fcntl-h          [test $HAVE_FCHDIR = 0]
-filename         [test $HAVE_FCHDIR = 0]
-filenamecat-lgpl [test $HAVE_FCHDIR = 0]
-free-posix       [test $HAVE_FCHDIR = 0]
-fstat            [test $HAVE_FCHDIR = 0]
-getcwd-lgpl      [test $HAVE_FCHDIR = 0]
-malloc-posix     [test $HAVE_FCHDIR = 0]
-open             [test $HAVE_FCHDIR = 0]
-realloc-posix    [test $HAVE_FCHDIR = 0]
-stat             [test $HAVE_FCHDIR = 0]
-stdbool          [test $HAVE_FCHDIR = 0]
-strdup-posix     [test $HAVE_FCHDIR = 0]
-sys_stat         [test $HAVE_FCHDIR = 0]
+assure           [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]
+chdir            [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]
+close            [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]
+dirfd            [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]
+dup2             [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]
+fcntl            [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]
+fcntl-h          [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]
+filename         [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]
+filenamecat-lgpl [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]
+free-posix       [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]
+fstat            [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]
+getcwd-lgpl      [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]
+malloc-posix     [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]
+open             [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]
+realloc-posix    [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]
+stat             [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]
+stdbool          [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]
+strdup-posix     [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]
+sys_stat         [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1]
 
 configure.ac:
 gl_FUNC_FCHDIR
-gl_CONDITIONAL([GL_COND_OBJ_FCHDIR], [test $HAVE_FCHDIR = 0])
+gl_CONDITIONAL([GL_COND_OBJ_FCHDIR],
+               [test $HAVE_FCHDIR = 0 || test $REPLACE_FCHDIR = 1])
 AM_COND_IF([GL_COND_OBJ_FCHDIR], [
   gl_PREREQ_FCHDIR
 ])
index f244b0dd9a548f5d419a87bb24f64ea0d59b847c..ce2ee04edc9181a4da54bfe6cd5b7fcdccefe2e9 100644 (file)
@@ -192,6 +192,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's|@''REPLACE_EXECVP''@|$(REPLACE_EXECVP)|g' \
              -e 's|@''REPLACE_EXECVPE''@|$(REPLACE_EXECVPE)|g' \
              -e 's|@''REPLACE_FACCESSAT''@|$(REPLACE_FACCESSAT)|g' \
+             -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
              -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
              -e 's|@''REPLACE_FDATASYNC''@|$(REPLACE_FDATASYNC)|g' \
              -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \