Go to the SVN repository for this file.
1 #ifndef CORELIB___NCBI_ATOMIC_DEFS__HPP 2 #define CORELIB___NCBI_ATOMIC_DEFS__HPP 45 #if (defined(HAVE_SCHED_YIELD) || defined(NCBI_OS_MSWIN)) \ 46 && !defined(NCBI_NO_THREADS) 47 # if defined(__cplusplus) && defined(NCBI_OS_DARWIN) 52 # elif !defined(NCBI_OS_MSWIN) 55 # if defined(NCBI_OS_MSWIN) 56 # define NCBI_SCHED_YIELD() ::SwitchToThread() 57 # define NCBI_SCHED_SPIN_INIT() int spin_counter = 0 58 # define NCBI_SCHED_SPIN_YIELD() if ( !(++spin_counter & 3) ) ::SwitchToThread() 60 # define NCBI_SCHED_YIELD() sched_yield() 61 # define NCBI_SCHED_SPIN_INIT() int spin_counter = 0 62 # define NCBI_SCHED_SPIN_YIELD() if ( !(++spin_counter & 3) ) sched_yield() 65 # define NCBI_SCHED_YIELD() 66 # define NCBI_SCHED_SPIN_INIT() 67 # define NCBI_SCHED_SPIN_YIELD() 70 #undef NCBI_COUNTER_UNSIGNED 71 #undef NCBI_COUNTER_RESERVED_VALUE 72 #undef NCBI_COUNTER_ASM_OK 73 #undef NCBI_COUNTER_USE_ASM 74 #undef NCBI_COUNTER_USE_STD_ATOMIC 75 #undef NCBI_COUNTER_ADD 76 #undef NCBI_COUNTER_NEED_MUTEX 77 #undef NCBI_SWAP_POINTERS 78 #undef NCBI_SWAP_POINTERS_CONDITIONALLY 79 #undef NCBI_SWAP_POINTERS_EXTERN 80 #undef NCBI_SLOW_ATOMIC_SWAP 82 #if defined(NCBI_COMPILER_GCC) || defined(NCBI_COMPILER_WORKSHOP) \ 83 || (defined(NCBI_COMPILER_KCC) && defined(NCBI_OS_LINUX)) \ 84 || defined(NCBI_COMPILER_ICC) || defined(NCBI_COMPILER_ANY_CLANG) 85 # define NCBI_COUNTER_ASM_OK 1 92 #if defined(NCBI_TCHECK) 93 # define NCBI_SWAP_POINTERS_EXTERN 1 96 #if defined(NCBI_HAVE_CXX11) && !defined(NCBI_COMPILER_MSVC) 111 #ifdef NCBI_NO_THREADS 113 # if SIZEOF_SIZE_T == 8 114 # define NCBI_COUNTER_64_BIT 1 116 # define NCBI_COUNTER_UNSIGNED 1 117 # define NCBI_COUNTER_ADD(p, d) ((*p) += d) 118 #elif (defined(NCBI_COMPILER_GCC) || defined(NCBI_COMPILER_ICC) || \ 119 defined(NCBI_COMPILER_ANY_CLANG)) && \ 120 (defined(__i386) || defined(__sparc) || defined(__x86_64) || \ 121 defined(__aarch64__)) && \ 122 (!defined(__GLIBCXX__) || !defined(NCBI_TCHECK)) 123 # if defined(__x86_64) || defined(__aarch64__) 124 # define NCBI_COUNTER_64_BIT 126 # ifdef NCBI_COUNTER_64_BIT 131 # define NCBI_COUNTER_UNSIGNED 1 132 # define NCBI_COUNTER_USE_ASM 1 133 # if defined(__sparc) && !defined(__sparcv9) 134 # define NCBI_COUNTER_RESERVED_VALUE 0x3FFFFFFF 136 #elif defined(NCBI_HAVE_CXX11) && !defined(NCBI_COMPILER_MSVC) 140 # if SIZEOF_SIZE_T == 8 141 # define NCBI_COUNTER_64_BIT 1 143 # define NCBI_ATOMIC_TYPE(t) std::atomic<t> 144 # define NCBI_COUNTER_UNSIGNED 1 145 # define NCBI_COUNTER_USE_STD_ATOMIC 1 146 # define NCBI_COUNTER_ADD(p, d) ((*p) += d) 147 #elif defined(NCBI_OS_SOLARIS) && defined(HAVE_ATOMIC_H) 149 # ifndef NCBI_COUNTER_ADD 151 # define NCBI_COUNTER_UNSIGNED 1 152 # define NCBI_COUNTER_ADD(p, d) atomic_add_32_nv(p, d) 155 # ifndef _SYS_ATOMIC_H 160 void*atomic_swap_ptr(
volatile void*,
void*);
162 # define NCBI_SWAP_POINTERS(loc, nv) atomic_swap_ptr(loc, nv) 163 #elif defined(NCBI_COMPILER_WORKSHOP) 169 # define NCBI_COUNTER_UNSIGNED 1 173 void* NCBICORE_asm_casx(
void* new_value,
void**
location,
void* old_value);
174 # define NCBI_SWAP_POINTERS_CONDITIONALLY(loc, ov, nv) \ 175 (NCBICORE_asm_casx(nv, loc, ov) == ov) 176 # define NCBI_SWAP_POINTERS_EXTERN 1 177 # elif defined(__sparc) 179 # define NCBI_COUNTER_RESERVED_VALUE 0x3FFFFFFF 180 # define NCBI_COUNTER_UNSIGNED 1 183 # define NCBI_SWAP_POINTERS(loc, nv) \ 184 ((void*))(NCBICORE_asm_swap((TNCBIAtomicValue)(nv), \ 185 (TNCBIAtomicValue*)(loc))) 186 # define NCBI_SWAP_POINTERS_EXTERN 1 187 # elif defined(__x86_64) 189 # define NCBI_COUNTER_UNSIGNED 1 192 void* NCBICORE_asm_xchgq(
void* new_value,
void**
location);
193 # define NCBI_COUNTER_ADD(p, d) (NCBICORE_asm_lock_xaddl_64(p, d) + d) 194 # define NCBI_COUNTER_USE_EXTERN_ASM 1 195 # define NCBI_SWAP_POINTERS(loc, nv) NCBICORE_asm_xchgq(nv, loc) 196 # define NCBI_SWAP_POINTERS_EXTERN 1 197 # elif defined(__i386) 199 # define NCBI_COUNTER_UNSIGNED 1 202 void* NCBICORE_asm_xchg(
void* new_value,
void**
location);
203 # define NCBI_COUNTER_ADD(p, d) (NCBICORE_asm_lock_xaddl(p, d) + d) 204 # define NCBI_COUNTER_USE_EXTERN_ASM 1 205 # define NCBI_SWAP_POINTERS(loc, nv) NCBICORE_asm_xchg(nv, loc) 206 # define NCBI_SWAP_POINTERS_EXTERN 1 208 # undef NCBI_COUNTER_ASM_OK 213 #elif defined(_CXXCONFIG) 214 # include <ext/atomicity.h> 216 # define NCBI_COUNTER_ADD(p, d) (__gnu_cxx::__exchange_and_add(p, d) + d) 217 #elif defined(NCBI_COMPILER_COMPAQ) 218 # include <machine/builtins.h> 220 # define NCBI_COUNTER_ADD(p, d) (__ATOMIC_ADD_LONG(p, d) + d) 221 # define NCBI_SWAP_POINTERS(loc, nv) \ 222 ((void*)(__ATOMIC_EXCH_QUAD((loc), (long)(nv)))) 225 #if defined(NCBI_NO_THREADS) 227 #elif defined(NCBI_OS_IRIX) 229 # ifndef NCBI_COUNTER_ADD 231 # define NCBI_COUNTER_UNSIGNED 1 232 # define NCBI_COUNTER_ADD(p, d) add_then_test32(p, d) 234 # define NCBI_SWAP_POINTERS(loc, nv) \ 235 ((void*) (test_and_set((unsigned long*)(loc), (unsigned long)(nv)))) 236 #elif defined(NCBI_OS_AIX) 237 # include <sys/atomic_op.h> 238 # ifndef NCBI_COUNTER_ADD 240 # define NCBI_COUNTER_ADD(p, d) (fetch_and_add(p, d) + d) 242 # define NCBI_SWAP_POINTERS_CONDITIONALLY(loc, ov, nv) \ 243 (compare_and_swap((atomic_p)(loc), (int*)(&(ov)), (int)(nv)) != FALSE) 244 #elif defined(NCBI_OS_DARWIN) && 0 245 # include <CarbonCore/DriverSynchronization.h> 246 # if !defined(NCBI_COUNTER_ADD) && !defined(NCBI_COUNTER_USE_ASM) 248 # define NCBI_COUNTER_ADD(p, d) (AddAtomic(d, p) + d) 250 # if SIZEOF_VOIDP == 4 251 # define NCBI_SWAP_POINTERS_CONDITIONALLY(loc, ov, nv) \ 252 CompareAndSwap((UInt32)(ov), (UInt32)(nv), (UInt32*)(loc)) 254 #elif defined(NCBI_OS_MSWIN) 256 # if !defined(NCBI_COUNTER_ADD) && !defined(NCBI_COUNTER_USE_ASM) 257 # if NCBI_PLATFORM_BITS >= 64 258 # define NCBI_COUNTER_64_BIT 260 # ifdef NCBI_COUNTER_64_BIT 262 # define NCBI_COUNTER_ADD(p, d) (InterlockedExchangeAdd64(p, d) + d) 265 # define NCBI_COUNTER_ADD(p, d) (InterlockedExchangeAdd(p, d) + d) 268 # define NCBI_SWAP_POINTERS(loc, nv) (InterlockedExchangePointer(loc, nv)) 269 #elif !defined(NCBI_COUNTER_ADD) && !defined(NCBI_COUNTER_USE_ASM) 271 # define NCBI_COUNTER_UNSIGNED 1 272 # if defined (NCBI_COUNTER_ASM_OK) && (defined(__i386) || defined(__sparc) || defined(__x86_64)) 273 # define NCBI_COUNTER_USE_ASM 1 275 # define NCBI_COUNTER_NEED_MUTEX 1 279 #if !defined(NCBI_SWAP_POINTERS) \ 280 && !defined(NCBI_SWAP_POINTERS_CONDITIONALLY) \ 281 && !defined(NCBI_NO_THREADS) \ 282 && (!defined(NCBI_COUNTER_ASM_OK) \ 283 || (!defined(__i386) && !defined(__powerpc__) \ 284 && !defined(__powerpc64__) && !defined(__ppc__) \ 285 && !defined(__ppc64__) && !defined(__sparc) \ 286 && !defined(__x86_64) && !defined(__aarch64__))) 287 # define NCBI_SWAP_POINTERS_EXTERN 1 288 # define NCBI_SLOW_ATOMIC_SWAP 1 291 #ifndef NCBI_ATOMIC_TYPE 292 # define NCBI_ATOMIC_TYPE(t) tstatic const char location[]
size_t TNCBIAtomicValue
Define platform specific atomic-operations macros/values.
Defines some MS Windows specifics for our "C" code.
Front end for a platform-specific configuration summary.
Int4 delta(size_t dimension_, const Int4 *score_)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4