Boost logo

Boost :

From: Jonathan Wakely (cow_at_[hidden])
Date: 2004-05-12 07:05:11


On Wed, May 12, 2004 at 11:35:15AM +0100, John Maddock wrote:

>
> It looks as though _GLIBCXX_HAVE_GTHR_DEFAULT is defined by the std lib when
> it's in thread safe mode, so I'm leaning towards adding:
>
> #ifdef __GLIBCXX__ // gcc 3.4 and greater:
> #ifdef _GLIBCXX_HAVE_GTHR_DEFAULT
> #define BOOST_HAS_THREADS
> #else
> #define BOOST_DISABLE_THREADS
> #endif
> #endif
>
> To our libstdcpp3.hpp config file, which I think will take care of it,
> albeit not in a way that everyone will appreciate (it will force threading
> on whenever the std lib is also thread safe).

That's the current behaviour anyway - if the library was configured to
be threadsafe then _REENTRANT will be defined and threading is forced
on by Boost.

I think your fix is an improvement, since AFAICT _REENTRANT is not
defined for all threading models in GCC 3.4 (only "posix") whereas
_GLIBCXX_HAVE_GTHR_DEFAULT should be defined for any thread model except
"single" (which is what we want).

It might be that the only option for GCC 3.4 users is to either define
BOOST_DISABLE_THREADS or add -pthread to the compiler flags.

Looking at the GCC sources under gcc/config/ it appears that some
platforms (e.g. Solaris2, NetBSD, Linux on certain architectures) define
_PTHREADS when -pthread is used. x86-linux is not one of those platforms,
nor is FreeBSD. It might be possible to get that macro, or something else,
defined on all platforms when -pthread is given so Boost could check for
that.

Cristoph, did you ever ask about this issue on the "gcc" list, or just
"gcc-help" ?

jon

-- 
Atilla The Hun's Maxim:
"If you're going to rape, pillage and burn, be sure to do things in that order."
	- P. J. Plauger, Programming On Purpose

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk