re PR libstdc++/46914 (std::atomic<int*>::exchange(...) doesn't store correct value.)

2011-02-01  Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/46914
	* include/bits/atomic_0.h (_ATOMIC_STORE_, _ATOMIC_MODIFY_,
	_ATOMIC_CMPEXCHNG_): Rename __v -> __w, and __m -> __n, to
	avoid name conflicts.

From-SVN: r169494
This commit is contained in:
Paolo Carlini 2011-02-01 18:15:39 +00:00 committed by Paolo Carlini
parent 04f089357e
commit 72660097ec
2 changed files with 21 additions and 14 deletions

View File

@ -1,3 +1,10 @@
2011-02-01 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/46914
* include/bits/atomic_0.h (_ATOMIC_STORE_, _ATOMIC_MODIFY_,
_ATOMIC_CMPEXCHNG_): Rename __v -> __w, and __m -> __n, to
avoid name conflicts.
2011-02-01 Benjamin Kosnik <bkoz@redhat.com> 2011-02-01 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/47560 PR libstdc++/47560

View File

@ -1,6 +1,6 @@
// -*- C++ -*- header. // -*- C++ -*- header.
// Copyright (C) 2008, 2009, 2010 // Copyright (C) 2008, 2009, 2010, 2011
// Free Software Foundation, Inc. // Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
@ -68,39 +68,39 @@ namespace __atomic0
atomic_flag_clear_explicit(__g, __x); \ atomic_flag_clear_explicit(__g, __x); \
__r; }) __r; })
#define _ATOMIC_STORE_(__a, __m, __x) \ #define _ATOMIC_STORE_(__a, __n, __x) \
({typedef __typeof__(_ATOMIC_MEMBER_) __i_type; \ ({typedef __typeof__(_ATOMIC_MEMBER_) __i_type; \
__i_type* __p = &_ATOMIC_MEMBER_; \ __i_type* __p = &_ATOMIC_MEMBER_; \
__typeof__(__m) __v = (__m); \ __typeof__(__n) __w = (__n); \
__atomic_flag_base* __g = __atomic_flag_for_address(__p); \ __atomic_flag_base* __g = __atomic_flag_for_address(__p); \
__atomic_flag_wait_explicit(__g, __x); \ __atomic_flag_wait_explicit(__g, __x); \
*__p = __v; \ *__p = __w; \
atomic_flag_clear_explicit(__g, __x); \ atomic_flag_clear_explicit(__g, __x); \
__v; }) __w; })
#define _ATOMIC_MODIFY_(__a, __o, __m, __x) \ #define _ATOMIC_MODIFY_(__a, __o, __n, __x) \
({typedef __typeof__(_ATOMIC_MEMBER_) __i_type; \ ({typedef __typeof__(_ATOMIC_MEMBER_) __i_type; \
__i_type* __p = &_ATOMIC_MEMBER_; \ __i_type* __p = &_ATOMIC_MEMBER_; \
__typeof__(__m) __v = (__m); \ __typeof__(__n) __w = (__n); \
__atomic_flag_base* __g = __atomic_flag_for_address(__p); \ __atomic_flag_base* __g = __atomic_flag_for_address(__p); \
__atomic_flag_wait_explicit(__g, __x); \ __atomic_flag_wait_explicit(__g, __x); \
__i_type __r = *__p; \ __i_type __r = *__p; \
*__p __o __v; \ *__p __o __w; \
atomic_flag_clear_explicit(__g, __x); \ atomic_flag_clear_explicit(__g, __x); \
__r; }) __r; })
#define _ATOMIC_CMPEXCHNG_(__a, __e, __m, __x) \ #define _ATOMIC_CMPEXCHNG_(__a, __e, __n, __x) \
({typedef __typeof__(_ATOMIC_MEMBER_) __i_type; \ ({typedef __typeof__(_ATOMIC_MEMBER_) __i_type; \
__i_type* __p = &_ATOMIC_MEMBER_; \ __i_type* __p = &_ATOMIC_MEMBER_; \
__typeof__(__e) __q = (__e); \ __typeof__(__e) __q = (__e); \
__typeof__(__m) __v = (__m); \ __typeof__(__n) __w = (__n); \
bool __r; \ bool __r; \
__atomic_flag_base* __g = __atomic_flag_for_address(__p); \ __atomic_flag_base* __g = __atomic_flag_for_address(__p); \
__atomic_flag_wait_explicit(__g, __x); \ __atomic_flag_wait_explicit(__g, __x); \
__i_type __t = *__p; \ __i_type __t = *__p; \
if (*__q == __t) \ if (*__q == __t) \
{ \ { \
*__p = (__i_type)__v; \ *__p = (__i_type)__w; \
__r = true; \ __r = true; \
} \ } \
else { *__q = __t; __r = false; } \ else { *__q = __t; __r = false; } \