cstdatomic: Remove assert include.

2008-12-15  Benjamin Kosnik  <bkoz@redhat.com>

	* include/c_global/cstdatomic: Remove assert include.
	* include/debug/debug.h: Consolidate __replacement_assert...
	* include/parallel/base.h: Consolidate __replacement_assert...
	* include/bits/c++config: ...here.
	* include/bits/atomic_0.h: Use it.
	* include/bits/atomic_2.h: Same.
	* testsuite/29_atomics/atomic/cons/assign_neg.cc: Adjust line numbers.
	* testsuite/29_atomics/atomic/cons/copy_neg.cc: Same.

From-SVN: r142777
This commit is contained in:
Benjamin Kosnik 2008-12-16 01:28:46 +00:00 committed by Benjamin Kosnik
parent f2d6c7fb16
commit d4e1b0727a
9 changed files with 113 additions and 120 deletions

View File

@ -1,3 +1,14 @@
2008-12-15 Benjamin Kosnik <bkoz@redhat.com>
* include/c_global/cstdatomic: Remove assert include.
* include/debug/debug.h: Consolidate __replacement_assert...
* include/parallel/base.h: Consolidate __replacement_assert...
* include/bits/c++config: ...here.
* include/bits/atomic_0.h: Use it.
* include/bits/atomic_2.h: Same.
* testsuite/29_atomics/atomic/cons/assign_neg.cc: Adjust line numbers.
* testsuite/29_atomics/atomic/cons/copy_neg.cc: Same.
2008-12-13 Benjamin Kosnik <bkoz@redhat.com>
* src/atomic.cc: Revert last change.

View File

