diff options
Diffstat (limited to 'src/microhttpd/mhd_locks.h')
-rw-r--r-- | src/microhttpd/mhd_locks.h | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/src/microhttpd/mhd_locks.h b/src/microhttpd/mhd_locks.h index cf10c0d1..1d8376f0 100644 --- a/src/microhttpd/mhd_locks.h +++ b/src/microhttpd/mhd_locks.h @@ -22,8 +22,9 @@ * @file microhttpd/mhd_locks.h * @brief Header for platform-independent locks abstraction * @author Karlson2k (Evgeny Grin) + * @author Christian Grothoff * - * Provides basic abstraction for locks and mutex. + * Provides basic abstraction for locks/mutex and semaphores. * Any functions can be implemented as macro on some platforms * unless explicitly marked otherwise. * Any function argument can be skipped in macro, so avoid @@ -147,4 +148,48 @@ #define MHD_mutex_unlock_(pmutex) (LeaveCriticalSection((pmutex)), !0) #endif + +/** + * A semaphore. + */ +struct MHD_Semaphore; + + +/** + * Create a semaphore with an initial counter of @a init + * + * @param init initial counter + * @return the semaphore, NULL on error + */ +struct MHD_Semaphore * +MHD_semaphore_create (unsigned int init); + + +/** + * Count down the semaphore, block if necessary. + * + * @param sem semaphore to count down. + */ +void +MHD_semaphore_down (struct MHD_Semaphore *sem); + + +/** + * Increment the semaphore. + * + * @param sem semaphore to increment. + */ +void +MHD_semaphore_up (struct MHD_Semaphore *sem); + + +/** + * Destroys the semaphore. + * + * @param sem semaphore to destroy. + */ +void +MHD_semaphore_destroy (struct MHD_Semaphore *sem); + + #endif /* ! MHD_LOCKS_H */ |