omniorb/thread: use proper autoconf macros for header inclusion src/lib/omnithread/posix.cc uses sleep() and usleep(), defined in on numerous platforms, and struct timeval/gettimeofday(), defined in on various platforms. Since those header files are not available on all platforms, posix.cc currently uses the following condition: #if (defined(__GLIBC__) && __GLIBC__ >= 2) || defined(__SCO_VERSION__) || defined(__aix__) || defined (__cygwin__) || defined(__darwin__) || defined(__macos__) Unfortunately, this falls short on Linux systems based on the musl C library. Indeed, the musl C library does not define the __GLIBC__ symbol, but does have the sleep()/usleep() definitions in , and the struct timeval/gettimeofday() definitions in , like any Linux system. Also, the musl C library does not define any constant like __MUSL__ to distinguish it. Due to this, on musl based systems, and are not included, causing a build failure: posix.cc:864:22: error: '::sleep' has not been declared while ((secs = ::sleep(secs))) ; ^ posix.cc:866:43: error: 'usleep' was not declared in this scope usleep(secs * 1000000 + (nanosecs / 1000)); ^ posix.cc: In static member function 'static void omni_thread::get_time(long unsigned int*, long unsigned int*, long unsigned int, long unsigned int)': posix.cc:904:20: error: aggregate 'omni_thread::get_time(long unsigned int*, long unsigned int*, long unsigned int, long unsigned int)::timeval tv' has incomplete type and cannot be defined struct timeval tv; ^ posix.cc:905:24: error: 'gettimeofday' was not declared in this scope gettimeofday(&tv, 0); It turns out that the configure.ac already checks for the availability of and . So all what this patch does is use the C defines generated by the configure script to decide whether and can be included or not. Signed-off-by: Thomas Petazzoni Index: b/src/lib/omnithread/posix.cc =================================================================== --- a/src/lib/omnithread/posix.cc +++ b/src/lib/omnithread/posix.cc @@ -78,10 +78,14 @@ #include #include #include +#include -#if (defined(__GLIBC__) && __GLIBC__ >= 2) || defined(__SCO_VERSION__) || defined(__aix__) || defined (__cygwin__) || defined(__darwin__) || defined(__macos__) // typedef of struct timeval and gettimeofday(); +#if defined(HAVE_SYS_TIME_H) #include +#endif + +#if defined(HAVE_UNISTD_H) #include #endif