re PR libstdc++/51798 (libstdc++ atomicity performance regression due to __sync_fetch_and_add)

PR libstdc++/51798
	* config/cpu/generic/atomicity_builtins/atomicity.h
	(__exchange_and_add, __atomic_add): Use __atomic_fetch_add
	with __ATOMIC_ACQ_REL semantics instead of __sync_fetch_and_add.
	* include/ext/atomicity.h (__exchange_and_add, __atomic_add):
	Likewise.

From-SVN: r183644
This commit is contained in:
Jakub Jelinek 2012-01-27 21:26:03 +01:00 committed by Jakub Jelinek
parent 8c6cb782a3
commit 7dcbaaa984
3 changed files with 15 additions and 6 deletions

View File

@ -1,3 +1,12 @@
2012-01-27 Jakub Jelinek <jakub@redhat.com>
PR libstdc++/51798
* config/cpu/generic/atomicity_builtins/atomicity.h
(__exchange_and_add, __atomic_add): Use __atomic_fetch_add
with __ATOMIC_ACQ_REL semantics instead of __sync_fetch_and_add.
* include/ext/atomicity.h (__exchange_and_add, __atomic_add):
Likewise.
2011-01-27 Rafael Avila de Espindola <rafael.espindola@gmail.com>
* libsupc++/typeinfo: Correctly match #pragma GCC visibility

View File

@ -1,7 +1,7 @@
// Low-level functions for atomic operations: version for CPUs providing
// atomic builtins -*- C++ -*-
// Copyright (C) 2006, 2009, 2010 Free Software Foundation, Inc.
// Copyright (C) 2006, 2009, 2010, 2012 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@ -33,12 +33,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Atomic_word
__attribute__ ((__unused__))
__exchange_and_add(volatile _Atomic_word* __mem, int __val) throw ()
{ return __sync_fetch_and_add(__mem, __val); }
{ return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
void
__attribute__ ((__unused__))
__atomic_add(volatile _Atomic_word* __mem, int __val) throw ()
{ __sync_fetch_and_add(__mem, __val); }
{ __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace

View File

@ -1,6 +1,6 @@
// Support for atomic operations -*- C++ -*-
// Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011
// Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011, 2012
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@ -45,11 +45,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#ifdef _GLIBCXX_ATOMIC_BUILTINS
static inline _Atomic_word
__exchange_and_add(volatile _Atomic_word* __mem, int __val)
{ return __sync_fetch_and_add(__mem, __val); }
{ return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
static inline void
__atomic_add(volatile _Atomic_word* __mem, int __val)
{ __sync_fetch_and_add(__mem, __val); }
{ __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
#else
_Atomic_word
__attribute__ ((__unused__))