From 822bf267121b8e380037da3db4ad31aca34fc7c7 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 11 Sep 2023 07:09:48 +0000 Subject: Add a pthread sysdep Signed-off-by: Laurent Bercot --- configure | 9 +++++---- src/sysdeps/trypthread.c | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 src/sysdeps/trypthread.c diff --git a/configure b/configure index 748e70d..1e058c0 100755 --- a/configure +++ b/configure @@ -597,10 +597,11 @@ fi echo "$socket_lib" > $sysdeps/socket.lib trylibs clockrt sysclock 'clock_gettime()' -lrt -choose cl clockmon CLOCK_MONOTONIC `cat "${sysdeps}/sysclock.lib"` -choose cl clockboot CLOCK_BOOTTIME `cat "${sysdeps}/sysclock.lib"` +choose cl clockmon CLOCK_MONOTONIC $sysclock_lib +choose cl clockboot CLOCK_BOOTTIME $sysclock_lib trylibs posixspawn spawn 'posix_spawn()' -lrt trylibs timer timer 'timer_create()' -lrt +trylibs pthread pthread 'pthread support' -lpthread -lrt tryendianness trytypes @@ -640,11 +641,11 @@ choose cl explicit_bzero 'explicit_bzero()' choose cl getrandom 'getrandom()' choose cl grndinsecure 'GRND_INSECURE' choose cl chroot 'chroot()' -choose cl posixspawnsetsid 'POSIX_SPAWN_SETSID' ${spawn_lib} +choose cl posixspawnsetsid 'POSIX_SPAWN_SETSID' $spawn_lib # Here are the evil irreducible run-time sysdeps. choose clr devurandom '/dev/urandom' -choose clr posixspawnearlyreturn 'posix_spawn() incorrectly returning early' ${spawn_lib} +choose clr posixspawnearlyreturn 'posix_spawn() incorrectly returning early' $spawn_lib # Finally, produce config.mak and config.h diff --git a/src/sysdeps/trypthread.c b/src/sysdeps/trypthread.c new file mode 100644 index 0000000..8e2e459 --- /dev/null +++ b/src/sysdeps/trypthread.c @@ -0,0 +1,24 @@ +/* ISC license. */ + +#include +#include + +void *pstart (void *) +{ + return 0 ; +} + +int main (void) +{ + pthread_t th ; + pthread_attr_t attr ; + pthread_cond_t cond = PTHREAD_COND_INITIALIZER ; + pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER ; + struct timespec ts = { .tv_sec = 1, .tv_nsec = 0 } ; + void *p ; + int e = pthread_attr_init(&attr) ; + e = pthread_create(&th, &attr, &pstart, 0) ; + e = pthread_cond_timedwait(&cond, &mutex, &ts) ; + e = pthread_join(th, &p) ; + return 0 ; +} -- cgit v1.2.3