[vlc-devel] [PATCH] Use Mach semaphores on Mac OS X

Jan-Hinrich Fessel oskar at fessel.org
Thu May 6 20:02:40 CEST 2010

Am 06.05.2010 um 16:59 schrieb Juho Vähä-Herttua:

> On 6.5.2010, at 16.15, Juho Vähä-Herttua wrote:
>> There's one problem with the patch. It calls for VLC_THREAD_ASSERT  
>> that calls vlc_thread_fatal on debug, which in turn calls  
>> strerror_r, which fails because the return value is not errno value  
>> but instead kern_return_t. ILEoo also mentioned that after  
>> semaphore_destroy the condition should be val == KERN_SUCCESS  
>> instead of != check.
> Last patch was complete crap: in addition to the above,  
> semaphore_destroy didn't reference the pointer, error code path of  
> vlc_sem_post didn't return a value correctly on non-Mac platform.  
> Second attempt included, I used EINVAL for all error cases since it  
> was easy and VLC_THREAD_ASSERT is already there.

Couldn't you just use the standard semaphore calls as defined in  
<semaphore.h> resp. <sys/semaphore.h>
where it states:

int sem_close(sem_t *);
int sem_destroy(sem_t *);
int sem_getvalue(sem_t * __restrict, int * __restrict);
int sem_init(sem_t *, int, unsigned int);
sem_t * sem_open(const char *, int, ...);
int sem_post(sem_t *);
int sem_trywait(sem_t *);
int sem_unlink(const char *);
int sem_wait(sem_t *) __DARWIN_ALIAS_C(sem_wait);

#endif  /* _SYS_SEMAPHORE_H_ */

More information about the vlc-devel mailing list