sem                21 gc/include/private/darwin_semaphore.h static int sem_init(sem_t *sem, int pshared, int value) {
sem                25 gc/include/private/darwin_semaphore.h     sem->value = value;
sem                27 gc/include/private/darwin_semaphore.h     ret = pthread_mutex_init(&sem->mutex,NULL);
sem                29 gc/include/private/darwin_semaphore.h     ret = pthread_cond_init(&sem->cond,NULL);
sem                34 gc/include/private/darwin_semaphore.h static int sem_post(sem_t *sem) {
sem                35 gc/include/private/darwin_semaphore.h     if(pthread_mutex_lock(&sem->mutex) < 0)
sem                37 gc/include/private/darwin_semaphore.h     sem->value++;
sem                38 gc/include/private/darwin_semaphore.h     if(pthread_cond_signal(&sem->cond) < 0) {
sem                39 gc/include/private/darwin_semaphore.h         pthread_mutex_unlock(&sem->mutex);
sem                42 gc/include/private/darwin_semaphore.h     if(pthread_mutex_unlock(&sem->mutex) < 0)
sem                47 gc/include/private/darwin_semaphore.h static int sem_wait(sem_t *sem) {
sem                48 gc/include/private/darwin_semaphore.h     if(pthread_mutex_lock(&sem->mutex) < 0)
sem                50 gc/include/private/darwin_semaphore.h     while(sem->value == 0) {
sem                51 gc/include/private/darwin_semaphore.h         pthread_cond_wait(&sem->cond,&sem->mutex);
sem                53 gc/include/private/darwin_semaphore.h     sem->value--;
sem                54 gc/include/private/darwin_semaphore.h     if(pthread_mutex_unlock(&sem->mutex) < 0)
sem                59 gc/include/private/darwin_semaphore.h static int sem_destroy(sem_t *sem) {
sem                61 gc/include/private/darwin_semaphore.h     ret = pthread_cond_destroy(&sem->cond);
sem                63 gc/include/private/darwin_semaphore.h     ret = pthread_mutex_destroy(&sem->mutex);