Skip to content

Commit 2ab2c26

Browse files
committed
slightly suspect changes to get semaphore.c to compile.
The existing code was clearly wrong, but this might not be the right way to fix it either...
1 parent d7fe4b0 commit 2ab2c26

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/semaphore.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -712,10 +712,10 @@ _dispatch_thread_semaphore_create(void)
712712
}
713713
return s4;
714714
#elif USE_POSIX_SEM
715-
sem_t s4;
716-
int ret = sem_init(&s4, 0, 0);
715+
sem_t* s4 = malloc(sizeof(sem_t));
716+
int ret = sem_init(s4, 0, 0);
717717
DISPATCH_SEMAPHORE_VERIFY_RET(ret);
718-
return s4;
718+
return (_dispatch_thread_semaphore_t)s4;
719719
#elif USE_WIN32_SEM
720720
HANDLE tmp;
721721
while (!dispatch_assume(tmp = CreateSemaphore(NULL, 0, LONG_MAX, NULL))) {
@@ -738,8 +738,8 @@ _dispatch_thread_semaphore_dispose(_dispatch_thread_semaphore_t sema)
738738
DISPATCH_VERIFY_MIG(kr);
739739
DISPATCH_SEMAPHORE_VERIFY_KR(kr);
740740
#elif USE_POSIX_SEM
741-
sem_t s4 = (sem_t)sema;
742-
int ret = sem_destroy(&s4);
741+
sem_t *s4 = (sem_t*)sema;
742+
int ret = sem_destroy(s4);
743743
DISPATCH_SEMAPHORE_VERIFY_RET(ret);
744744
#elif USE_WIN32_SEM
745745
// XXX: signal the semaphore?
@@ -762,8 +762,8 @@ _dispatch_thread_semaphore_signal(_dispatch_thread_semaphore_t sema)
762762
kern_return_t kr = semaphore_signal(s4);
763763
DISPATCH_SEMAPHORE_VERIFY_KR(kr);
764764
#elif USE_POSIX_SEM
765-
sem_t s4 = (sem_t)sema;
766-
int ret = sem_post(&s4);
765+
sem_t *s4 = (sem_t*)sema;
766+
int ret = sem_post(s4);
767767
DISPATCH_SEMAPHORE_VERIFY_RET(ret);
768768
#elif USE_WIN32_SEM
769769
int ret;
@@ -788,10 +788,10 @@ _dispatch_thread_semaphore_wait(_dispatch_thread_semaphore_t sema)
788788
} while (slowpath(kr == KERN_ABORTED));
789789
DISPATCH_SEMAPHORE_VERIFY_KR(kr);
790790
#elif USE_POSIX_SEM
791-
sem_t s4 = (sem_t)sema;
791+
sem_t *s4 = (sem_t*)sema;
792792
int ret;
793793
do {
794-
ret = sem_wait(&s4);
794+
ret = sem_wait(s4);
795795
} while (slowpath(ret != 0));
796796
DISPATCH_SEMAPHORE_VERIFY_RET(ret);
797797
#elif USE_WIN32_SEM

0 commit comments

Comments
 (0)