diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-09-11 07:09:48 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-09-11 07:09:48 +0000 |
commit | 822bf267121b8e380037da3db4ad31aca34fc7c7 (patch) | |
tree | 34777dfe83dc7c9a58034b31ec25dacdce9a54c9 /src/sysdeps/trypthread.c | |
parent | 252e2ad869637ca3ef8690854a8fac784b869ec9 (diff) | |
download | skalibs-822bf267121b8e380037da3db4ad31aca34fc7c7.tar.xz |
Add a pthread sysdep
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/sysdeps/trypthread.c')
-rw-r--r-- | src/sysdeps/trypthread.c | 24 |
1 files changed, 24 insertions, 0 deletions
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 <time.h> +#include <pthread.h> + +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 ; +} |