Home | History | Annotate | Download | only in bits
      1 // -*- C++ -*- header.
      2 
      3 // Copyright (C) 2008, 2009
      4 // Free Software Foundation, Inc.
      5 //
      6 // This file is part of the GNU ISO C++ Library.  This library is free
      7 // software; you can redistribute it and/or modify it under the
      8 // terms of the GNU General Public License as published by the
      9 // Free Software Foundation; either version 3, or (at your option)
     10 // any later version.
     11 
     12 // This library is distributed in the hope that it will be useful,
     13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 // GNU General Public License for more details.
     16 
     17 // Under Section 7 of GPL version 3, you are granted additional
     18 // permissions described in the GCC Runtime Library Exception, version
     19 // 3.1, as published by the Free Software Foundation.
     20 
     21 // You should have received a copy of the GNU General Public License and
     22 // a copy of the GCC Runtime Library Exception along with this program;
     23 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
     24 // <http://www.gnu.org/licenses/>.
     25 
     26 /** @file bits/atomicfwd_c.h
     27  *  This is an internal header file, included by other library headers.
     28  *  You should not attempt to use it directly.
     29  */
     30 
     31 // "C" only bits.
     32 
     33 #define _ATOMIC_MEMBER_ ((__a)->_M_i)
     34 
     35   // POD base classes for atomic intgral types.
     36   struct __atomic_bool_base
     37   {
     38     bool _M_i;
     39   };
     40 
     41   struct __atomic_char_base
     42   {
     43     char _M_i;
     44   };
     45 
     46   struct __atomic_schar_base
     47   {
     48     signed char _M_i;
     49   };
     50 
     51   struct __atomic_uchar_base
     52   {
     53     unsigned char _M_i;
     54   };
     55 
     56   struct __atomic_short_base
     57   {
     58     short _M_i;
     59   };
     60 
     61   struct __atomic_ushort_base
     62   {
     63     unsigned short _M_i;
     64   };
     65 
     66   struct __atomic_int_base
     67   {
     68     int _M_i;
     69   };
     70 
     71   struct __atomic_uint_base
     72   {
     73     unsigned int _M_i;
     74   };
     75 
     76   struct __atomic_long_base
     77   {
     78     long _M_i;
     79   };
     80 
     81   struct __atomic_ulong_base
     82   {
     83     unsigned long _M_i;
     84   };
     85 
     86   struct __atomic_llong_base
     87   {
     88     long long _M_i;
     89   };
     90 
     91   struct __atomic_ullong_base
     92   {
     93     unsigned long long	_M_i;
     94   };
     95 
     96   struct __atomic_wchar_t_base
     97   {
     98     wchar_t _M_i;
     99   };
    100 
    101   typedef struct __atomic_flag_base 		atomic_flag;
    102   typedef struct __atomic_address_base 		atomic_address;
    103   typedef struct __atomic_bool_base		atomic_bool;
    104   typedef struct __atomic_char_base 		atomic_char;
    105   typedef struct __atomic_schar_base 		atomic_schar;
    106   typedef struct __atomic_uchar_base 		atomic_uchar;
    107   typedef struct __atomic_short_base 		atomic_short;
    108   typedef struct __atomic_ushort_base 		atomic_ushort;
    109   typedef struct __atomic_int_base 		atomic_int;
    110   typedef struct __atomic_uint_base 		atomic_uint;
    111   typedef struct __atomic_long_base 		atomic_long;
    112   typedef struct __atomic_ulong_base 		atomic_ulong;
    113   typedef struct __atomic_llong_base 		atomic_llong;
    114   typedef struct __atomic_ullong_base 		atomic_ullong;
    115   typedef struct __atomic_wchar_t_base 		atomic_wchar_t;
    116   typedef struct __atomic_short_base 		atomic_char16_t;
    117   typedef struct __atomic_int_base 		atomic_char32_t;
    118 
    119 #define atomic_is_lock_free(__a)					\
    120   false
    121 
    122 #define atomic_load_explicit(__a, __x)					\
    123   _ATOMIC_LOAD_(__a, __x)
    124 
    125 #define atomic_load(__a)						\
    126   atomic_load_explicit(__a, memory_order_seq_cst)
    127 
    128 #define atomic_store_explicit(__a, __m, __x)				\
    129   _ATOMIC_STORE_(__a, __m, __x)
    130 
    131 #define atomic_store(__a, __m)						\
    132   atomic_store_explicit(__a, __m, memory_order_seq_cst)
    133 
    134 #define atomic_exchange_explicit(__a, __m, __x)				\
    135   _ATOMIC_MODIFY_(__a, =, __m, __x)
    136 
    137 #define atomic_exchange(__a, __m)					\
    138   atomic_exchange_explicit(__a, __m, memory_order_seq_cst)
    139 
    140 #define atomic_compare_exchange_explicit(__a, __e, __m, __x, __y)	\
    141   _ATOMIC_CMPEXCHNG_(__a, __e, __m, __x)
    142 
    143 #define atomic_compare_exchange(__a, __e, __m)				\
    144   _ATOMIC_CMPEXCHNG_(__a, __e, __m, memory_order_seq_cst)
    145 
    146 #define atomic_fetch_add_explicit(__a, __m, __x)			\
    147   _ATOMIC_MODIFY_(__a, +=, __m, __x)
    148 
    149 #define atomic_fetch_add(__a, __m)					\
    150   atomic_fetch_add_explicit(__a, __m, memory_order_seq_cst)
    151 
    152 #define atomic_fetch_sub_explicit(__a, __m, __x)			\
    153   _ATOMIC_MODIFY_(__a, -=, __m, __x)
    154 
    155 #define atomic_fetch_sub(__a, __m)					\
    156   atomic_fetch_sub_explicit(__a, __m, memory_order_seq_cst)
    157 
    158 #define atomic_fetch_and_explicit(__a, __m, __x)			\
    159   _ATOMIC_MODIFY_(__a, &=, __m, __x)
    160 
    161 #define atomic_fetch_and(__a, __m)					\
    162   atomic_fetch_and_explicit(__a, __m, memory_order_seq_cst)
    163 
    164 #define atomic_fetch_or_explicit(__a, __m, __x) 			\
    165   _ATOMIC_MODIFY_(__a, |=, __m, __x)
    166 
    167 #define atomic_fetch_or(__a, __m)					\
    168   atomic_fetch_or_explicit(__a, __m, memory_order_seq_cst)
    169 
    170 #define atomic_fetch_xor_explicit(__a, __m, __x)			\
    171   _ATOMIC_MODIFY_(__a, ^=, __m, __x)
    172 
    173 #define atomic_fetch_xor(__a, __m)					\
    174   atomic_fetch_xor_explicit(__a, __m, memory_order_seq_cst)
    175