
S G Ganesh wrote:
Yes that seems eminently reasonable (that readdir_r only be prototyped/available if -mt is supplied).
Yes, since readdir_r is specifically for multithreaded code.
but it is guarded with the code below
Well, there is code in libs/filesystem/src/operations_posix_windows.cpp that
attempts to
detect if it is being compiled with multi-threading enabled:
# if defined(_POSIX_THREAD_SAFE_FUNCTIONS) \ && defined(_SC_THREAD_SAFE_FUNCTIONS) \ && (_POSIX_THREAD_SAFE_FUNCTIONS+0 >= 0) Presumably aCC sets these macros incorrectly, or this code is not correct. Maybe the check should be for >0?
They are defined in <sys/unistd.h> (but the check will fail if the header file is not included).
The problem seems to be that the header unistd.h is included. Apparantly unistd.h always defines the above tokens, even if the '-mt' flag is not passed on to the compiler. I tested this in a small test-program: <tt.cpp> #include <unistd.h> #include <iostream int main() { std::cout << _POSIX_THREAD_SAFE_FUNCTIONS << std::endl ; std::cout << _SC_THREAD_SAFE_FUNCTIONS << std::endl ; std::cout << _POSIX_THREAD_SAFE_FUNCTIONS << std::endl ; return 0 ; } </tt.cpp> And 'aCC -AA tt.cpp ; ./a.out' gives : <cout> 1 441 1 </cout> Next 'aCC -AA -mt tt.cpp ; ./a.out' gives exactly the same output. So it's clear that the current testing of _POSIX_THREAD_SAFE_FUNCTIONS, _SC_THREAD_SAFE_FUNCTIONS and _POSIX_THREAD_SAFE_FUNCTIONS does not suffice. Thus I still think it's best to expand the #if test to: # if defined(_POSIX_THREAD_SAFE_FUNCTIONS) \ && defined(_SC_THREAD_SAFE_FUNCTIONS) \ && (_POSIX_THREAD_SAFE_FUNCTIONS+0 >= 0) \ && ( !defined(__HP_aCC) \ || ( (defined(__HP_aCC) && defined(_REENTRANT) ) to make sure that, in case we're compiling with HP-aCC, we also check that the token _REENTRANT is defined.