summaryrefslogtreecommitdiffstats
path: root/include/c.h
diff options
context:
space:
mode:
authorFabian Groffen2011-01-21 17:48:14 +0100
committerKarel Zak2011-01-23 22:17:14 +0100
commitd58c47d9a49805157ff0669afe02fa4f9d8adf78 (patch)
tree6bd8e603aa195bed3b2f0127135afdff1cceec9c /include/c.h
parentlib: [xalloc] don't use hardcoded return code (diff)
downloadkernel-qcow2-util-linux-d58c47d9a49805157ff0669afe02fa4f9d8adf78.tar.gz
kernel-qcow2-util-linux-d58c47d9a49805157ff0669afe02fa4f9d8adf78.tar.xz
kernel-qcow2-util-linux-d58c47d9a49805157ff0669afe02fa4f9d8adf78.zip
include: emulate dirfd when necessary
dirfd is not available on Solaris 10, it is available on latest OpenSolaris releases though. Do some autoconf trickery to determine if providing an alternative dirfd function is necessary and possible. shlibs/blkid/src/read.c: Do not define _XOPEN_SOURCE to 600, or DIR will lose it's dd_fd member again. Rearrange defines and includes to make sense per comments, and not conflict on Solaris. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Diffstat (limited to 'include/c.h')
-rw-r--r--include/c.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/c.h b/include/c.h
index 83be3565c..b37c44224 100644
--- a/include/c.h
+++ b/include/c.h
@@ -73,5 +73,14 @@ static inline __attribute__((const)) int is_power_of_2(unsigned long num)
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 */