Opened 10 years ago

Closed 10 years ago

Last modified 7 years ago

#7141 closed Bugs (fixed)

smart_ptr sp_has_sync.hpp should use gcc builtin atomics when available on ARM

Reported by: anonymous Owned by: Peter Dimov
Milestone: To Be Determined Component: smart_ptr
Version: Boost 1.51.0 Severity: Problem
Keywords: Cc:

Description

I am the lucky owner of a Raspberry Pi, and I have been trying to compile some code that uses boost shared_ptr on it (with the Raspbian armhf distro with boost 1.49 and gcc 4.6.3).

I get a lot of "Warning: swp{b} use is deprecated for this architecture", some of which originate from spinlock_arm_gcc.hpp.

I realized that this was fixed in 1.50, but after a bit of looking around I realized that gcc 4.6.3 actually has support for the builtin atomics on this platform, so that sp_has_sync.hpp should make smart_ptr use them instead of trying the assembler stuff in spinlock_arm_gcc.hpp.

So I propose the following fix to sp_has_sync.hpp:

#define BOOST_SP_HAS_SYNC
  
+ #if !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
+ 
  #if defined( __arm__ )  || defined( __armel__ )
  #undef BOOST_SP_HAS_SYNC
  #endif
  
+ #endif // __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
+ 
  #if defined( __hppa ) || defined( __hppa__ )
  #undef BOOST_SP_HAS_SYNC
  #endif

I maybe more of the platforms can check for the builtins, but I leave that to those who know more about them... Also maybe the ..._SWAP_8 would have to be used for some of them instead?

Of course I know that the __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 is actually not defined for all gcc versions where the builtins are available, but here we at least will use them when that symbol is defined, rather than not at all.

I have written a similar ticket #7140 for boost asio, which suffers a similar problem.

Change History (6)

comment:1 by lars@…, 10 years ago

Component: Nonesmart_ptr
Owner: set to Peter Dimov

comment:2 by Peter Dimov, 10 years ago

(In [81128]) Define BOOST_SP_HAS_SYNC when GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 is set. Refs #7141.

comment:3 by Peter Dimov, 10 years ago

Resolution: fixed
Status: newclosed

(In [81334]) Merged [81128] from trunk. Fixes #7141.

comment:4 by anonymous, 7 years ago

erererer

comment:5 by anonymous, 7 years ago

yes i do

Note: See TracTickets for help on using tickets.