summaryrefslogtreecommitdiff
path: root/src/sysdeps
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2014-09-18 18:55:44 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2014-09-18 18:55:44 +0000
commit3534b428629be185e096be99e3bd5fdfe32d5544 (patch)
tree210ef3198ed66bc7f7b7bf6a85e4579f455e5a36 /src/sysdeps
downloadskalibs-3534b428629be185e096be99e3bd5fdfe32d5544.tar.xz
initial commit with rc for skalibs-2.0.0.0
Diffstat (limited to 'src/sysdeps')
-rw-r--r--src/sysdeps/tryaccept4.c33
-rw-r--r--src/sysdeps/tryancilautoclose.c116
-rw-r--r--src/sysdeps/tryclockmon.c11
-rw-r--r--src/sysdeps/tryclockrt.c11
-rw-r--r--src/sysdeps/trycmsgcloexec.c25
-rw-r--r--src/sysdeps/trydevrandom.c54
-rw-r--r--src/sysdeps/trydevurandom.c31
-rw-r--r--src/sysdeps/tryendianness.c43
-rw-r--r--src/sysdeps/tryeproto.c7
-rw-r--r--src/sysdeps/tryeventfd.c10
-rw-r--r--src/sysdeps/tryflock.c13
-rw-r--r--src/sysdeps/trygetpeereid.c15
-rw-r--r--src/sysdeps/trygetpeerucred.c20
-rw-r--r--src/sysdeps/tryipv6.c35
-rw-r--r--src/sysdeps/trylinkat.c29
-rw-r--r--src/sysdeps/trylsock.c26
-rw-r--r--src/sysdeps/trymalloc0.c4
-rw-r--r--src/sysdeps/tryopenat.c29
-rw-r--r--src/sysdeps/trypipe2.c17
-rw-r--r--src/sysdeps/tryposixspawn.c16
-rw-r--r--src/sysdeps/tryppoll.c18
-rw-r--r--src/sysdeps/tryrevoke.c7
-rw-r--r--src/sysdeps/trysendfile.c10
-rw-r--r--src/sysdeps/trysetgroups.c27
-rw-r--r--src/sysdeps/trysettimeofday.c27
-rw-r--r--src/sysdeps/trysignalfd.c13
-rw-r--r--src/sysdeps/trysizeofgid.c8
-rw-r--r--src/sysdeps/trysizeoftime.c8
-rw-r--r--src/sysdeps/trysizeofuint.c7
-rw-r--r--src/sysdeps/trysizeofulong.c7
-rw-r--r--src/sysdeps/trysizeofushort.c7
-rw-r--r--src/sysdeps/trysopeercred.c29
-rw-r--r--src/sysdeps/trysplice.c28
-rw-r--r--src/sysdeps/trystrcasestr.c21
-rw-r--r--src/sysdeps/tryuint64t.c5
35 files changed, 767 insertions, 0 deletions
diff --git a/src/sysdeps/tryaccept4.c b/src/sysdeps/tryaccept4.c
new file mode 100644
index 0000000..e27eb1a
--- /dev/null
+++ b/src/sysdeps/tryaccept4.c
@@ -0,0 +1,33 @@
+/* ISC license. */
+
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+
+#ifndef _XPG4_2
+# define _XPG4_2
+#endif
+
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE
+#endif
+
+#include <sys/types.h>
+
+#if defined(__FreeBSD__)
+# include <sys/param.h>
+#endif
+
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+
+int main (void)
+{
+ struct sockaddr blah ;
+ socklen_t blahlen = sizeof(blah) ;
+ int fd = open("/dev/null", O_RDONLY | O_NONBLOCK) ;
+ if (fd < 0) return 111 ;
+ if ((accept4(fd, &blah, &blahlen, SOCK_NONBLOCK) < 0) && (errno != ENOTSOCK)) return 1 ;
+ return 0 ;
+}
diff --git a/src/sysdeps/tryancilautoclose.c b/src/sysdeps/tryancilautoclose.c
new file mode 100644
index 0000000..7b4a563
--- /dev/null
+++ b/src/sysdeps/tryancilautoclose.c
@@ -0,0 +1,116 @@
+/* ISC license. */
+
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+
+#ifndef _XPG4_2
+# define _XPG4_2
+#endif
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+#if defined(__FreeBSD__)
+# include <sys/param.h>
+#endif
+
+typedef struct ancilbuf_s ancilbuf_t, *ancilbuf_t_ref ;
+struct ancilbuf_s
+{
+ struct cmsghdr h ;
+ int fd ;
+} ;
+
+static int ancil_send_fd (int sock, int fd)
+{
+ struct msghdr msghdr ;
+ struct iovec nothing_ptr ;
+ ancilbuf_t buf ;
+ struct cmsghdr *cmsg ;
+ char nothing = '!' ;
+
+ nothing_ptr.iov_base = &nothing ;
+ nothing_ptr.iov_len = 1 ;
+ msghdr.msg_name = 0 ;
+ msghdr.msg_namelen = 0 ;
+ msghdr.msg_iov = &nothing_ptr ;
+ msghdr.msg_iovlen = 1 ;
+ msghdr.msg_flags = 0 ;
+ msghdr.msg_control = &buf ;
+ msghdr.msg_controllen = sizeof(ancilbuf_t) ;
+ cmsg = CMSG_FIRSTHDR(&msghdr) ;
+ cmsg->cmsg_len = msghdr.msg_controllen ;
+ cmsg->cmsg_level = SOL_SOCKET ;
+ cmsg->cmsg_type = SCM_RIGHTS ;
+ *((int *)CMSG_DATA(cmsg)) = fd ;
+ return (sendmsg(sock, &msghdr, 0) >= 0) ;
+}
+
+static int ancil_recv_fd (int sock)
+{
+ struct msghdr msghdr ;
+ struct iovec nothing_ptr ;
+ ancilbuf_t buf ;
+ struct cmsghdr *cmsg ;
+ char nothing ;
+
+ nothing_ptr.iov_base = &nothing ;
+ nothing_ptr.iov_len = 1 ;
+ msghdr.msg_name = 0 ;
+ msghdr.msg_namelen = 0 ;
+ msghdr.msg_iov = &nothing_ptr ;
+ msghdr.msg_iovlen = 1 ;
+ msghdr.msg_flags = 0 ;
+ msghdr.msg_control = &buf ;
+ msghdr.msg_controllen = sizeof(ancilbuf_t) ;
+ cmsg = CMSG_FIRSTHDR(&msghdr) ;
+ cmsg->cmsg_len = msghdr.msg_controllen ;
+ cmsg->cmsg_level = SOL_SOCKET ;
+ cmsg->cmsg_type = SCM_RIGHTS ;
+ *((int *)CMSG_DATA(cmsg)) = -1 ;
+ if (recvmsg(sock, &msghdr, 0) < 0) return -1 ;
+ return *((int *)CMSG_DATA(cmsg)) ;
+}
+
+static int client (int sock)
+{
+ int p ;
+ char c ;
+ if (read(sock, &c, 1) < 1) return 111 ;
+ if (c != 'b') return 111 ;
+ p = ancil_recv_fd(sock) ;
+ if (p < 0) return 111 ;
+ if (read(sock, &c, 1) < 1) return 111 ;
+ if (c != 'a') return 111 ;
+ if (read(p, &c, 1) < 1) return 111 ;
+ if (c != 'K') return 111 ;
+ if (read(p, &c, 1) < 1) return 111 ;
+ return c ;
+}
+
+static void server (int sock)
+{
+ int p[2] ;
+ char c = 1 ;
+ if (pipe(p) < 0) return ;
+ if (write(sock, "b", 1) < 1) return ;
+ if (!ancil_send_fd(sock, p[0])) return ;
+ if (write(sock, "a", 1) < 1) return ;
+ if (write(p[1], "K", 1) < 1) return ;
+ if ((close(p[0]) < 0) && (errno == EBADF)) c = 0 ;
+ write(p[1], &c, 1) ;
+}
+
+int main (void)
+{
+ int fd[2] ;
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0) return 111 ;
+ switch (fork())
+ {
+ case -1 : return 111 ;
+ case 0 : close(fd[0]) ; server(fd[1]) ; return 0 ;
+ default : close(fd[1]) ; return client(fd[0]) ;
+ }
+}
diff --git a/src/sysdeps/tryclockmon.c b/src/sysdeps/tryclockmon.c
new file mode 100644
index 0000000..2564ed3
--- /dev/null
+++ b/src/sysdeps/tryclockmon.c
@@ -0,0 +1,11 @@
+/* ISC license. */
+
+#include <sys/types.h>
+#include <time.h>
+
+int main (void)
+{
+ struct timespec ts ;
+ if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) return 111 ;
+ return 0 ;
+}
diff --git a/src/sysdeps/tryclockrt.c b/src/sysdeps/tryclockrt.c
new file mode 100644
index 0000000..01bae7c
--- /dev/null
+++ b/src/sysdeps/tryclockrt.c
@@ -0,0 +1,11 @@
+/* ISC license. */
+
+#include <sys/types.h>
+#include <time.h>
+
+int main (void)
+{
+ struct timespec ts ;
+ if (clock_gettime(CLOCK_REALTIME, &ts) < 0) return 111 ;
+ return 0 ;
+}
diff --git a/src/sysdeps/trycmsgcloexec.c b/src/sysdeps/trycmsgcloexec.c
new file mode 100644
index 0000000..7923340
--- /dev/null
+++ b/src/sysdeps/trycmsgcloexec.c
@@ -0,0 +1,25 @@
+/* ISC license. */
+
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+
+#ifndef _XPG4_2
+# define _XPG4_2
+#endif
+
+#ifndef _XPG_6
+# define _XPG6
+#endif
+
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE
+#endif
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int main (void)
+{
+ int flag = MSG_CMSG_CLOEXEC ;
+ return 0 ;
+}
diff --git a/src/sysdeps/trydevrandom.c b/src/sysdeps/trydevrandom.c
new file mode 100644
index 0000000..395d008
--- /dev/null
+++ b/src/sysdeps/trydevrandom.c
@@ -0,0 +1,54 @@
+/* ISC license. */
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <errno.h>
+
+static int fd_read (int fd, char *buf, unsigned int len)
+{
+ register int r ;
+ do r = read(fd, buf, len) ;
+ while ((r == -1) && (errno == EINTR)) ;
+ return r ;
+}
+
+static unsigned int allread (int fd, register char *buf, register unsigned int len)
+{
+ register unsigned int written = 0 ;
+ while (len)
+ {
+ register int w = fd_read(fd, buf, len) ;
+ if (!w) errno = EPIPE ;
+ if (w <= 0) break ;
+ written += w ;
+ buf += w ;
+ len -= w ;
+ }
+ return written ;
+}
+
+static int byte_diff (char *s, unsigned int n, char *t)
+{
+ for (;;)
+ {
+ if (!n) return 0 ;
+ if (*s != *t) break ;
+ ++s ; ++t ; --n ;
+ }
+ return ((int)(unsigned int)(unsigned char) *s)
+ - ((int)(unsigned int)(unsigned char) *t);
+}
+
+int main ()
+{
+ char a[64] ;
+ char b[64] ;
+ int fd = open("/dev/random", O_RDONLY) ;
+ if ((fd == -1) || (allread(fd, a, 64) < 64) ) return 111 ;
+ close(fd) ;
+ fd = open("/dev/random", O_RDONLY) ;
+ if ((fd == -1) || (allread(fd, b, 64) < 64) ) return 111 ;
+ close(fd) ;
+ return !byte_diff(a, 64, b) ;
+}
diff --git a/src/sysdeps/trydevurandom.c b/src/sysdeps/trydevurandom.c
new file mode 100644
index 0000000..3d0f912
--- /dev/null
+++ b/src/sysdeps/trydevurandom.c
@@ -0,0 +1,31 @@
+/* ISC license. */
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+static int byte_diff (char *s, unsigned int n, char *t)
+{
+ for (;;)
+ {
+ if (!n) return 0 ;
+ if (*s != *t) break ;
+ ++s ; ++t ; --n ;
+ }
+ return ((int)(unsigned int)(unsigned char) *s)
+ - ((int)(unsigned int)(unsigned char) *t);
+}
+
+int main ()
+{
+ char a[64] ;
+ char b[64] ;
+ int fd ;
+ fd = open("/dev/urandom", O_RDONLY) ;
+ if ((fd == -1) || (read(fd, a, 64) < 64) ) return 111 ;
+ close(fd) ;
+ fd = open("/dev/urandom", O_RDONLY) ;
+ if ((fd == -1) || (read(fd, b, 64) < 64) ) return 111 ;
+ close(fd) ;
+ return (!byte_diff(a, 64, b)) ;
+}
diff --git a/src/sysdeps/tryendianness.c b/src/sysdeps/tryendianness.c
new file mode 100644
index 0000000..3fa1938
--- /dev/null
+++ b/src/sysdeps/tryendianness.c
@@ -0,0 +1,43 @@
+/* ISC license. */
+
+#include <stdio.h>
+
+int main (void)
+{
+ unsigned long i = 0xdeadbeefUL ;
+ if (sizeof(unsigned long) == 4)
+ if ((((unsigned char *)(&i))[0] == 0xef)
+ && (((unsigned char *)(&i))[1] == 0xbe)
+ && (((unsigned char *)(&i))[2] == 0xad)
+ && (((unsigned char *)(&i))[3] == 0xde))
+ return (puts("little"), 0) ;
+ else if ((((unsigned char *)(&i))[0] == 0xde)
+ && (((unsigned char *)(&i))[1] == 0xad)
+ && (((unsigned char *)(&i))[2] == 0xbe)
+ && (((unsigned char *)(&i))[3] == 0xef))
+ return (puts("big"), 0) ;
+ else return (puts("unknown"), 1) ;
+ else if (sizeof(unsigned long) == 8)
+ if ((((unsigned char *)(&i))[0] == 0xef)
+ && (((unsigned char *)(&i))[1] == 0xbe)
+ && (((unsigned char *)(&i))[2] == 0xad)
+ && (((unsigned char *)(&i))[3] == 0xde)
+ && (((unsigned char *)(&i))[4] == 0x00)
+ && (((unsigned char *)(&i))[5] == 0x00)
+ && (((unsigned char *)(&i))[6] == 0x00)
+ && (((unsigned char *)(&i))[7] == 0x00))
+ return (puts("little"), 0) ;
+ else if (sizeof(unsigned long) == 8)
+ if ((((unsigned char *)(&i))[0] == 0x00)
+ && (((unsigned char *)(&i))[1] == 0x00)
+ && (((unsigned char *)(&i))[2] == 0x00)
+ && (((unsigned char *)(&i))[3] == 0x00)
+ && (((unsigned char *)(&i))[4] == 0xde)
+ && (((unsigned char *)(&i))[5] == 0xad)
+ && (((unsigned char *)(&i))[6] == 0xbe)
+ && (((unsigned char *)(&i))[7] == 0xef))
+ return (puts("big"), 0) ;
+ else return (puts("unknown"), 1) ;
+ else return 1 ;
+ else return (puts("unknown unsigned long size"), 1) ;
+}
diff --git a/src/sysdeps/tryeproto.c b/src/sysdeps/tryeproto.c
new file mode 100644
index 0000000..b5cc66c
--- /dev/null
+++ b/src/sysdeps/tryeproto.c
@@ -0,0 +1,7 @@
+/* ISC license. */
+
+#include <errno.h>
+static int dummy ;
+#ifndef EPROTO
+ syntax error !
+#endif
diff --git a/src/sysdeps/tryeventfd.c b/src/sysdeps/tryeventfd.c
new file mode 100644
index 0000000..3c3122c
--- /dev/null
+++ b/src/sysdeps/tryeventfd.c
@@ -0,0 +1,10 @@
+/* ISC license. */
+
+#include <sys/eventfd.h>
+
+int main (void)
+{
+ int fd = eventfd(0, EFD_NONBLOCK) ;
+ if (fd < 0) return 1 ;
+ return 0 ;
+}
diff --git a/src/sysdeps/tryflock.c b/src/sysdeps/tryflock.c
new file mode 100644
index 0000000..47fadf8
--- /dev/null
+++ b/src/sysdeps/tryflock.c
@@ -0,0 +1,13 @@
+/* ISC license. */
+
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+
+#include <sys/types.h>
+#include <sys/file.h>
+#include <fcntl.h>
+
+int main (void)
+{
+ return flock(0, LOCK_EX | LOCK_UN | LOCK_NB) ;
+}
diff --git a/src/sysdeps/trygetpeereid.c b/src/sysdeps/trygetpeereid.c
new file mode 100644
index 0000000..10a411a
--- /dev/null
+++ b/src/sysdeps/trygetpeereid.c
@@ -0,0 +1,15 @@
+/* ISC license. */
+
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+
+#include <sys/types.h>
+#include <unistd.h>
+
+int main (void)
+{
+ uid_t uid ;
+ gid_t gid ;
+ int s = 0 ;
+ return getpeereid(s, &uid, &gid) ;
+}
diff --git a/src/sysdeps/trygetpeerucred.c b/src/sysdeps/trygetpeerucred.c
new file mode 100644
index 0000000..22dac68
--- /dev/null
+++ b/src/sysdeps/trygetpeerucred.c
@@ -0,0 +1,20 @@
+/* ISC license. */
+
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+
+#include <sys/types.h>
+#include <ucred.h>
+
+int main (void)
+{
+ ucred_t *cred ;
+ uid_t uid ;
+ gid_t gid ;
+ int s = 0 ;
+ getpeerucred(s, &cred) ;
+ uid = ucred_geteuid(cred) ;
+ gid = ucred_getegid(cred) ;
+ ucred_free(cred) ;
+ return 0 ;
+}
diff --git a/src/sysdeps/tryipv6.c b/src/sysdeps/tryipv6.c
new file mode 100644
index 0000000..0c7f306
--- /dev/null
+++ b/src/sysdeps/tryipv6.c
@@ -0,0 +1,35 @@
+/* ISC license. */
+
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+
+#define _XPG4_2
+#define _XPG6
+
+#include <sys/types.h>
+
+#if defined(__FreeBSD__)
+# include <sys/param.h>
+#endif
+
+#include <errno.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+int main (void)
+{
+ int s ;
+ register int r ;
+ struct in6_addr foo ;
+ struct sockaddr_in6 bar ;
+ memset(&foo, 0, sizeof(struct sockaddr_in6)) ;
+ bar.sin6_addr = foo ;
+ bar.sin6_port = 1026 ;
+ s = socket(AF_INET6, SOCK_STREAM, 0) ;
+ if (s < 0) return 111 ;
+ do r = connect(s, (struct sockaddr *)&bar, sizeof bar) ;
+ while ((r == -1) && (errno == EINTR)) ;
+ if ((r == -1) && (errno == EALREADY)) errno = EINPROGRESS ;
+ return 0 ;
+}
diff --git a/src/sysdeps/trylinkat.c b/src/sysdeps/trylinkat.c
new file mode 100644
index 0000000..3db0845
--- /dev/null
+++ b/src/sysdeps/trylinkat.c
@@ -0,0 +1,29 @@
+/* ISC license. */
+
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#ifndef _ATFILE_SOURCE
+#define _ATFILE_SOURCE
+#endif
+
+#ifndef _INCOMPLETE_XOPEN_C063
+#define _INCOMPLETE_XOPEN_C063
+#endif
+
+#ifndef __EXTENSIONS__
+#define __EXTENSIONS__
+#endif
+
+#include <unistd.h>
+#include <fcntl.h>
+
+int main (void)
+{
+ int r = linkat(AT_FDCWD, "/foo", AT_FDCWD, "foo", AT_SYMLINK_FOLLOW) ;
+ return (r < 0) ;
+}
diff --git a/src/sysdeps/trylsock.c b/src/sysdeps/trylsock.c
new file mode 100644
index 0000000..b5b4413
--- /dev/null
+++ b/src/sysdeps/trylsock.c
@@ -0,0 +1,26 @@
+/* ISC license. */
+
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+
+#ifndef _XPG4_2
+# define _XPG4_2
+#endif
+
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE
+#endif
+
+#include <sys/types.h>
+
+#if defined(__FreeBSD__)
+# include <sys/param.h>
+#endif
+
+#include <sys/socket.h>
+
+int main (void)
+{
+ shutdown(0, 0) ;
+ return 0 ;
+}
diff --git a/src/sysdeps/trymalloc0.c b/src/sysdeps/trymalloc0.c
new file mode 100644
index 0000000..0f68329
--- /dev/null
+++ b/src/sysdeps/trymalloc0.c
@@ -0,0 +1,4 @@
+/* ISC license */
+
+#include <stdlib.h>
+int main() { return !malloc(0) ; }
diff --git a/src/sysdeps/tryopenat.c b/src/sysdeps/tryopenat.c
new file mode 100644
index 0000000..d24a9cb
--- /dev/null
+++ b/src/sysdeps/tryopenat.c
@@ -0,0 +1,29 @@
+/* ISC license. */
+
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#ifndef _ATFILE_SOURCE
+#define _ATFILE_SOURCE
+#endif
+
+#ifndef _INCOMPLETE_XOPEN_C063
+#define _INCOMPLETE_XOPEN_C063
+#endif
+
+#ifndef __EXTENSIONS__
+#define __EXTENSIONS__
+#endif
+
+#include <sys/stat.h>
+#include <fcntl.h>
+
+int main (void)
+{
+ int fd = openat(0, "/", O_RDONLY) ;
+ return (fd < 0) ;
+}
diff --git a/src/sysdeps/trypipe2.c b/src/sysdeps/trypipe2.c
new file mode 100644
index 0000000..4e63182
--- /dev/null
+++ b/src/sysdeps/trypipe2.c
@@ -0,0 +1,17 @@
+/* ISC license. */
+
+#ifndef _NETBSD_SOURCE
+#define _NETBSD_SOURCE
+#endif
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <unistd.h>
+
+int main (void)
+{
+ int p[2] ;
+ if (pipe2(p, 0) < 0) return 111 ;
+ return 0 ;
+}
diff --git a/src/sysdeps/tryposixspawn.c b/src/sysdeps/tryposixspawn.c
new file mode 100644
index 0000000..dccdba4
--- /dev/null
+++ b/src/sysdeps/tryposixspawn.c
@@ -0,0 +1,16 @@
+/* ISC license. */
+
+#include <sys/types.h>
+#include <spawn.h>
+
+int main (void)
+{
+ pid_t pid ;
+ posix_spawn_file_actions_t actions ;
+ posix_spawnattr_t attr ;
+ char *const argv[2] = { "/bin/true", 0 } ;
+ char *const envp[1] = { 0 } ;
+ posix_spawnattr_setflags(&attr, 0) ;
+ posix_spawn_file_actions_init(&actions) ;
+ return posix_spawn(&pid, argv[0], 0, 0, argv, envp) ;
+}
diff --git a/src/sysdeps/tryppoll.c b/src/sysdeps/tryppoll.c
new file mode 100644
index 0000000..33380b8
--- /dev/null
+++ b/src/sysdeps/tryppoll.c
@@ -0,0 +1,18 @@
+/* ISC license. */
+
+#define _GNU_SOURCE
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <time.h>
+#include <poll.h>
+
+int main (void)
+{
+ struct pollfd x = { .events = POLLIN } ;
+ struct timespec ts = { .tv_sec = 0, .tv_nsec = 10 } ;
+ x.fd = open("src/sysdeps/tryppoll.c", O_RDONLY);
+ if (x.fd < 0) return 111 ;
+ if (ppoll(&x, 1, &ts, 0) < 0) return 1 ;
+ if (x.revents != POLLIN) return 1 ;
+ return 0 ;
+}
diff --git a/src/sysdeps/tryrevoke.c b/src/sysdeps/tryrevoke.c
new file mode 100644
index 0000000..9cbc615
--- /dev/null
+++ b/src/sysdeps/tryrevoke.c
@@ -0,0 +1,7 @@
+/* ISC license. */
+
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+
+#include <unistd.h>
+int main () { return revoke("/") ; }
diff --git a/src/sysdeps/trysendfile.c b/src/sysdeps/trysendfile.c
new file mode 100644
index 0000000..6c99ad0
--- /dev/null
+++ b/src/sysdeps/trysendfile.c
@@ -0,0 +1,10 @@
+/* ISC license. */
+
+#include <sys/types.h>
+#include <sys/sendfile.h>
+
+int main (void)
+{
+ sendfile(1, 0, 0, 4096) ;
+ return 0 ;
+}
diff --git a/src/sysdeps/trysetgroups.c b/src/sysdeps/trysetgroups.c
new file mode 100644
index 0000000..af2d8c6
--- /dev/null
+++ b/src/sysdeps/trysetgroups.c
@@ -0,0 +1,27 @@
+/* ISC license. */
+
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+
+#ifndef _NETBSD_SOURCE
+#define _NETBSD_SOURCE
+#endif
+
+#ifndef __EXTENSIONS__
+#define __EXTENSIONS__
+#endif
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <grp.h>
+
+int main (void)
+{
+ gid_t g = 0 ;
+ setgroups(1, &g) ;
+ return 0 ;
+}
diff --git a/src/sysdeps/trysettimeofday.c b/src/sysdeps/trysettimeofday.c
new file mode 100644
index 0000000..05ae3c4
--- /dev/null
+++ b/src/sysdeps/trysettimeofday.c
@@ -0,0 +1,27 @@
+/* ISC license. */
+
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+
+#ifndef _NETBSD_SOURCE
+#define _NETBSD_SOURCE
+#endif
+
+#ifndef __EXTENSIONS__
+#define __EXTENSIONS__
+#endif
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+int main (void)
+{
+ struct timeval tv ;
+ gettimeofday(&tv, 0) ;
+ settimeofday(&tv, 0) ;
+ return 0 ;
+}
diff --git a/src/sysdeps/trysignalfd.c b/src/sysdeps/trysignalfd.c
new file mode 100644
index 0000000..1f06933
--- /dev/null
+++ b/src/sysdeps/trysignalfd.c
@@ -0,0 +1,13 @@
+/* ISC license. */
+
+#include <sys/types.h>
+#include <signal.h>
+#include <sys/signalfd.h>
+
+int main (void)
+{
+ sigset_t foo ;
+ sigemptyset(&foo) ;
+ if (signalfd(-1, &foo, SFD_NONBLOCK) < 0) return 1 ;
+ return 0 ;
+}
diff --git a/src/sysdeps/trysizeofgid.c b/src/sysdeps/trysizeofgid.c
new file mode 100644
index 0000000..75eeb2c
--- /dev/null
+++ b/src/sysdeps/trysizeofgid.c
@@ -0,0 +1,8 @@
+#include <sys/types.h>
+#include <stdio.h>
+
+int main (void)
+{
+ printf("%u\n", (unsigned int)sizeof(gid_t)) ;
+ return 0 ;
+}
diff --git a/src/sysdeps/trysizeoftime.c b/src/sysdeps/trysizeoftime.c
new file mode 100644
index 0000000..13674de
--- /dev/null
+++ b/src/sysdeps/trysizeoftime.c
@@ -0,0 +1,8 @@
+#include <sys/types.h>
+#include <stdio.h>
+
+int main (void)
+{
+ printf("%u\n", (unsigned int)sizeof(time_t)) ;
+ return 0 ;
+}
diff --git a/src/sysdeps/trysizeofuint.c b/src/sysdeps/trysizeofuint.c
new file mode 100644
index 0000000..ca4af39
--- /dev/null
+++ b/src/sysdeps/trysizeofuint.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main (void)
+{
+ printf("%u\n", (unsigned int)sizeof(unsigned int)) ;
+ return 0 ;
+}
diff --git a/src/sysdeps/trysizeofulong.c b/src/sysdeps/trysizeofulong.c
new file mode 100644
index 0000000..f2f21b1
--- /dev/null
+++ b/src/sysdeps/trysizeofulong.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main (void)
+{
+ printf("%u\n", (unsigned int)sizeof(unsigned long)) ;
+ return 0 ;
+}
diff --git a/src/sysdeps/trysizeofushort.c b/src/sysdeps/trysizeofushort.c
new file mode 100644
index 0000000..fd410bb
--- /dev/null
+++ b/src/sysdeps/trysizeofushort.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main (void)
+{
+ printf("%u\n", (unsigned int)sizeof(unsigned short)) ;
+ return 0 ;
+}
diff --git a/src/sysdeps/trysopeercred.c b/src/sysdeps/trysopeercred.c
new file mode 100644
index 0000000..0356fcf
--- /dev/null
+++ b/src/sysdeps/trysopeercred.c
@@ -0,0 +1,29 @@
+/* ISC license. */
+
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+
+#ifndef _XPG4_2
+# define _XPG4_2
+#endif
+
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE
+#endif
+
+#include <sys/types.h>
+
+#if defined(__FreeBSD__)
+# include <sys/param.h>
+#endif
+
+#include <sys/socket.h>
+#include <sys/un.h>
+
+int main (void)
+{
+ int s ;
+ struct ucred dummy ;
+ socklen_t len = sizeof(struct ucred) ;
+ return getsockopt(s, SOL_SOCKET, SO_PEERCRED, &dummy, &len) ;
+}
diff --git a/src/sysdeps/trysplice.c b/src/sysdeps/trysplice.c
new file mode 100644
index 0000000..6b566b8
--- /dev/null
+++ b/src/sysdeps/trysplice.c
@@ -0,0 +1,28 @@
+/* ISC license. */
+
+#define _GNU_SOURCE
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#define N 4096
+
+int main (void)
+{
+ char buf[N] ;
+ int p[2] ;
+ int fd ;
+ if (pipe(p) < 0) return 111 ;
+ fd = open("./src/sysdeps/trysplice.c", O_RDONLY) ;
+ if (fd < 0) return 111 ;
+
+ for (;;)
+ {
+ register int r = splice(fd, 0, p[1], 0, N, 0) ;
+ if (r < 0) return 1 ;
+ if (!r) break ;
+ if (splice(p[0], 0, 1, 0, r, 0) < r) return 2 ;
+ }
+ return 0 ;
+}
diff --git a/src/sysdeps/trystrcasestr.c b/src/sysdeps/trystrcasestr.c
new file mode 100644
index 0000000..f362202
--- /dev/null
+++ b/src/sysdeps/trystrcasestr.c
@@ -0,0 +1,21 @@
+/* ISC license. */
+
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+#ifndef _NETBSD_SOURCE
+#define _NETBSD_SOURCE
+#endif
+
+#include <string.h>
+
+int main (void)
+{
+ return !strcasestr("foobar", "bar") ;
+}
diff --git a/src/sysdeps/tryuint64t.c b/src/sysdeps/tryuint64t.c
new file mode 100644
index 0000000..23aafad
--- /dev/null
+++ b/src/sysdeps/tryuint64t.c
@@ -0,0 +1,5 @@
+/* ISC license. */
+
+#include <stdint.h>
+
+uint64_t dummy = 0 ;