diff --git a/Misc/NEWS b/Misc/NEWS index ccbf416e3a4..726777ec0a8 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -200,6 +200,8 @@ Core and Builtins Library ------- +- Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy. + - Issue #16787: Increase asyncore and asynchat default output buffers size, to decrease CPU usage and increase throughput. diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c index ccd5f017eca..eb3fa0ceb58 100644 --- a/Modules/_multiprocessing/semaphore.c +++ b/Modules/_multiprocessing/semaphore.c @@ -186,6 +186,13 @@ semlock_release(SemLockObject *self, PyObject *args) #define SEM_GETVALUE(sem, pval) sem_getvalue(sem, pval) #define SEM_UNLINK(name) sem_unlink(name) +/* OS X 10.4 defines SEM_FAILED as -1 instead of (sem_t *)-1; this gives + compiler warnings, and (potentially) undefined behaviour. */ +#ifdef __APPLE__ +# undef SEM_FAILED +# define SEM_FAILED ((sem_t *)-1) +#endif + #ifndef HAVE_SEM_UNLINK # define sem_unlink(name) 0 #endif