Boost logo

Boost :

From: S G Ganesh (sgganesh_at_[hidden])
Date: 2005-06-21 00:30:32

Hi Toon, Caleb Epstein, Beman, Thomas Matelich,

>> > Does anybody now any other flag that might influence this?
>> Is it normal (never used readdir_r myself) that it is only defined in
>> > multi-threading-mode?
>From manpage of readdir_r:

      "Users of readdir_r() should note that readdir_r() now conforms with
      the POSIX.1c Threads standard. The old prototype of readdir_r() is
      supported for compatibility with existing DCE applications only."

_r denotes reentrant functions and -mt enables the following (for default
-AA mode for aCC/Itanium):

    * -D_POSIX_C_SOURCE=199506L
    * -D_HPUX_SOURCE *
    * -lpthread

>> Should we instruct bbv1 to compile the boost.filesystem always with the -mt
flag on hpux ?

>> 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.

>> 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:
>> && defined(_SC_THREAD_SAFE_FUNCTIONS) \
>> 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).

>> Perhaps you can check what _POSIX_THREAD_SAFE_FUNCTIONS is defined to
>> on aCC both with and without -mt? On Linux 2.4.21 + gcc 3.3.4, I get
>> 200112 both with -pthread and without.
>> #include <pthread.h>
>> #include <iostream>
>> int main () { std::cout << _POSIX_THREAD_SAFE_FUNCTIONS <<
>> std::endl; }

It will fail in aCC if <unistd.h> is not included since -mt doesn't set these

>> HP isn't like MS where you need uniform
>> mt or not across all translation units if you want happiness, but I
>> wouldn't think you'd want to enable mt settings behind the users' back.

I'm afraid its not, -mt needs to be defined consistently, otherwise there can
be unexpected runtime problems.

>> > Since somebody suggested that _REENTRANT is defined on HP
>> when the '-mt' flag is used, what about only adding adding following to this
>> >
>> > # if defined(_POSIX_THREAD_SAFE_FUNCTIONS) \
>> > && defined(_SC_THREAD_SAFE_FUNCTIONS) \
>> > || (defined(__HP_aCC) && defined(_REENTRANT))
>> I don't use boost build, but I thought the existing ifdef
>> block seemed like it should work. I don't know much about HPUX on Itanium,
but I
>> went grepping on my HP 11i box, and found the
>> _POSIX_THREAD_SAFE_FUNCTIONS define in /usr/include/sys/unistd.h.

>> Then I remembered that to use the new posix friendly APIs on 11i, you
>> need a -D_POSIX_C_SOURCE=199506L. I'd bet that if you added that to
>> your build, things would work a lot more nicely. I think that define
>> is only contra-indicated if you're still trying to use CMA threads
>> (which is not a good idea).
Yes, but setting -mt will take care of it. But I don't think its needed for the
check we are doing here.

>> If you do end up needing a modification of the define block
>> above, I'd recommend __hpux rather than __HP_aCC since this is a platform
>> rather than a compiler issue.
But, the problem is not with using g++ on HP-UX.

>> > || (defined(__HP_aCC) && defined(_REENTRANT))
I presume no change is needed if it is ensured (with a #ifdef guard?) that
<unistd.h> is included before the check.


Boost list run by bdawes at, gregod at, cpdaniel at, john at