Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-01-11 12:49:52


Jerry Lawson wrote:
> On sparc/gcc environment, boost/detail/sp_counted_base.hpp will use
> sp_counted_base_pt.hpp, which of course implements counter protection
> via pthread_mutex operations. Other gcc-environments (x86, x64, ia64,
> ppc) have the concept of using asm directives for atomic increment &
> decrement, which obviously is more efficient than the mutex
> operations.
>
> The boost/detail/atomic_count_gcc.hpp implementation seems like a more
> efficient mechanism for incrementing/decrementing the shared_ptr
> reference counters. In fact, the shared_ptr_nmt.hpp implementation
> does use boost::detail::atomic_count for the reference count (albeit
> directly, rather than through the shared_count template).
>
> I am using atomic_count as the basis for my internal reference
> counting for my intrusive_ptr-based objects and am happy with this.
>
> So I'm curious as to why sp_counted_base.hpp does not use the atomic
> increment/decrement model for sparc/gcc that it does for other gcc
> environments?

The primitives supplied by g++ were not enough to support sp_counted_base
(although this is going to change in 4.2, I think). There is an assembly
language version scheduled for 1.35 in the CVS. You can play with it by
downloading

http://boost.cvs.sourceforge.net/*checkout*/boost/boost/boost/detail/sp_counted_base_gcc_sparc.hpp

and applying the patch

http://boost.cvs.sourceforge.net/boost/boost/boost/detail/sp_counted_base.hpp?r1=1.8&r2=1.9

There is currently a problem with 64-bit SPARCs in 32-bit mode, where the
default architecture isn't v9 (g++ doesn't support the notion of v8+). We're
looking into fixing that on the bjam side.


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