atomicity.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2007 by Marc Boris Duerner
3  * Copyright (C) 2006-2007 by Aloysius Indrayanto
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * As a special exception, you may use this file as part of a free
11  * software library without restriction. Specifically, if other files
12  * instantiate templates or use macros or inline functions from this
13  * file, or you compile this file and link it with other files to
14  * produce an executable, this file does not by itself cause the
15  * resulting executable to be covered by the GNU General Public
16  * License. This exception does not however invalidate any other
17  * reasons why the executable file might be covered by the GNU Library
18  * General Public License.
19  *
20  * This library is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23  * Lesser General Public License for more details.
24  *
25  * You should have received a copy of the GNU Lesser General Public
26  * License along with this library; if not, write to the Free Software
27  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28  */
29 #ifndef CXXTOOLS_ATOMICITY_H
30 #define CXXTOOLS_ATOMICITY_H
31 
32 #include <cxxtools/config.h>
33 
34 #if defined(CXXTOOLS_ATOMICITY_SUN)
35  #include <cxxtools/atomicity.sun.h>
36 
37 #elif defined(CXXTOOLS_ATOMICITY_WINDOWS)
39 
40 #elif defined(CXXTOOLS_ATOMICITY_GCC_ARM)
42 
43 #elif defined(CXXTOOLS_ATOMICITY_GCC_MIPS)
45 
46 #elif defined(CXXTOOLS_ATOMICITY_GCC_AVR32)
48 
49 #elif defined(CXXTOOLS_ATOMICITY_GCC_SPARC32)
51 
52 #elif defined(CXXTOOLS_ATOMICITY_GCC_SPARC64)
54 
55 #elif defined(CXXTOOLS_ATOMICITY_GCC_X86_64)
57 
58 #elif defined(CXXTOOLS_ATOMICITY_GCC_X86)
60 
61 #elif defined(CXXTOOLS_ATOMICITY_GCC_PPC)
63 
64 #elif defined(CXXTOOLS_ATOMICITY_PTHREAD)
66 
67 #elif defined(_WIN32) || defined(WIN32) || defined(_WIN32_WCE)
68  #define CXXTOOLS_ATOMICITY_WINDOWS
70 
71 #elif defined(__sun)
72  #define CXXTOOLS_ATOMICITY_SUN
73  #include <cxxtools/atomicity.sun.h>
74 
75 #elif defined(__GNUC__) || defined(__xlC__) || \
76  defined(__SUNPRO_CC) || defined(__SUNPRO_C)
77 
78  #if defined (i386) || defined(__i386) || defined (__i386__) || \
79  defined(_X86_) || defined(sun386) || defined (_M_IX86)
80  #define CXXTOOLS_ATOMICITY_GCC_X86
82 
83  #elif defined(__x86_64__) || defined(__amd64__)
84  #define CXXTOOLS_ATOMICITY_GCC_X86_64
86 
87  #elif defined (ARM) || defined(__arm__) || defined(_M_ARM) || defined(_M_ARMT)
88  #define CXXTOOLS_ATOMICITY_GCC_ARM
90 
91  #elif defined (AVR) || defined(__AVR__)
92  #define CXXTOOLS_ATOMICITY_GCC_AVR32
93  #include <cxxtools/atomicity.avr32.h>
94 
95  #elif defined( _M_PPC ) || defined( PPC ) || \
96  defined( ppc ) || defined( __powerpc__ ) || \
97  defined( __ppc__ )
98  #define CXXTOOLS_ATOMICITY_GCC_PPC
100 
101  #elif defined(__mips__) || defined(MIPSEB) || defined(_MIPSEB) || \
102  defined(MIPSEL) || defined(_MIPSEL)
103  #define CXXTOOLS_ATOMICITY_GCC_MIPS
105 
106  #elif defined(__sparcv9)
107  #define CXXTOOLS_ATOMICITY_GCC_SPARC64
109 
110  #elif defined(__sparc__) || defined(sparc) || defined(__sparc) || \
111  defined(__sparcv8)
112  #define CXXTOOLS_ATOMICITY_GCC_SPARC32
114 
115  #else
117 
118  #endif
119 
120 #else
122 
123 #endif
124 
125 
126 namespace cxxtools {
127 
132 atomic_t atomicGet(volatile atomic_t& val);
133 
138 void atomicSet(volatile atomic_t& val, atomic_t n);
139 
144 atomic_t atomicIncrement(volatile atomic_t& val);
145 
150 atomic_t atomicDecrement(volatile atomic_t& val);
151 
156 atomic_t atomicExchangeAdd(volatile atomic_t& val, atomic_t add);
157 
163 atomic_t atomicCompareExchange(volatile atomic_t& val, atomic_t exch, atomic_t comp);
164 
170 void* atomicCompareExchange(void* volatile& ptr, void* exch, void* comp);
171 
176 atomic_t atomicExchange(volatile atomic_t& val, atomic_t exch);
177 
182 void* atomicExchange(void* volatile& dest, void* exch);
183 
184 }
185 
186 #endif