diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-12-21 12:34:40 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-12-21 12:34:40 +0000 |
commit | 8a3e5a8b05ad0a7fab63595b6b4eafec56f63f89 (patch) | |
tree | 8aaf51a5fe4664a7934afa68c14c391e40b76f47 | |
parent | b45692fe8638c4faaaedb488402b90971fda18f5 (diff) | |
download | skalibs-8a3e5a8b05ad0a7fab63595b6b4eafec56f63f89.tar.xz |
Add dirfd sysdep, because Solaris sucks
-rwxr-xr-x | configure | 1 | ||||
-rw-r--r-- | package/deps.mak | 4 | ||||
-rw-r--r-- | src/include/skalibs/direntry.h | 1 | ||||
-rw-r--r-- | src/libstddjb/dir_fd.c | 23 | ||||
-rw-r--r-- | src/sysdeps/trydirfd.c | 19 |
5 files changed, 47 insertions, 1 deletions
@@ -507,6 +507,7 @@ EOF choose clr ancilautoclose ANCILAUTOCLOSE 'auto-close after fd-passing' choose c cmsgcloexec CMSGCLOEXEC 'MSG_CMSG_CLOEXEC' choose clr devurandom DEVURANDOM '/dev/urandom' + choose cl dirfd DIRFD 'dirfd()' choose c eproto EPROTO EPROTO choose cl eventfd EVENTFD 'eventfd()' choose cl flock FLOCK 'flock()' diff --git a/package/deps.mak b/package/deps.mak index b263960..25adeff 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -31,7 +31,7 @@ src/include/skalibs/iobuffer.h: src/include/skalibs/buffer.h src/include/skalibs src/include/skalibs/iopause.h: src/include/skalibs/tai.h src/include/skalibs/kolbak.h: src/include/skalibs/unixmessage.h src/include/skalibs/lolstdio.h: src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/strerr2.h -src/include/skalibs/mininetstring.h: src/include/skalibs/gccattributes.h src/include/skalibs/stralloc.h +src/include/skalibs/mininetstring.h: src/include/skalibs/stralloc.h src/include/skalibs/netstring.h: src/include/skalibs/buffer.h src/include/skalibs/stralloc.h src/include/skalibs/posixplz.h: src/include/skalibs/gccattributes.h src/include/skalibs/random.h: src/include/skalibs/stralloc.h @@ -48,6 +48,7 @@ src/include/skalibs/stddjb.h: src/include/skalibs/alarm.h src/include/skalibs/al src/include/skalibs/strerr.h: src/include/skalibs/gccattributes.h src/include/skalibs/strerr2.h: src/include/skalibs/strerr.h src/include/skalibs/tai.h: src/include/skalibs/gccattributes.h src/include/skalibs/uint64.h +src/include/skalibs/textclient.h: src/include/skalibs/tai.h src/include/skalibs/textmessage.h src/include/skalibs/textmessage.h: src/include/skalibs/allreadwrite.h src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/gccattributes.h src/include/skalibs/stralloc.h src/include/skalibs/tai.h src/include/skalibs/unix-timed.h: src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/functypes.h src/include/skalibs/stralloc.h src/include/skalibs/tai.h src/include/skalibs/unix-transactional.h: src/include/skalibs/stralloc.h src/include/skalibs/uint64.h @@ -270,6 +271,7 @@ src/libstddjb/child_spawn2.o src/libstddjb/child_spawn2.lo: src/libstddjb/child_ src/libstddjb/coe.o src/libstddjb/coe.lo: src/libstddjb/coe.c src/include/skalibs/djbunix.h src/libstddjb/deepsleepuntil.o src/libstddjb/deepsleepuntil.lo: src/libstddjb/deepsleepuntil.c src/include/skalibs/iopause.h src/include/skalibs/tai.h src/libstddjb/dir_close.o src/libstddjb/dir_close.lo: src/libstddjb/dir_close.c src/include/skalibs/direntry.h +src/libstddjb/dir_fd.o src/libstddjb/dir_fd.lo: src/libstddjb/dir_fd.c src/include/skalibs/direntry.h src/include/skalibs/nonposix.h src/include/skalibs/sysdeps.h src/libstddjb/env_addmodif.o src/libstddjb/env_addmodif.lo: src/libstddjb/env_addmodif.c src/include/skalibs/env.h src/include/skalibs/stralloc.h src/libstddjb/env_get.o src/libstddjb/env_get.lo: src/libstddjb/env_get.c src/include/skalibs/env.h src/include/skalibs/posixplz.h src/libstddjb/env_get2.o src/libstddjb/env_get2.lo: src/libstddjb/env_get2.c src/include/skalibs/bytestr.h src/include/skalibs/env.h diff --git a/src/include/skalibs/direntry.h b/src/include/skalibs/direntry.h index 518ce77..70bd190 100644 --- a/src/include/skalibs/direntry.h +++ b/src/include/skalibs/direntry.h @@ -8,5 +8,6 @@ typedef struct dirent direntry, direntry_t, *direntry_ref, *direntry_t_ref ; extern int dir_close (DIR *) ; +extern int dir_fd (DIR *) ; /* Solaris doesn't have dirfd() */ #endif diff --git a/src/libstddjb/dir_fd.c b/src/libstddjb/dir_fd.c new file mode 100644 index 0000000..403853f --- /dev/null +++ b/src/libstddjb/dir_fd.c @@ -0,0 +1,23 @@ +/* ISC license. */ + +#include <skalibs/sysdeps.h> +#include <skalibs/nonposix.h> +#include <skalibs/direntry.h> + +#ifdef SKALIBS_HASDIRFD + +int dir_fd (DIR *dir) +{ + return dirfd(dir) ; +} + +#else + + /* Pokes at the internals of DIR - no choice here */ + +int dir_fd (DIR *dir) +{ + return dir->dd_fd ; +} + +#endif diff --git a/src/sysdeps/trydirfd.c b/src/sysdeps/trydirfd.c new file mode 100644 index 0000000..c2eccf2 --- /dev/null +++ b/src/sysdeps/trydirfd.c @@ -0,0 +1,19 @@ +/* ISC license. */ + +#undef _POSIX_C_SOURCE +#undef _XOPEN_SOURCE + +#ifndef _NETBSD_SOURCE +#define _NETBSD_SOURCE +#endif +#ifndef __EXTENSIONS__ +#define __EXTENSIONS__ +#endif + +#include <dirent.h> + +int main (void) +{ + DIR *dir = opendir(".") ; + return dirfd(dir) ; +} |