Very frustrating week.
I've been working on bringing up the ixmatch engine on OS/X 10.3. Which, by itself, would be a pretty cool project. I had lots of cruft in linux-dependant makefiles to clean up and code to rearrange, all of which was expected. After a couple days of learning XCode, I was able to get it all brought in and building.
Then the fun started.
The engine uses the POSIX sem_wait(3) and sem_signal(3) calls. Mac OS/X defines these, but they return 78 - which is errno-ese for Function Not Implemented. Oh joy.
So, I think to myself "self, you're porting to a mach-based OS. Remember all the fun of coding for NeXTStep? This is a real os core, there are happy little mutex, semaphore, and rwlock primitives hiding down there - go look in /usr/include/mach."
So I do. And there's no mutexes in there. WTF?
So, I go off to start implementing stuff using pthreads, which looked OK. pthreads has mutexes. But no semaphores. It has condition variables, but not semaphores, and condition variables don't look to be as useful as semaphores. Another wasted day of research and prototyping.
Turns out that OS/X does expose semaphores in /usr/include/mach (but not mutexes), and I can do a mutex with a semaphore, which is what I ended up doing, after some long and tedious detours into Kernel.framework and IOKit.framework, none of which was very happy. I also looked at the SysV semaphore set stuff which has been added to darwin, which just looked confusing.