From 564b957cc31a33124a935ea8678e5bbb710fc082 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 10 Sep 2014 03:09:41 +0200 Subject: osdep: add POSIX semaphore emulation for OSX OSX is POSIX conformant, but it's a sad joke: it provides the prototype as the standard demands, but they're empty wrappers, and all functions just return ENOSYS. Emulate them similar to how osdep/io.h emulate filesystem functions on Windows. By including the header, working sem_* functions become available. To make it async-signal safe, use a pipe for wakeup (write() is AS-safe, but mutexes can't be). Actually I'm not sure anymore if we really need AS-safety, but for now the emulation can do it. On Linux, the system provides a far more efficient and robust implementation. We definitely want to avoid using the emulation if possible, so this code is active on OSX only. For convenience we always build the source file though, even if the implementation is disabled and no actual code is generated. (Linux provides working semaphores, but is formally not POSIX conformant. On OSX it's the opposite. Is POSIX a complete joke?) --- wscript_build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wscript_build.py') diff --git a/wscript_build.py b/wscript_build.py index 2f19c14f03..95161c134b 100644 --- a/wscript_build.py +++ b/wscript_build.py @@ -382,8 +382,8 @@ def build(ctx): ( "osdep/ar/HIDRemote.m", "cocoa" ), ( "osdep/macosx_application.m", "cocoa-application" ), ( "osdep/macosx_events.m", "cocoa" ), + ( "osdep/semaphore_osx.c" ), ( "osdep/path-macosx.m", "cocoa" ), - ( "osdep/path-win.c", "os-win32" ), ( "osdep/path-win.c", "os-cygwin" ), ( "osdep/glob-win.c", "glob-win32-replacement" ), -- cgit v1.2.3