1
/* Copyright 2012 10gen Inc.
3
* Licensed under the Apache License, Version 2.0 (the "License");
4
* you may not use this file except in compliance with the License.
5
* You may obtain a copy of the License at
7
* http://www.apache.org/licenses/LICENSE-2.0
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
* See the License for the specific language governing permissions and
13
* limitations under the License.
17
* WARNING(schwerin): Use with extreme caution. Prefer the AtomicWord<> types from atomic_word.h.
19
* The atomic_intrinsics module provides low-level atomic operations for manipulating memory.
20
* Implementations are platform specific, so this file describes the interface and includes
21
* the appropriate os/compiler-specific headers.
23
* For supported word types, the atomic_intrinsics headers provide implementations of template
24
* classes of the following form:
26
* template <typename T> class AtomicIntrinsics {
27
* static T load(volatile const T* value);
28
* static T store(volatile T* dest, T newValue);
29
* static T compareAndSwap(volatile T* dest, T expected, T newValue);
30
* static T swap(volatile T* dest, T newValue);
31
* static T fetchAndAdd(volatile T* dest, T increment);
34
* All of the functions assume that the volatile T pointers are naturally aligned, and may not
35
* operate as expected, if they are not so aligned.
37
* The behavior of the functions is analogous to the same-named member functions of the AtomicWord
38
* template type in atomic_word.h.
44
#include "mongo/platform/atomic_intrinsics_win32.h"
45
#elif defined(__GNUC__)
46
#if defined(__i386__) || defined(__x86_64__)
47
#include "mongo/platform/atomic_intrinsics_gcc_intel.h"
49
#include "mongo/platform/atomic_intrinsics_gcc_generic.h"
52
#error "Unsupported os/compiler family"