From 7cd6a5437c263a4e2b64bafdf780d60ce51f941f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 1 Sep 2022 23:14:03 -0400 Subject: Simplify thread and semaphore status codes --- include/zix/common.h | 1 + include/zix/sem.h | 5 +++-- include/zix/thread.h | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/zix/common.h b/include/zix/common.h index 0cefd55..a097edd 100644 --- a/include/zix/common.h +++ b/include/zix/common.h @@ -29,6 +29,7 @@ typedef enum { ZIX_STATUS_TIMEOUT, ZIX_STATUS_OVERFLOW, ZIX_STATUS_NOT_SUPPORTED, + ZIX_STATUS_UNAVAILABLE, } ZixStatus; /// Return a string describing a status code diff --git a/include/zix/sem.h b/include/zix/sem.h index 4c82f17..41b9860 100644 --- a/include/zix/sem.h +++ b/include/zix/sem.h @@ -97,8 +97,9 @@ zix_sem_wait(ZixSem* ZIX_NONNULL sem); /** Non-blocking version of wait(). - @return #ZIX_STATUS_SUCCESS if `sem` was decremented, #ZIX_STATUS_TIMEOUT if - it was already zero, or #ZIX_STATUS_BAD_ARG if `sem` is invalid. + @return #ZIX_STATUS_SUCCESS if `sem` was decremented, + #ZIX_STATUS_UNAVAILABLE if it was already zero, or #ZIX_STATUS_BAD_ARG if + `sem` is invalid. */ ZIX_API ZixStatus diff --git a/include/zix/thread.h b/include/zix/thread.h index bad939f..482315a 100644 --- a/include/zix/thread.h +++ b/include/zix/thread.h @@ -103,9 +103,9 @@ zix_thread_create(ZixThread* thread, pthread_attr_setstacksize(&attr, stack_size); const int ret = pthread_create(thread, NULL, function, arg); - pthread_attr_destroy(&attr); - return ret == EAGAIN ? ZIX_STATUS_NO_MEM : zix_errno_status(ret); + pthread_attr_destroy(&attr); + return zix_errno_status(ret); } static inline ZixStatus -- cgit v1.2.1