Skip to content

Commit

Permalink
Try another fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmf01 committed Jul 10, 2023
1 parent d7c053e commit 7ff207f
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions src/libFLAC/stream_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,33 @@
/* Mac does have sem_init, but it doesn't work */
#include <dispatch/dispatch.h>
typedef dispatch_semaphore_t sem_t;
#define sem_init(sem,x,val) ((*sem = dispatch_semaphore_create(val)) == NULL)
#define sem_post(sem) dispatch_semaphore_signal(*sem)
#define sem_wait(sem) dispatch_semaphore_wait(*sem, DISPATCH_TIME_FOREVER)
#define sem_destroy(sem) dispatch_release(*sem)
static int sem_init(sem_t *sem, int is_shared, unsigned int value)
{
(void)is_shared;
if((*sem = dispatch_semaphore_create (value)) == NULL)
return -1;
else
return 0;
}

static int sem_post(sem_t *sem)
{
dispatch_semaphore_signal(*sem);
return 0;
}

static int sem_wait(sem_t *sem)
{
dispatch_semaphore_wait(*sem, DISPATCH_TIME_FOREVER);
return 0;
}

static int sem_destroy(sem_t *sem)
{
dispatch_release(*sem);
return 0;
}

#else
#include <semaphore.h>
#endif
Expand Down

0 comments on commit 7ff207f

Please sign in to comment.