From f5e48e94a2f4d4bbd6e5628c7f2afafc6dbcc459 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 7 Mar 2024 17:28:52 -0500 Subject: build: Build mlibc + add distclean target Signed-off-by: Ian Moffett --- lib/mlibc/tests/posix/pthread_barrier.c | 56 --------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 lib/mlibc/tests/posix/pthread_barrier.c (limited to 'lib/mlibc/tests/posix/pthread_barrier.c') diff --git a/lib/mlibc/tests/posix/pthread_barrier.c b/lib/mlibc/tests/posix/pthread_barrier.c deleted file mode 100644 index 213ba8f..0000000 --- a/lib/mlibc/tests/posix/pthread_barrier.c +++ /dev/null @@ -1,56 +0,0 @@ -#include -#include -#include - -pthread_barrier_t barrier; -_Atomic int hitBarrierCount, pastBarrierCount; - -static void *worker(void *arg) { - (void)arg; - hitBarrierCount++; - pthread_barrier_wait(&barrier); - pastBarrierCount++; - return NULL; -} - -int main() { - // pthread_barrierattr_t - pthread_barrierattr_t attr; - pthread_barrierattr_init(&attr); - - int pshared; - pthread_barrierattr_getpshared(&attr, &pshared); - assert(pshared == PTHREAD_PROCESS_PRIVATE); - - pthread_barrierattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); - pthread_barrierattr_getpshared(&attr, &pshared); - assert(pshared == PTHREAD_PROCESS_SHARED); - - pthread_barrierattr_setpshared(&attr, PTHREAD_PROCESS_PRIVATE); - pthread_barrierattr_getpshared(&attr, &pshared); - assert(pshared == PTHREAD_PROCESS_PRIVATE); - - // pthread_barrier_t - pthread_barrier_init(&barrier, &attr, 3); - pthread_barrierattr_destroy(&attr); - - pthread_t thread1; - int ret = pthread_create(&thread1, NULL, &worker, NULL); - assert(!ret); - - pthread_t thread2; - ret = pthread_create(&thread2, NULL, &worker, NULL); - assert(!ret); - - sleep(1); - - // Make sure the barrier actually stops threads from proceeding. - assert(pastBarrierCount == 0); - assert(hitBarrierCount <= 2); - - hitBarrierCount++; - pthread_barrier_wait(&barrier); - assert(hitBarrierCount == 3); - - pthread_barrier_destroy(&barrier); -} -- cgit v1.2.3