* 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 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
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
-# 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,
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
-# 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,
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])
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
])
-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' \