http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49745
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-07-14 12:33:16 UTC --- svn blame isn't hard to use. You'll find out that the unistd.h include was added by http://gcc.gnu.org/ml/gcc-patches/2002-10/msg01666.html There are still some of the unistd.h guard macros used in gthr*, so you can't just drop that. But, two of the three macros are limited to libobjc (the scheduling stuff), so if it wasn't for _POSIX_TIMEOUTS for __gthread_mutex_timedwait, you could guard the unistd.h include with #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK) Unfortunately, the remaining one, _POSIX_TIMEOUTS and defining __gthread_mutex_timedlock if it is present, is used in libstdc++ (<mutex> in particular, and apparently unconditionally there, so it will just not compile on prehistoric OSes which lack pthread_mutex_timedlock or on systems that don't use gthr-posix.h but other gthr-*.h headers instead). So, if you want to avoid including unistd.h, you'd need to e.g. add some configure test in libstdc++ and in gthr-posix.h use #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK) \ || !defined(_GTHR_HAS_POSIX_TIMEOUTS) #include <unistd.h> #ifdef _POSIX_TIMEOUTS #define _GTHR_HAS_POSIX_TIMEOUTS _POSIX_TIMEOUTS #endif #endif and use _GTHR_HAS_POSIX_TIMEOUTS instead of _POSIX_TIMEOUTS in gthr.h and arrange for libstdc++ headers to define _GTHR_HAS_POSIX_TIMEOUTS based on whether <unistd.h> defines _POSIX_TIMEOUTS.