2
0
mirror of https://github.com/boostorg/atomic.git synced 2026-02-02 20:32:09 +00:00

Fixed compilation with gcc 4.4. Optimized code for gcc older than 4.7 and also added support for 128-bit atomic ops. Completed transition to defaulted and deleted functions.

[SVN r84801]
This commit is contained in:
Andrey Semashev
2013-06-16 13:40:11 +00:00
parent 9cab8a9ebf
commit 55e8b16a12
17 changed files with 1125 additions and 478 deletions

View File

@@ -14,7 +14,8 @@ namespace detail {
namespace {
// This seems to be the maximum across all modern CPUs
enum { cache_line_size = 64 };
// NOTE: This constant is made as a macro because some compilers (gcc 4.4 for one) don't allow enums or regular constants in alignment attributes
#define BOOST_ATOMIC_CACHE_LINE_SIZE 64
template< unsigned int N >
struct padding
@@ -26,11 +27,13 @@ struct padding< 0 >
{
};
struct BOOST_ALIGNMENT(cache_line_size) padded_lock
struct BOOST_ALIGNMENT(BOOST_ATOMIC_CACHE_LINE_SIZE) padded_lock
{
lockpool::lock_type lock;
// The additional padding is needed to avoid false sharing between locks
enum { padding_size = (sizeof(lockpool::lock_type) <= cache_line_size ? (cache_line_size - sizeof(lockpool::lock_type)) : (cache_line_size - sizeof(lockpool::lock_type) % cache_line_size)) };
enum { padding_size = (sizeof(lockpool::lock_type) <= BOOST_ATOMIC_CACHE_LINE_SIZE ?
(BOOST_ATOMIC_CACHE_LINE_SIZE - sizeof(lockpool::lock_type)) :
(BOOST_ATOMIC_CACHE_LINE_SIZE - sizeof(lockpool::lock_type) % BOOST_ATOMIC_CACHE_LINE_SIZE)) };
padding< padding_size > pad;
};