@ -124,17 +124,17 @@ namespace __atomic0
void
store(void* __v, memory_order __m = memory_order_seq_cst) volatile
{
// XXX
//if (__m != memory_order_acquire && __m != memory_order_acq_rel
// && __m != memory_order_consume)
__glibcxx_assert(__m == memory_order_acquire);
__glibcxx_assert(__m == memory_order_acq_rel);
__glibcxx_assert(__m == memory_order_consume);
_ATOMIC_STORE_(this, __v, __m);
}
void*
load(memory_order __m = memory_order_seq_cst) const volatile
{
// XXX
//if (__m != memory_order_release && __m != memory_order_acq_rel)
__glibcxx_assert(__m == memory_order_release);
__glibcxx_assert(__m == memory_order_acq_rel);
return _ATOMIC_LOAD_(this, __m);
}
@ -146,11 +146,10 @@ namespace __atomic0
compare_exchange_weak(void*& __v1, void* __v2, memory_order __m1,
memory_order __m2) volatile
{
bool __ret = false;
if (__m2 != memory_order_release && __m2 != memory_order_acq_rel
&& __m2 <= __m1)
__ret = _ATOMIC_CMPEXCHNG_(this, &__v1, __v2, __m1);
return __ret;
__glibcxx_assert(__m2 == memory_order_release);
__glibcxx_assert(__m2 == memory_order_acq_rel);
__glibcxx_assert(__m2 <= __m1);
return _ATOMIC_CMPEXCHNG_(this, &__v1, __v2, __m1);
}
bool
@ -165,11 +164,10 @@ namespace __atomic0
compare_exchange_strong(void*& __v1, void* __v2, memory_order __m1,
memory_order __m2) volatile
{
bool __ret = false;
if (__m2 != memory_order_release && __m2 != memory_order_acq_rel
&& __m2 <= __m1)
__ret = _ATOMIC_CMPEXCHNG_(this, &__v1, __v2, __m1);
return __ret;
__glibcxx_assert(__m2 == memory_order_release);
__glibcxx_assert(__m2 == memory_order_acq_rel);
__glibcxx_assert(__m2 <= __m1);
return _ATOMIC_CMPEXCHNG_(this, &__v1, __v2, __m1);
}
bool
@ -317,16 +315,17 @@ namespace __atomic0
store(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
{
// XXX
//if (__m != memory_order_acquire && __m != memory_order_acq_rel
// && __m != memory_order_consume)
__glibcxx_assert(__m == memory_order_acquire);
__glibcxx_assert(__m == memory_order_acq_rel);
__glibcxx_assert(__m == memory_order_consume);
_ATOMIC_STORE_(this, __i, __m);
}
__integral_type
load(memory_order __m = memory_order_seq_cst) const volatile
{
// if (__m != memory_order_release && __m != memory_order_acq_rel)
__glibcxx_assert(__m == memory_order_release);
__glibcxx_assert(__m == memory_order_acq_rel);
return _ATOMIC_LOAD_(this, __m);
}
@ -339,11 +338,10 @@ namespace __atomic0
compare_exchange_weak(__integral_type& __i1, __integral_type __i2,
memory_order __m1, memory_order __m2) volatile
{
bool __ret = false;
if (__m2 != memory_order_release && __m2 != memory_order_acq_rel
&& __m2 <= __m1)
__ret = _ATOMIC_CMPEXCHNG_(this, &__i1, __i2, __m1);
return __ret;
__glibcxx_assert(__m2 == memory_order_release);
__glibcxx_assert(__m2 == memory_order_acq_rel);
__glibcxx_assert(__m2 <= __m1);
return _ATOMIC_CMPEXCHNG_(this, &__i1, __i2, __m1);
}
bool
@ -358,11 +356,10 @@ namespace __atomic0
compare_exchange_strong(__integral_type& __i1, __integral_type __i2,
memory_order __m1, memory_order __m2) volatile
{
bool __ret = false;
if (__m2 != memory_order_release && __m2 != memory_order_acq_rel
&& __m2 <= __m1)
__ret = _ATOMIC_CMPEXCHNG_(this, &__i1, __i2, __m1);
return __ret;
__glibcxx_assert(__m2 == memory_order_release);
__glibcxx_assert(__m2 == memory_order_acq_rel);
__glibcxx_assert(__m2 <= __m1);
return _ATOMIC_CMPEXCHNG_(this, &__i1, __i2, __m1);
}
bool

View File

@ -98,9 +98,9 @@ namespace __atomic2
void
store(void* __v, memory_order __m = memory_order_seq_cst) volatile
{
assert(__m == memory_order_acquire);
assert(__m == memory_order_acq_rel);
assert(__m == memory_order_consume);
__glibcxx_assert(__m == memory_order_acquire);
__glibcxx_assert(__m == memory_order_acq_rel);
__glibcxx_assert(__m == memory_order_consume);
if (__m == memory_order_relaxed)
_M_i = __v;
@ -116,8 +116,8 @@ namespace __atomic2
void*
load(memory_order __m = memory_order_seq_cst) const volatile
{
assert(__m == memory_order_release);
assert(__m == memory_order_acq_rel);
__glibcxx_assert(__m == memory_order_release);
__glibcxx_assert(__m == memory_order_acq_rel);
__sync_synchronize();
void* __ret = _M_i;
@ -149,9 +149,9 @@ namespace __atomic2
compare_exchange_strong(void*& __v1, void* __v2, memory_order __m1,
memory_order __m2) volatile
{
assert(__m2 == memory_order_release);
assert(__m2 == memory_order_acq_rel);
assert(__m2 <= __m1);
__glibcxx_assert(__m2 == memory_order_release);
__glibcxx_assert(__m2 == memory_order_acq_rel);
__glibcxx_assert(__m2 <= __m1);
void* __v1o = __v1;
void* __v1n = __sync_val_compare_and_swap(&_M_i, __v1o, __v2);
@ -289,9 +289,9 @@ namespace __atomic2
store(__integral_type __i,
memory_order __m = memory_order_seq_cst) volatile
{
assert(__m == memory_order_acquire);
assert(__m == memory_order_acq_rel);
assert(__m == memory_order_consume);
__glibcxx_assert(__m == memory_order_acquire);
__glibcxx_assert(__m == memory_order_acq_rel);
__glibcxx_assert(__m == memory_order_consume);
if (__m == memory_order_relaxed)
_M_i = __i;
@ -307,8 +307,8 @@ namespace __atomic2
__integral_type
load(memory_order __m = memory_order_seq_cst) const volatile
{
assert(__m == memory_order_release);
assert(__m == memory_order_acq_rel);
__glibcxx_assert(__m == memory_order_release);
__glibcxx_assert(__m == memory_order_acq_rel);
__sync_synchronize();
__integral_type __ret = _M_i;
@ -341,9 +341,9 @@ namespace __atomic2
compare_exchange_strong(__integral_type& __i1, __integral_type __i2,
memory_order __m1, memory_order __m2) volatile
{
assert(__m2 == memory_order_release);
assert(__m2 == memory_order_acq_rel);
assert(__m2 <= __m1);
__glibcxx_assert(__m2 == memory_order_release);
__glibcxx_assert(__m2 == memory_order_acq_rel);
__glibcxx_assert(__m2 <= __m1);
__integral_type __i1o = __i1;
__integral_type __i1n = __sync_val_compare_and_swap(&_M_i, __i1o, __i2);

View File

@ -271,6 +271,34 @@ namespace std
# define _GLIBCXX_WEAK_DEFINITION
#endif
// Assert.
// Avoid the use of assert, because we're trying to keep the <cassert>
// include out of the mix.
#if !defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_PARALLEL)
#define __glibcxx_assert(_Condition)
#else
_GLIBCXX_BEGIN_NAMESPACE(std)
// Avoid the use of assert, because we're trying to keep the <cassert>
// include out of the mix.
inline void
__replacement_assert(const char* __file, int __line,
const char* __function, const char* __condition)
{
__builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line,
__function, __condition);
__builtin_abort();
}
_GLIBCXX_END_NAMESPACE
#define __glibcxx_assert(_Condition) \
do \
{ \
if (! (_Condition)) \
std::__replacement_assert(__FILE__, __LINE__, \
__PRETTY_FUNCTION__, #_Condition); \
} while (false)
#endif
// The remainder of the prewritten config is automatic; all the
// user hooks are listed above.

View File

@ -52,7 +52,6 @@
#include <stdatomic.h>
#include <cstddef>
#include <cassert> // XXX static_assert vs. constant-expression PR38502
_GLIBCXX_BEGIN_NAMESPACE(std)

View File

@ -86,33 +86,9 @@ namespace __gnu_debug
#else
# include <cstdio>
# include <debug/macros.h>
namespace std
{
namespace __debug
{
// Avoid the use of assert, because we're trying to keep the <cassert>
// include out of the mix.
inline void
__replacement_assert(const char* __file, int __line,
const char* __function, const char* __condition)
{
printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line,
__function, __condition);
__builtin_abort();
}
} // namespace __debug
} // namespace std
#define _GLIBCXX_DEBUG_ASSERT(_Condition) \
do \
{ \
if (! (_Condition)) \
std::__debug::__replacement_assert(__FILE__, __LINE__, \
__PRETTY_FUNCTION__, #_Condition); \
} while (false)
#define _GLIBCXX_DEBUG_ASSERT(_Condition) __glibcxx_assert(_Condition)
#ifdef _GLIBCXX_DEBUG_PEDANTIC
# define _GLIBCXX_DEBUG_PEDASSERT(_Condition) _GLIBCXX_DEBUG_ASSERT(_Condition)

View File

@ -38,7 +38,6 @@
#ifndef _GLIBCXX_PARALLEL_BASE_H
#define _GLIBCXX_PARALLEL_BASE_H 1
#include <cstdio>
#include <functional>
#include <omp.h>
#include <parallel/features.h>
@ -471,24 +470,7 @@ template<typename RandomAccessIterator, typename Comparator>
}
}
// Avoid the use of assert, because we're trying to keep the <cassert>
// include out of the mix. (Same as debug mode).
inline void
__replacement_assert(const char* __file, int __line,
const char* __function, const char* __condition)
{
std::printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line,
__function, __condition);
__builtin_abort();
}
#define _GLIBCXX_PARALLEL_ASSERT(_Condition) \
do \
{ \
if (!(_Condition)) \
__gnu_parallel::__replacement_assert(__FILE__, __LINE__, \
__PRETTY_FUNCTION__, #_Condition); \
} while (false)
#define _GLIBCXX_PARALLEL_ASSERT(_Condition) __glibcxx_assert(_Condition)
} //namespace __gnu_parallel

View File

@ -39,19 +39,19 @@ int main()
}
// { dg-error "used here" "" { target *-*-* } 510 }
// { dg-error "deleted function" "" { target *-*-* } 240 }
// { dg-error "deleted function" "" { target *-*-* } 258 }
// { dg-error "deleted function" "" { target *-*-* } 276 }
// { dg-error "deleted function" "" { target *-*-* } 294 }
// { dg-error "deleted function" "" { target *-*-* } 312 }
// { dg-error "deleted function" "" { target *-*-* } 330 }
// { dg-error "deleted function" "" { target *-*-* } 348 }
// { dg-error "deleted function" "" { target *-*-* } 366 }
// { dg-error "deleted function" "" { target *-*-* } 384 }
// { dg-error "deleted function" "" { target *-*-* } 402 }
// { dg-error "deleted function" "" { target *-*-* } 420 }
// { dg-error "deleted function" "" { target *-*-* } 438 }
// { dg-error "deleted function" "" { target *-*-* } 456 }
// { dg-error "deleted function" "" { target *-*-* } 474 }
// { dg-error "deleted function" "" { target *-*-* } 492 }
// { dg-error "deleted function" "" { target *-*-* } 239 }
// { dg-error "deleted function" "" { target *-*-* } 257 }
// { dg-error "deleted function" "" { target *-*-* } 275 }
// { dg-error "deleted function" "" { target *-*-* } 293 }
// { dg-error "deleted function" "" { target *-*-* } 311 }
// { dg-error "deleted function" "" { target *-*-* } 329 }
// { dg-error "deleted function" "" { target *-*-* } 347 }
// { dg-error "deleted function" "" { target *-*-* } 365 }
// { dg-error "deleted function" "" { target *-*-* } 383 }
// { dg-error "deleted function" "" { target *-*-* } 401 }
// { dg-error "deleted function" "" { target *-*-* } 419 }
// { dg-error "deleted function" "" { target *-*-* } 437 }
// { dg-error "deleted function" "" { target *-*-* } 455 }
// { dg-error "deleted function" "" { target *-*-* } 473 }
// { dg-error "deleted function" "" { target *-*-* } 491 }
// { dg-excess-errors "In member function" }

View File

@ -39,19 +39,19 @@ int main()
}
// { dg-error "used here" "" { target *-*-* } 549 }
// { dg-error "deleted function" "" { target *-*-* } 239 }
// { dg-error "deleted function" "" { target *-*-* } 257 }
// { dg-error "deleted function" "" { target *-*-* } 275 }
// { dg-error "deleted function" "" { target *-*-* } 293 }
// { dg-error "deleted function" "" { target *-*-* } 311 }
// { dg-error "deleted function" "" { target *-*-* } 329 }
// { dg-error "deleted function" "" { target *-*-* } 347 }
// { dg-error "deleted function" "" { target *-*-* } 365 }
// { dg-error "deleted function" "" { target *-*-* } 383 }
// { dg-error "deleted function" "" { target *-*-* } 401 }
// { dg-error "deleted function" "" { target *-*-* } 419 }
// { dg-error "deleted function" "" { target *-*-* } 437 }
// { dg-error "deleted function" "" { target *-*-* } 455 }
// { dg-error "deleted function" "" { target *-*-* } 473 }
// { dg-error "deleted function" "" { target *-*-* } 491 }
// { dg-error "deleted function" "" { target *-*-* } 238 }
// { dg-error "deleted function" "" { target *-*-* } 256 }
// { dg-error "deleted function" "" { target *-*-* } 274 }
// { dg-error "deleted function" "" { target *-*-* } 292 }
// { dg-error "deleted function" "" { target *-*-* } 310 }
// { dg-error "deleted function" "" { target *-*-* } 328 }
// { dg-error "deleted function" "" { target *-*-* } 346 }
// { dg-error "deleted function" "" { target *-*-* } 364 }
// { dg-error "deleted function" "" { target *-*-* } 382 }
// { dg-error "deleted function" "" { target *-*-* } 400 }
// { dg-error "deleted function" "" { target *-*-* } 418 }
// { dg-error "deleted function" "" { target *-*-* } 436 }
// { dg-error "deleted function" "" { target *-*-* } 454 }
// { dg-error "deleted function" "" { target *-*-* } 472 }
// { dg-error "deleted function" "" { target *-*-* } 490 }
// { dg-excess-errors "In member function" }