Opened 5 years ago

Closed 5 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:


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:

< #elif defined(__GNUC__) && defined(__arm__)
> #elif defined(__GNUC__) && defined(__arm__) && !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
< #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.

Attachments (0)

Change History (2)

comment:1 Changed 5 years ago by lars@…

The smart_ptr ticket is #7141, for reference.

comment:2 Changed 5 years ago by chris_kohlhoff

  • Resolution set to fixed
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain chris_kohlhoff.
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.