From bf1d972d5c397125d879d6334c84012f166af9eb Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 10 Aug 2022 18:11:57 +0200 Subject: [PATCH] Cygwin: move POSIX semaphore API functions to posix_ipc.cc This way, the sem API is all in the same place, even if the underlying semaphore class is still in thread.cc. Signed-off-by: Corinna Vinschen --- winsup/cygwin/posix_ipc.cc | 48 ++++++++++++++++++++++++++++++++++++ winsup/cygwin/thread.cc | 50 -------------------------------------- 2 files changed, 48 insertions(+), 50 deletions(-) diff --git a/winsup/cygwin/posix_ipc.cc b/winsup/cygwin/posix_ipc.cc index 68d66e410..34fd2ba34 100644 --- a/winsup/cygwin/posix_ipc.cc +++ b/winsup/cygwin/posix_ipc.cc @@ -518,3 +518,51 @@ sem_unlink (const char *name) return -1; return 0; } + +extern "C" int +sem_init (sem_t * sem, int pshared, unsigned int value) +{ + return semaphore::init (sem, pshared, value); +} + +extern "C" int +sem_destroy (sem_t * sem) +{ + return semaphore::destroy (sem); +} + +extern "C" int +sem_wait (sem_t * sem) +{ + return semaphore::wait (sem); +} + +extern "C" int +sem_trywait (sem_t * sem) +{ + return semaphore::trywait (sem); +} + +extern "C" int +sem_clockwait (sem_t * sem, clockid_t clock_id, const struct timespec *abstime) +{ + return semaphore::clockwait (sem, clock_id, abstime); +} + +extern "C" int +sem_timedwait (sem_t * sem, const struct timespec *abstime) +{ + return semaphore::clockwait (sem, CLOCK_REALTIME, abstime); +} + +extern "C" int +sem_post (sem_t *sem) +{ + return semaphore::post (sem); +} + +extern "C" int +sem_getvalue (sem_t * sem, int *sval) +{ + return semaphore::getvalue (sem, sval); +} diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index d818e8060..5c1284a93 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -4559,54 +4559,4 @@ pthread_getcpuclockid (pthread_t thread, clockid_t *clk_id) return 0; } -/* Semaphores */ - -int -sem_init (sem_t * sem, int pshared, unsigned int value) -{ - return semaphore::init (sem, pshared, value); -} - -int -sem_destroy (sem_t * sem) -{ - return semaphore::destroy (sem); -} - -int -sem_wait (sem_t * sem) -{ - return semaphore::wait (sem); -} - -int -sem_trywait (sem_t * sem) -{ - return semaphore::trywait (sem); -} - -int -sem_clockwait (sem_t * sem, clockid_t clock_id, const struct timespec *abstime) -{ - return semaphore::clockwait (sem, clock_id, abstime); -} - -int -sem_timedwait (sem_t * sem, const struct timespec *abstime) -{ - return semaphore::clockwait (sem, CLOCK_REALTIME, abstime); -} - -int -sem_post (sem_t *sem) -{ - return semaphore::post (sem); -} - -int -sem_getvalue (sem_t * sem, int *sval) -{ - return semaphore::getvalue (sem, sval); -} - }