Modify

Ticket #7140 (closed Bugs: fixed)

Opened 21 months ago

Last modified 21 months ago

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.

Attachments

Change History

comment:1 Changed 21 months ago by lars@…

The smart_ptr ticket is #7141, for reference.

comment:2 Changed 21 months ago by chris_kohlhoff

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

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

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


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

 
Note: See TracTickets for help on using tickets.