
"Jonathan Wakely" <cow@compsoc.man.ac.uk> wrote in message news:20050404134320.GA88664@compsoc.man.ac.uk...
Out of interest, why can't you just use _SC_THREAD_SAFE_FUNCTIONS if it's defined?
Also, if _POSIX_THREAD_SAFE_FUNCTIONS == 0, I thought that meant *not* supported (in which case sysconf() would return -1) ? Does the test have to be >= not just > ?
I'd have written it:
# if defined(_SC_THREAD_SAFE_FUNCTIONS) if ( ::sysconf( _SC_THREAD_SAFE_FUNCTIONS ) > 0 ) { return ::readdir_r( dirp, entry, result ); } # endif
But I didn't realise this wasn't good enough :-|
This is the first time I've ever used the POSIX config mechanisms, so I may have it wrong. I'll check... Hum... I find the POSIX docs for sysconf() pretty impeneratable regarding the return value. I can see why I took >=0 to be needed, but I could also read it in a way that >0 would be OK. Any POSIX experts out there?
Finally, readdir_r() is available on FreeBSD even though neither _POSIX_THREAD_SAFE_FUNCTIONS not _SC_THREAD_SAFE_FUNCTIONS is defined. I don't know how to test for it though, FreeBSD's sysconf() only claims to support POSIX 1990, even though some later interfaces are available.
Someone with access to that system needs to figure out what PP macro to look for. Thanks, --Beman