From 741c3349b09c8774fcd013e3bdd7d9e7f6b470ce Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 31 Dec 2020 15:15:05 +0100 Subject: Format all code with clang-format --- zix/thread.h | 71 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 36 insertions(+), 35 deletions(-) (limited to 'zix/thread.h') diff --git a/zix/thread.h b/zix/thread.h index 3989f13..8fa562d 100644 --- a/zix/thread.h +++ b/zix/thread.h @@ -20,10 +20,10 @@ #include "zix/common.h" #ifdef _WIN32 -# include +# include #else -# include -# include +# include +# include #endif #include @@ -54,8 +54,8 @@ typedef pthread_t ZixThread; static inline ZixStatus zix_thread_create(ZixThread* thread, size_t stack_size, - void* (*function)(void*), - void* arg); + void* (*function)(void*), + void* arg); /** Join `thread` (block until `thread` exits). @@ -68,53 +68,54 @@ zix_thread_join(ZixThread thread, void** retval); static inline ZixStatus zix_thread_create(ZixThread* thread, size_t stack_size, - void* (*function)(void*), - void* arg) + void* (*function)(void*), + void* arg) { - *thread = CreateThread(NULL, stack_size, - (LPTHREAD_START_ROUTINE)function, arg, - 0, NULL); - return *thread ? ZIX_STATUS_SUCCESS : ZIX_STATUS_ERROR; + *thread = CreateThread( + NULL, stack_size, (LPTHREAD_START_ROUTINE)function, arg, 0, NULL); + return *thread ? ZIX_STATUS_SUCCESS : ZIX_STATUS_ERROR; } static inline ZixStatus zix_thread_join(ZixThread thread, void** retval) { - (void)retval; + (void)retval; - return WaitForSingleObject(thread, INFINITE) - ? ZIX_STATUS_SUCCESS : ZIX_STATUS_ERROR; + return WaitForSingleObject(thread, INFINITE) ? ZIX_STATUS_SUCCESS + : ZIX_STATUS_ERROR; } -#else /* !defined(_WIN32) */ +#else /* !defined(_WIN32) */ static inline ZixStatus zix_thread_create(ZixThread* thread, size_t stack_size, - void* (*function)(void*), - void* arg) + void* (*function)(void*), + void* arg) { - pthread_attr_t attr; - pthread_attr_init(&attr); - pthread_attr_setstacksize(&attr, stack_size); - - const int ret = pthread_create(thread, NULL, function, arg); - pthread_attr_destroy(&attr); - - switch (ret) { - case EAGAIN: return ZIX_STATUS_NO_MEM; - case EINVAL: return ZIX_STATUS_BAD_ARG; - case EPERM: return ZIX_STATUS_BAD_PERMS; - } - - return ret ? ZIX_STATUS_ERROR : ZIX_STATUS_SUCCESS; + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setstacksize(&attr, stack_size); + + const int ret = pthread_create(thread, NULL, function, arg); + pthread_attr_destroy(&attr); + + switch (ret) { + case EAGAIN: + return ZIX_STATUS_NO_MEM; + case EINVAL: + return ZIX_STATUS_BAD_ARG; + case EPERM: + return ZIX_STATUS_BAD_PERMS; + } + + return ret ? ZIX_STATUS_ERROR : ZIX_STATUS_SUCCESS; } static inline ZixStatus zix_thread_join(ZixThread thread, void** retval) { - return pthread_join(thread, retval) - ? ZIX_STATUS_ERROR : ZIX_STATUS_SUCCESS; + return pthread_join(thread, retval) ? ZIX_STATUS_ERROR : ZIX_STATUS_SUCCESS; } #endif @@ -125,7 +126,7 @@ zix_thread_join(ZixThread thread, void** retval) */ #ifdef __cplusplus -} /* extern "C" */ +} /* extern "C" */ #endif -#endif /* ZIX_THREAD_H */ +#endif /* ZIX_THREAD_H */ -- cgit v1.2.1