fi])
AC_SUBST([SOCKET_LIBS])
+
+have_dirfd=no
+AC_CHECK_FUNCS([dirfd], [have_dirfd=yes], [have_dirfd=no])
+if test x"$have_dirfd" = xno ; then
+ AC_CHECK_DECLS([dirfd],
+ [have_dirfd=yes], [have_dirfd=no],
+ [#include <sys/types.h>
+ #include <dirent.h>])
+fi
+
+have_ddfd=no
+if test x"$have_dirfd" = xno ; then
+ AC_CHECK_MEMBERS([DIR.dd_fd],
+ [have_ddfd=yes], [have_ddfd=no],
+ [#include <sys/types.h>
+ #include <dirent.h>])
+fi
+
+case "$have_dirfd:$have_ddfd" in
+no:no)
+ AC_MSG_ERROR([cannot find a method to get filedescriptor of directory]) ;;
+esac
+
+
dnl Static compilation
m4_define([UTIL_STATIC_PROGRAMS], [losetup, mount, umount, fdisk, sfdisk, blkid])
typedef int64_t loff_t;
#endif
+#if !defined(HAVE_DIRFD) && (!defined(HAVE_DECL_DIRFD) || HAVE_DECL_DIRFD == 0) && defined(HAVE_DIR_DD_FD)
+#include <sys/types.h>
+#include <dirent.h>
+static inline int dirfd(DIR *d)
+{
+ return d->dd_fd;
+}
+#endif
+
#endif /* UTIL_LINUX_C_H */
* %End-Header%
*/
-#define _XOPEN_SOURCE 600 /* for inclusion of strtoull */
#include <stdio.h>
#include <ctype.h>
#include "blkidP.h"
+#if HAVE_STDLIB_H
+# ifndef _XOPEN_SOURCE
+# define _XOPEN_SOURCE 600 /* for inclusion of strtoull */
+# endif
+# include <stdlib.h>
+#endif
+
#ifdef HAVE_STRTOULL
#define STRTOULL strtoull /* defined in stdlib.h if you try hard enough */
#else
#define STRTOULL strtoul
#endif
-#if HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
#ifdef TEST_PROGRAM
#define blkid_debug_dump_dev(dev) (debug_dump_dev(dev))
static void debug_dump_dev(blkid_dev dev);