diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2015-03-19 12:32:42 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2015-03-19 12:33:44 -0700 |
commit | ccf00107f7aa8897cde017bec3717ecc350515f7 (patch) | |
tree | f92f5f4c4a8f61f8f1f73a3ebb61304b409471ec /m4 | |
parent | 8aa13d07fe72b8a00ded10602f5c5ce773181b40 (diff) |
Merge from gnulib
This incorporates:
2015-03-19 fdopendir: port better to MinGW
2015-03-18 fdopendir: fix typo in comment
2015-02-24 glob, etc.: port to MSVC v18 on MS-Windows 8.1
* lib/dirent.in.h, lib/fdopendir.c: Update from gnulib.
* lib/dirfd.c, m4/dirfd.m4: New files from gnulib.
* lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate.
Diffstat (limited to 'm4')
-rw-r--r-- | m4/dirfd.m4 | 83 | ||||
-rw-r--r-- | m4/gnulib-comp.m4 | 20 |
2 files changed, 103 insertions, 0 deletions
diff --git a/m4/dirfd.m4 b/m4/dirfd.m4 new file mode 100644 index 0000000000..ce56cff691 --- /dev/null +++ b/m4/dirfd.m4 @@ -0,0 +1,83 @@ +# serial 22 -*- Autoconf -*- + +dnl Find out how to get the file descriptor associated with an open DIR*. + +# Copyright (C) 2001-2006, 2008-2015 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +dnl From Jim Meyering + +AC_DEFUN([gl_FUNC_DIRFD], +[ + AC_REQUIRE([gl_DIRENT_H_DEFAULTS]) + + dnl Persuade glibc <dirent.h> to declare dirfd(). + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + + AC_CHECK_FUNCS([dirfd]) + AC_CHECK_DECLS([dirfd], , , + [[#include <sys/types.h> + #include <dirent.h>]]) + if test $ac_cv_have_decl_dirfd = no; then + HAVE_DECL_DIRFD=0 + fi + + AC_CACHE_CHECK([whether dirfd is a macro], + gl_cv_func_dirfd_macro, + [AC_EGREP_CPP([dirent_header_defines_dirfd], [ +#include <sys/types.h> +#include <dirent.h> +#ifdef dirfd + dirent_header_defines_dirfd +#endif], + gl_cv_func_dirfd_macro=yes, + gl_cv_func_dirfd_macro=no)]) + + # Use the replacement only if we have no function or macro with that name. + if test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no; then + if test $ac_cv_have_decl_dirfd = yes; then + # If the system declares dirfd already, let's declare rpl_dirfd instead. + REPLACE_DIRFD=1 + fi + fi +]) + +dnl Prerequisites of lib/dirfd.c. +AC_DEFUN([gl_PREREQ_DIRFD], +[ + AC_CACHE_CHECK([how to get the file descriptor associated with an open DIR*], + [gl_cv_sys_dir_fd_member_name], + [ + dirfd_save_CFLAGS=$CFLAGS + for ac_expr in d_fd dd_fd; do + + CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include <sys/types.h> + #include <dirent.h>]], + [[DIR *dir_p = opendir("."); (void) dir_p->DIR_FD_MEMBER_NAME;]])], + [dir_fd_found=yes] + ) + CFLAGS=$dirfd_save_CFLAGS + test "$dir_fd_found" = yes && break + done + test "$dir_fd_found" = yes || ac_expr=no_such_member + + gl_cv_sys_dir_fd_member_name=$ac_expr + ] + ) + if test $gl_cv_sys_dir_fd_member_name != no_such_member; then + AC_DEFINE_UNQUOTED([DIR_FD_MEMBER_NAME], + [$gl_cv_sys_dir_fd_member_name], + [the name of the file descriptor member of DIR]) + fi + AH_VERBATIM([DIR_TO_FD], + [#ifdef DIR_FD_MEMBER_NAME +# define DIR_TO_FD(Dir_p) ((Dir_p)->DIR_FD_MEMBER_NAME) +#else +# define DIR_TO_FD(Dir_p) -1 +#endif +]) +]) diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 5763fae12f..949dd0e12f 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -56,6 +56,7 @@ AC_DEFUN([gl_EARLY], # Code from module crypto/sha256: # Code from module crypto/sha512: # Code from module dirent: + # Code from module dirfd: # Code from module dosname: # Code from module dtoastr: # Code from module dtotimespec: @@ -394,6 +395,7 @@ AC_DEFUN([gl_INIT], gl_UTIMENS AC_C_VARARRAYS gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=false + gl_gnulib_enabled_dirfd=false gl_gnulib_enabled_dosname=false gl_gnulib_enabled_euidaccess=false gl_gnulib_enabled_getdtablesize=false @@ -416,6 +418,18 @@ AC_DEFUN([gl_INIT], gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b=true fi } + func_gl_gnulib_m4code_dirfd () + { + if ! $gl_gnulib_enabled_dirfd; then + gl_FUNC_DIRFD + if test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no; then + AC_LIBOBJ([dirfd]) + gl_PREREQ_DIRFD + fi + gl_DIRENT_MODULE_INDICATOR([dirfd]) + gl_gnulib_enabled_dirfd=true + fi + } func_gl_gnulib_m4code_dosname () { if ! $gl_gnulib_enabled_dosname; then @@ -595,6 +609,9 @@ AC_DEFUN([gl_INIT], if test $HAVE_FDOPENDIR = 0; then func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b fi + if test $HAVE_FDOPENDIR = 0; then + func_gl_gnulib_m4code_dirfd + fi if test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1; then func_gl_gnulib_m4code_260941c0e5dc67ec9e87d1fb321c300b fi @@ -636,6 +653,7 @@ AC_DEFUN([gl_INIT], fi m4_pattern_allow([^gl_GNULIB_ENABLED_]) AM_CONDITIONAL([gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b], [$gl_gnulib_enabled_260941c0e5dc67ec9e87d1fb321c300b]) + AM_CONDITIONAL([gl_GNULIB_ENABLED_dirfd], [$gl_gnulib_enabled_dirfd]) AM_CONDITIONAL([gl_GNULIB_ENABLED_dosname], [$gl_gnulib_enabled_dosname]) AM_CONDITIONAL([gl_GNULIB_ENABLED_euidaccess], [$gl_gnulib_enabled_euidaccess]) AM_CONDITIONAL([gl_GNULIB_ENABLED_getdtablesize], [$gl_gnulib_enabled_getdtablesize]) @@ -822,6 +840,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/count-trailing-zeros.c lib/count-trailing-zeros.h lib/dirent.in.h + lib/dirfd.c lib/dosname.h lib/dtoastr.c lib/dtotimespec.c @@ -940,6 +959,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/count-one-bits.m4 m4/count-trailing-zeros.m4 m4/dirent_h.m4 + m4/dirfd.m4 m4/dup2.m4 m4/environ.m4 m4/errno_h.m4 |