
2009-02-20 Benjamin Kosnik <bkoz@redhat.com> * doc/doxygen/user.cfg.in: Tweaks. * doc/doxygen/doxygroups.cc: Prefer markup that can be elsewhere, be elsewhere. * include/tr1_impl/unordered_map: Just use most specialized container module. * include/tr1_impl/unordered_set: Same. * include/tr1_impl/array: Same. * include/bits/stl_list.h: Same. * include/bits/stl_map.h: Same. * include/bits/stl_queue.h: Same. * include/bits/stl_set.h: Same. * include/bits/stl_stack.h: Same. * include/bits/forward_list.h: Same. * include/bits/basic_string.h: Same. * include/bits/stl_multimap.h: Same. * include/bits/stl_vector.h: Same. * include/bits/stl_deque.h: Same. * include/bits/stl_multiset.h: Same. * include/bits/stl_bvector.h: Same. * include/backward/binders.h: Change binder module to binders. * include/std/complex: Add complex_numers module. * include/tr1_impl/complex: Same. * include/std/valarray: Add numeric_arrays module. * include/bits/gslice_array.h: Same. * include/bits/gslice.h: Same. * include/bits/mask_array.h: Same. * include/bits/slice_array.h: Same. * include/bits/indirect_array.h: Same. * include/bits/allocator.h: Add allocators module. * include/ext/throw_allocator.h * include/ext/pool_allocator.h * include/ext/bitmap_allocator.h * include/ext/new_allocator.h * include/ext/malloc_allocator.h * include/ext/array_allocator.h * include/ext/mt_allocator.h * include/ext/debug_allocator.h * include/ext/extptr_allocator.h * include/tr1_impl/functional: Move namespace markup here. * include/tr1_impl/regex: Same. * include/tr1_impl/type_traits: Add metaprogramming module. * include/std/type_traits: Same. * include/std/memory: Add memory module. * include/std/ratio: Add ratio module. * include/std/chrono: Move namespace markup here, add time module. * include/std/thread: Move namespace markup here, add concurrency module. * include/std/mutex: Use concurrency module. * include/std/condition_variable: Same. * include/bits/ios_base.h: Refine io module. * include/bits/basic_ios.h: Same. * include/std/fstream: Same. * include/std/istream: Same. * include/std/ostream: Same. * include/std/sstream: Same. * include/ext/vstring.h: Correct parameter markup. * include/bits/shared_ptr.h: Add pointer_abstractions module. * include/bits/unique_ptr.h: Same. * include/bits/algorithmfwd.h: Add mutating_algorithms, non_mutating_algorithms, sorting_algorithms. Adjust nesting. * include/bits/stl_heap.h: Add markup for new groupings. * include/bits/stl_algobase.h: Same. * include/bits/stl_algo.h: Same. * include/c_compatibility/stdatomic.h: Add atomics module. * include/c_global/cstdatomic: Same. * libsupc++/exception: Add exceptions module. * libsupc++/typeinfo: Same. * libsupc++/new: Same. * libsupc++/exception_ptr.h: Same. * include/std/system_error: Same. * include/std/stdexcept: Same. * libsupc++/cxxabi.h: Move doxygroups.cc markup here. * libsupc++/cxxabi-forced.h: Same. * testsuite/27_io/ios_base/cons/assign_neg.cc: Fix up line numbers. * testsuite/27_io/ios_base/cons/copy_neg.cc: Same. * testsuite/30_threads/condition_variable_any/cons/assign_neg.cc: Same. * testsuite/30_threads/condition_variable_any/cons/copy_neg.cc: Same. * testsuite/30_threads/mutex/cons/assign_neg.cc: Same. * testsuite/30_threads/mutex/cons/copy_neg.cc: Same. * testsuite/30_threads/timed_mutex/cons/assign_neg.cc: Same. * testsuite/30_threads/timed_mutex/cons/copy_neg.cc: Same. * testsuite/30_threads/thread/cons/assign_neg.cc: Same. * testsuite/30_threads/thread/cons/copy_neg.cc: Same. * testsuite/30_threads/recursive_mutex/cons/assign_neg.cc: Same. * testsuite/30_threads/recursive_mutex/cons/copy_neg.cc: Same. * testsuite/30_threads/condition_variable/cons/assign_neg.cc: Same. * testsuite/30_threads/condition_variable/cons/copy_neg.cc: Same. * testsuite/30_threads/recursive_timed_mutex/cons/assign_neg.cc: Same. * testsuite/30_threads/recursive_timed_mutex/cons/copy_neg.cc: Same. * testsuite/29_atomics/atomic/cons/assign_neg.cc: Same. * testsuite/29_atomics/atomic/cons/copy_neg.cc: Same. * testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Same. * testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Same. * testsuite/23_containers/vector/requirements/dr438/ constructor_1_neg.cc: Same. * testsuite/23_containers/vector/requirements/dr438/ constructor_2_neg.cc: Same. * testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Same. * testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: Same. * testsuite/23_containers/deque/requirements/dr438/ constructor_1_neg.cc: Same. * testsuite/23_containers/deque/requirements/dr438/ constructor_2_neg.cc: Same. * testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same. * testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same. * testsuite/23_containers/list/requirements/dr438/ constructor_1_neg.cc: Same. * testsuite/23_containers/list/requirements/dr438/ constructor_2_neg.cc: Same. * testsuite/20_util/duration/cons/1_neg.cc: Same. * testsuite/20_util/duration/requirements/typedefs_neg1.cc: Same. * testsuite/20_util/duration/requirements/typedefs_neg2.cc: Same. * testsuite/20_util/duration/requirements/typedefs_neg3.cc: Same. * testsuite/20_util/unique_ptr/modifiers/reset_neg.cc: Same. * testsuite/20_util/unique_ptr/assign/assign.cc: Same. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same. * testsuite/20_util/ratio/cons/cons_overflow.cc: Same. * testsuite/20_util/ratio/operations/ops_overflow.cc: Same. From-SVN: r144343
223 lines
7.4 KiB
C++
223 lines
7.4 KiB
C++
// -*- C++ -*- compatibility header.
|
|
|
|
// Copyright (C) 2008, 2009 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
|
|
// terms of the GNU General Public License as published by the
|
|
// Free Software Foundation; either version 2, or (at your option)
|
|
// any later version.
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this library; see the file COPYING. If not, write to
|
|
// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
// Boston, MA 02110-1301, USA.
|
|
|
|
// As a special exception, you may use this file as part of a free software
|
|
// library without restriction. Specifically, if other files instantiate
|
|
// templates or use macros or inline functions from this file, or you compile
|
|
// this file and link it with other files to produce an executable, this
|
|
// file does not by itself cause the resulting executable to be covered by
|
|
// the GNU General Public License. This exception does not however
|
|
// invalidate any other reasons why the executable file might be covered by
|
|
// the GNU General Public License.
|
|
|
|
/** @file stdatomic.h
|
|
* This is a Standard C++ Library header.
|
|
*/
|
|
|
|
#include <bits/c++config.h>
|
|
#include <stddef.h>
|
|
#include <stdbool.h> // XXX need to define bool w/o stdbool.h in tr1/cstdbool
|
|
|
|
#ifndef _GLIBCXX_STDATOMIC_H
|
|
#define _GLIBCXX_STDATOMIC_H 1
|
|
|
|
_GLIBCXX_BEGIN_NAMESPACE(std)
|
|
_GLIBCXX_BEGIN_EXTERN_C
|
|
|
|
/**
|
|
* @defgroup atomics Atomics
|
|
*
|
|
* Components for performing atomic operations.
|
|
* @{
|
|
*/
|
|
|
|
/// Enumeration for memory_order
|
|
typedef enum memory_order
|
|
{
|
|
memory_order_relaxed,
|
|
memory_order_consume,
|
|
memory_order_acquire,
|
|
memory_order_release,
|
|
memory_order_acq_rel,
|
|
memory_order_seq_cst
|
|
} memory_order;
|
|
|
|
// Base for atomic_flag.
|
|
typedef struct __atomic_flag_base
|
|
{
|
|
bool _M_i;
|
|
} __atomic_flag_base;
|
|
|
|
#define ATOMIC_FLAG_INIT { false }
|
|
|
|
/// 29.2 Lock-free Property
|
|
#if defined(_GLIBCXX_ATOMIC_BUILTINS_1) && defined(_GLIBCXX_ATOMIC_BUILTINS_2) \
|
|
&& defined(_GLIBCXX_ATOMIC_BUILTINS_4) && defined(_GLIBCXX_ATOMIC_BUILTINS_8)
|
|
# define _GLIBCXX_ATOMIC_PROPERTY 2
|
|
# define _GLIBCXX_ATOMIC_NAMESPACE __atomic2
|
|
#elif defined(_GLIBCXX_ATOMIC_BUILTINS_1)
|
|
# define _GLIBCXX_ATOMIC_PROPERTY 1
|
|
# define _GLIBCXX_ATOMIC_NAMESPACE __atomic1
|
|
#else
|
|
# define _GLIBCXX_ATOMIC_PROPERTY 0
|
|
# define _GLIBCXX_ATOMIC_NAMESPACE __atomic0
|
|
#endif
|
|
|
|
#define ATOMIC_INTEGRAL_LOCK_FREE _GLIBCXX_ATOMIC_PROPERTY
|
|
#define ATOMIC_ADDRESS_LOCK_FREE _GLIBCXX_ATOMIC_PROPERTY
|
|
|
|
// Switch atomic integral base types based on C or C++. In
|
|
// addition, for "C" only provide type-generic macros for atomic
|
|
// operations. (As C++ accomplishes the same thing with sets of
|
|
// overloaded functions.
|
|
#ifdef __cplusplus
|
|
inline namespace _GLIBCXX_ATOMIC_NAMESPACE { }
|
|
# include <bits/atomicfwd_cxx.h>
|
|
#else
|
|
# include <bits/atomicfwd_c.h>
|
|
#endif
|
|
|
|
// Typedefs for other atomic integral types.
|
|
typedef atomic_schar atomic_int_least8_t;
|
|
typedef atomic_uchar atomic_uint_least8_t;
|
|
typedef atomic_short atomic_int_least16_t;
|
|
typedef atomic_ushort atomic_uint_least16_t;
|
|
typedef atomic_int atomic_int_least32_t;
|
|
typedef atomic_uint atomic_uint_least32_t;
|
|
typedef atomic_llong atomic_int_least64_t;
|
|
typedef atomic_ullong atomic_uint_least64_t;
|
|
|
|
typedef atomic_schar atomic_int_fast8_t;
|
|
typedef atomic_uchar atomic_uint_fast8_t;
|
|
typedef atomic_short atomic_int_fast16_t;
|
|
typedef atomic_ushort atomic_uint_fast16_t;
|
|
typedef atomic_int atomic_int_fast32_t;
|
|
typedef atomic_uint atomic_uint_fast32_t;
|
|
typedef atomic_llong atomic_int_fast64_t;
|
|
typedef atomic_ullong atomic_uint_fast64_t;
|
|
|
|
typedef atomic_long atomic_intptr_t;
|
|
typedef atomic_ulong atomic_uintptr_t;
|
|
|
|
typedef atomic_long atomic_ssize_t;
|
|
typedef atomic_ulong atomic_size_t;
|
|
|
|
typedef atomic_llong atomic_intmax_t;
|
|
typedef atomic_ullong atomic_uintmax_t;
|
|
|
|
typedef atomic_long atomic_ptrdiff_t;
|
|
|
|
// Accessor functions for base atomic_flag type.
|
|
bool
|
|
atomic_flag_test_and_set_explicit(volatile __atomic_flag_base*, memory_order);
|
|
|
|
inline bool
|
|
atomic_flag_test_and_set(volatile __atomic_flag_base* __a)
|
|
{ return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); }
|
|
|
|
void
|
|
atomic_flag_clear_explicit(volatile __atomic_flag_base*, memory_order);
|
|
|
|
inline void
|
|
atomic_flag_clear(volatile __atomic_flag_base* __a)
|
|
{ atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
|
|
|
|
void
|
|
__atomic_flag_wait_explicit(volatile __atomic_flag_base*, memory_order);
|
|
|
|
volatile __atomic_flag_base*
|
|
__atomic_flag_for_address(const volatile void* __z) __attribute__((const));
|
|
|
|
// Implementation specific defines.
|
|
#define _ATOMIC_LOAD_(__a, __x) \
|
|
({ volatile __typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
|
|
volatile atomic_flag* __g = __atomic_flag_for_address(__p); \
|
|
__atomic_flag_wait_explicit(__g, __x); \
|
|
__typeof__ _ATOMIC_MEMBER_ __r = *__p; \
|
|
atomic_flag_clear_explicit(__g, __x); \
|
|
__r; })
|
|
|
|
#define _ATOMIC_STORE_(__a, __m, __x) \
|
|
({ volatile __typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
|
|
__typeof__(__m) __v = (__m); \
|
|
volatile atomic_flag* __g = __atomic_flag_for_address(__p); \
|
|
__atomic_flag_wait_explicit(__g, __x); \
|
|
*__p = __v; \
|
|
atomic_flag_clear_explicit(__g, __x); \
|
|
__v; })
|
|
|
|
#define _ATOMIC_MODIFY_(__a, __o, __m, __x) \
|
|
({ volatile __typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
|
|
__typeof__(__m) __v = (__m); \
|
|
volatile atomic_flag* __g = __atomic_flag_for_address(__p); \
|
|
__atomic_flag_wait_explicit(__g, __x); \
|
|
__typeof__ _ATOMIC_MEMBER_ __r = *__p; \
|
|
*__p __o __v; \
|
|
atomic_flag_clear_explicit(__g, __x); \
|
|
__r; })
|
|
|
|
#define _ATOMIC_CMPEXCHNG_(__a, __e, __m, __x) \
|
|
({ volatile __typeof__ _ATOMIC_MEMBER_* __p = &_ATOMIC_MEMBER_; \
|
|
__typeof__(__e) __q = (__e); \
|
|
__typeof__(__m) __v = (__m); \
|
|
bool __r; \
|
|
volatile atomic_flag* __g = __atomic_flag_for_address(__p); \
|
|
__atomic_flag_wait_explicit(__g, __x); \
|
|
__typeof__ _ATOMIC_MEMBER_ __t__ = *__p; \
|
|
if (__t__ == *__q) { *__p = __v; __r = true; } \
|
|
else { *__q = __t__; __r = false; } \
|
|
atomic_flag_clear_explicit(__g, __x); \
|
|
__r; })
|
|
|
|
// @} group atomics
|
|
|
|
_GLIBCXX_END_EXTERN_C
|
|
_GLIBCXX_END_NAMESPACE
|
|
|
|
// Inject into global namespace. XXX
|
|
#if defined(__cplusplus) && !defined(_GLIBCXX_STDATOMIC)
|
|
using std::memory_order;
|
|
using std::memory_order_relaxed;
|
|
using std::memory_order_consume;
|
|
using std::memory_order_acquire;
|
|
using std::memory_order_release;
|
|
using std::memory_order_acq_rel;
|
|
using std::memory_order_seq_cst;
|
|
using std::atomic_flag;
|
|
using std::atomic_bool;
|
|
using std::atomic_char;
|
|
using std::atomic_schar;
|
|
using std::atomic_uchar;
|
|
using std::atomic_short;
|
|
using std::atomic_ushort;
|
|
using std::atomic_int;
|
|
using std::atomic_uint;
|
|
using std::atomic_long;
|
|
using std::atomic_ulong;
|
|
using std::atomic_llong;
|
|
using std::atomic_ullong;
|
|
using std::atomic_wchar_t;
|
|
using std::atomic_char16_t;
|
|
using std::atomic_char32_t;
|
|
using std::atomic_address;
|
|
using std::atomic;
|
|
#endif
|
|
|
|
#endif
|