From c4ce5b5ae07436a28fe4b1869b202de8637611d1 Mon Sep 17 00:00:00 2001 From: David Griffith Date: Thu, 19 Sep 2019 19:21:57 -0700 Subject: [PATCH] Convert ux_sema.h to K&R style. --- src/curses/ux_sema.h | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/curses/ux_sema.h b/src/curses/ux_sema.h index ea1140b..87d8e7c 100644 --- a/src/curses/ux_sema.h +++ b/src/curses/ux_sema.h @@ -33,66 +33,74 @@ #ifdef MACOS #include struct ux_sema { - dispatch_semaphore_t dsem; + dispatch_semaphore_t dsem; }; typedef struct ux_sema ux_sem_t; + /* * Note that the current implementation does not check return codes * so use void to make things simpler on the MAC side */ static inline void ux_sem_init(ux_sem_t *sem, int pshared, unsigned int value) { - dispatch_semaphore_t *sema = &sem->dsem; - (void) pshared; + dispatch_semaphore_t *sema = &sem->dsem; + (void) pshared; - *sema = dispatch_semaphore_create(value); + *sema = dispatch_semaphore_create(value); } + static inline void ux_sem_post(ux_sem_t *sem) { - if (sem->dsem != NULL) - dispatch_semaphore_signal(sem->dsem); + if (sem->dsem != NULL) + dispatch_semaphore_signal(sem->dsem); } + static inline void ux_sem_wait(ux_sem_t *sem) { - if (sem->dsem != NULL) - dispatch_semaphore_wait(sem->dsem, DISPATCH_TIME_FOREVER); + if (sem->dsem != NULL) + dispatch_semaphore_wait(sem->dsem, DISPATCH_TIME_FOREVER); } + static inline int ux_sem_trywait(ux_sem_t *sem) { - if (sem->dsem != NULL) - return (int) dispatch_semaphore_wait(sem->dsem, DISPATCH_TIME_NOW); - return -1; + if (sem->dsem != NULL) + return (int) dispatch_semaphore_wait(sem->dsem, DISPATCH_TIME_NOW); + return -1; } #else #include typedef sem_t ux_sem_t; + /* * Note that the current implementation does not check return codes * so use void to make things simpler on the MAC side */ static inline void ux_sem_init(ux_sem_t *sem, int pshared, unsigned int value) { - (void) sem_init(sem, pshared, value); + (void) sem_init(sem, pshared, value); } + static inline void ux_sem_post(ux_sem_t *sem) { - (void) sem_post(sem); + (void) sem_post(sem); } + static inline void ux_sem_wait(ux_sem_t *sem) { - (void) sem_wait(sem); + (void) sem_wait(sem); } + static inline int ux_sem_trywait(ux_sem_t *sem) { - return sem_trywait(sem); + return sem_trywait(sem); } #endif -- 2.34.1