Opened 10 years ago

Closed 10 years ago

#7140 closed Bugs (fixed)

asio fenced_block should use gcc builtin atomics when available on ARM

Reported by: lars@… Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
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 asio 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 gcc_arm_fenced_block.hpp.

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 gcc_sync_fenced_block.hpp could be used intead of trying to fix the assembler stuff in gcc_arm_fenced_block.hpp.

So I propose the following fix to fenced_block.hpp:

28c28
< #elif defined(__GNUC__) && defined(__arm__)
---
> #elif defined(__GNUC__) && defined(__arm__) && !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
57c57
< #elif defined(__GNUC__) && defined(__arm__)
---
> #elif defined(__GNUC__) && defined(__arm__) && !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)

Basically just skips using the gcc_arm_fenced_block if __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 is defined, and lets the _sync_ one get used 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 will write a similar ticket for boost smart_ptr, which suffers the same problem.

Change History (2)

comment:1 by lars@…, 10 years ago

The smart_ptr ticket is #7141, for reference.

comment:2 by chris_kohlhoff, 10 years ago

Resolution: fixed
Status: newclosed

(In [79694]) Merge from trunk:

  • Decorate GCC attribute names with underscores to prevent interaction with user-defined macros. Fixes #6415
  • Add missing #include of <cctype>, needed for some versions of MinGW.
  • Use gcc's atomic builtins on arm, when available. Fixes #7140.
Note: See TracTickets for help on using tickets.