http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51906
--- Comment #31 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-01-31 11:23:55 UTC --- (In reply to comment #30) > it outputs "22" and it returns 0 with _XOPEN_SOURCE defined? > which appears to be... > > > The pthread_mutex_lock() and pthread_mutex_trylock() functions shall > fail if: > > EINVAL The mutex was created with the protocol attribute having the > value PTHREAD_PRIO_PROTECT and the calling thread's priority is > higher than the mutex's current priority ceiling. That's the POSIX spec, but priorities don't apply to that test. The Mac OS X pthread_mutex_trylock(3) man page (which doesn't seem to have been updated since it was copied from BSD) says simply [EINVAL] The value specified by mutex is invalid. and the pthread(3) man page says "The default system libraries include pthread functions. No additional libraries or CFLAGS are necessary to use this API" which isn't true if _XOPEN_SOURCE is needed.