From: Joerg Sonnenberger Date: Fri, 7 Apr 2017 12:37:12 +0000 (+0200) Subject: dirfd can be implemented as macro, so use a better test case. X-Git-Tag: v3.3.2~28 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d5ed4f85631d949a9728b0d9653f33d8e0ff0fef;p=thirdparty%2Flibarchive.git dirfd can be implemented as macro, so use a better test case. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 49537ce2c..4c818b083 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1203,7 +1203,6 @@ CHECK_FUNCTION_EXISTS_GLIBC(chflags HAVE_CHFLAGS) CHECK_FUNCTION_EXISTS_GLIBC(chown HAVE_CHOWN) CHECK_FUNCTION_EXISTS_GLIBC(chroot HAVE_CHROOT) CHECK_FUNCTION_EXISTS_GLIBC(ctime_r HAVE_CTIME_R) -CHECK_FUNCTION_EXISTS_GLIBC(dirfd HAVE_DIRFD) CHECK_FUNCTION_EXISTS_GLIBC(fchdir HAVE_FCHDIR) CHECK_FUNCTION_EXISTS_GLIBC(fchflags HAVE_FCHFLAGS) CHECK_FUNCTION_EXISTS_GLIBC(fchmod HAVE_FCHMOD) @@ -1303,6 +1302,10 @@ CHECK_C_SOURCE_COMPILES( "#include \nint main() {DIR *d = opendir(\".\"); struct dirent e,*r; return readdir_r(d,&e,&r);}" HAVE_READDIR_R) +# dirfd can be either a function or a macro. +CHECK_C_SOURCE_COMPILES( + "#include \nint main() {DIR *d = opendir(\".\"); return dirfd(d);}" + HAVE_DIRFD) # Only detect readlinkat() if we also have AT_FDCWD in unistd.h. # NOTE: linux requires fcntl.h for AT_FDCWD. diff --git a/configure.ac b/configure.ac index 2545299ec..1730f4513 100644 --- a/configure.ac +++ b/configure.ac @@ -605,7 +605,7 @@ AC_FUNC_VPRINTF # To avoid necessity for including windows.h or special forward declaration # workarounds, we use 'void *' for 'struct SECURITY_ATTRIBUTES *' AC_CHECK_STDCALL_FUNC([CreateHardLinkA],[const char *, const char *, void *]) -AC_CHECK_FUNCS([arc4random_buf chflags chown chroot ctime_r dirfd]) +AC_CHECK_FUNCS([arc4random_buf chflags chown chroot ctime_r]) AC_CHECK_FUNCS([fchdir fchflags fchmod fchown fcntl fdopendir fork]) AC_CHECK_FUNCS([fstat fstatat fstatfs fstatvfs ftruncate]) AC_CHECK_FUNCS([futimens futimes futimesat]) @@ -648,6 +648,13 @@ AC_COMPILE_IFELSE( return(readdir_r(dir, &e, &r));]])], [AC_DEFINE(HAVE_READDIR_R,1,[Define to 1 if you have a POSIX compatible readdir_r])] ) +# dirfd can be either a function or a macro. +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include + DIR *dir;]], + [[return(dirfd(dir));]])], + [AC_DEFINE(HAVE_DIRFD,1,[Define to 1 if you have a dirfd function or macro])] +) # FreeBSD's nl_langinfo supports an option to specify whether the # current locale uses month/day or day/month ordering. It makes the