summaryrefslogtreecommitdiff
path: root/src/mongo/platform
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2015-01-03 10:55:42 -0500
committerAndrew Morrow <acm@mongodb.com>2015-02-13 13:01:12 -0500
commit05d73815c390e344842ac8870acfea53498279ea (patch)
treef47dd823f6b7982df32480eb14c5834277fd72ce /src/mongo/platform
parentc1b5595b5fdf93e0599bbdd4154f35bfa10fadd1 (diff)
downloadmongo-05d73815c390e344842ac8870acfea53498279ea.tar.gz
SERVER-16559 Require C++11 and remove conditional compilation
Diffstat (limited to 'src/mongo/platform')
-rw-r--r--src/mongo/platform/atomic_intrinsics.h69
-rw-r--r--src/mongo/platform/atomic_intrinsics_gcc_atomic.h80
-rw-r--r--src/mongo/platform/atomic_intrinsics_gcc_intel.h178
-rw-r--r--src/mongo/platform/atomic_intrinsics_gcc_sync.h110
-rw-r--r--src/mongo/platform/atomic_word.h146
-rw-r--r--src/mongo/platform/atomic_word_cxx11.h193
-rw-r--r--src/mongo/platform/atomic_word_intrinsics.h164
-rw-r--r--src/mongo/platform/hash_namespace.h42
-rw-r--r--src/mongo/platform/unordered_map.h38
-rw-r--r--src/mongo/platform/unordered_set.h38
10 files changed, 140 insertions, 918 deletions
diff --git a/src/mongo/platform/atomic_intrinsics.h b/src/mongo/platform/atomic_intrinsics.h
deleted file mode 100644
index ffadd9af6f5..00000000000
--- a/src/mongo/platform/atomic_intrinsics.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Copyright 2012 10gen Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the GNU Affero General Public License in all respects
- * for all of the code used other than as permitted herein. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you do not
- * wish to do so, delete this exception statement from your version. If you
- * delete this exception statement from all source files in the program,
- * then also delete it in the license file.
- */
-
-/**
- * NOTE: Not for direct use by any code other than AtomicWord.
- *
- * The atomic_intrinsics module provides low-level atomic operations for manipulating memory.
- * Implementations are platform specific, so this file describes the interface and includes
- * the appropriate os/compiler-specific headers.
- *
- * For supported word types, the atomic_intrinsics headers provide implementations of template
- * classes of the following form:
- *
- * template <typename T> class AtomicIntrinsics {
- * static T load(volatile const T* value);
- * static T store(volatile T* dest, T newValue);
- * static T compareAndSwap(volatile T* dest, T expected, T newValue);
- * static T swap(volatile T* dest, T newValue);
- * static T fetchAndAdd(volatile T* dest, T increment);
- * };
- *
- * All of the functions assume that the volatile T pointers are naturally aligned, and may not
- * operate as expected, if they are not so aligned.
- *
- * The behavior of the functions is analogous to the same-named member functions of the AtomicWord
- * template type in atomic_word.h.
- */
-
-#pragma once
-
-#if defined(MONGO_HAVE_CXX11_ATOMICS)
-#error "Use of atomic_intrinsics.h is not supported when C++11 <atomic> is available"
-#endif
-
-#if defined(_WIN32)
-#error "Windows builds must use a compiler supporting std::atomic"
-#elif defined(MONGO_HAVE_GCC_ATOMIC_BUILTINS)
-#include "mongo/platform/atomic_intrinsics_gcc_atomic.h"
-#elif defined(MONGO_HAVE_GCC_SYNC_BUILTINS)
-#include "mongo/platform/atomic_intrinsics_gcc_sync.h"
-#elif defined(__i386__) || defined(__x86_64__)
-#include "mongo/platform/atomic_intrinsics_gcc_intel.h"
-#else
-#error "Unsupported os/compiler family"
-#endif
diff --git a/src/mongo/platform/atomic_intrinsics_gcc_atomic.h b/src/mongo/platform/atomic_intrinsics_gcc_atomic.h
deleted file mode 100644
index 5e2e7d24a14..00000000000
--- a/src/mongo/platform/atomic_intrinsics_gcc_atomic.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* Copyright 2012 10gen Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the GNU Affero General Public License in all respects
- * for all of the code used other than as permitted herein. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you do not
- * wish to do so, delete this exception statement from your version. If you
- * delete this exception statement from all source files in the program,
- * then also delete it in the license file.
- */
-
-/**
- * Implementation of the AtomicIntrinsics<T>::* operations for systems on any
- * architecture using a new enough GCC-compatible compiler toolchain.
- */
-
-#pragma once
-
-namespace mongo {
-
- /**
- * Instantiation of AtomicIntrinsics<> for all word types T.
- */
- template <typename T, typename IsTLarge=void>
- class AtomicIntrinsics {
- public:
-
- static T compareAndSwap(volatile T* dest, T expected, T newValue) {
- __atomic_compare_exchange(dest, &expected, &newValue, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
- return expected;
- }
-
- static T swap(volatile T* dest, T newValue) {
- T result;
- __atomic_exchange(dest, &newValue, &result, __ATOMIC_SEQ_CST);
- return result;
- }
-
- static T load(volatile const T* value) {
- T result;
- __atomic_load(value, &result, __ATOMIC_SEQ_CST);
- return result;
- }
-
- static T loadRelaxed(volatile const T* value) {
- T result;
- __atomic_load(value, &result, __ATOMIC_RELAXED);
- return result;
- }
-
- static void store(volatile T* dest, T newValue) {
- __atomic_store(dest, &newValue, __ATOMIC_SEQ_CST);
- }
-
- static T fetchAndAdd(volatile T* dest, T increment) {
- return __atomic_fetch_add(dest, increment, __ATOMIC_SEQ_CST);
- }
-
- private:
- AtomicIntrinsics();
- ~AtomicIntrinsics();
- };
-
-} // namespace mongo
diff --git a/src/mongo/platform/atomic_intrinsics_gcc_intel.h b/src/mongo/platform/atomic_intrinsics_gcc_intel.h
deleted file mode 100644
index 489c0c4b5bd..00000000000
--- a/src/mongo/platform/atomic_intrinsics_gcc_intel.h
+++ /dev/null
@@ -1,178 +0,0 @@
-/* Copyright 2012 10gen Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program 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 Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * As a special exception, the copyright holders give permission to link the
- * code of portions of this program with the OpenSSL library under certain
- * conditions as described in each individual source file and distribute
- * linked combinations including the program with the OpenSSL library. You
- * must comply with the GNU Affero General Public License in all respects
- * for all of the code used other than as permitted herein. If you modify
- * file(s) with this exception, you may extend this exception to your
- * version of the file(s), but you are not obligated to do so. If you do not
- * wish to do so, delete this exception statement from your version. If you
- * delete this exception statement from all source files in the program,
- * then also delete it in the license file.
- */
-
-/**
- * Implementation of the AtomicIntrinsics<T>::* operations for IA-32 and AMD64 systems using a
- * GCC-compatible compiler toolchain.
- */
-
-#pragma once
-
-#include <boost/utility.hpp>
-
-namespace mongo {
-
- /**
- * Instantiation of AtomicIntrinsics<> for all word types T where sizeof<T> <= sizeof(void *).
- *
- * On 32-bit systems, this handles 8-, 16- and 32-bit word types. On 64-bit systems,
- * it handles 8-, 16, 32- and 64-bit types.
- */
- template <typename T, typename IsTLarge=void>
- class AtomicIntrinsics {
- public:
-
- static T compareAndSwap(volatile T* dest, T expected, T newValue) {
-
- T result;
- asm volatile ("lock cmpxchg %[src], %[dest]"
- : [dest] "+m" (*dest),
- "=a" (result)
- : [src] "r" (newValue),
- "a" (expected)
- : "memory", "cc");
- return result;
- }
-
- static T swap(volatile T* dest, T newValue) {
-
- T result = newValue;
- // No need for "lock" prefix on "xchg".
- asm volatile ("xchg %[r], %[dest]"
- : [dest] "+m" (*dest),
- [r] "+r" (result)
- :
- : "memory");
- return result;
- }
-
- static T load(volatile const T* value) {
- asm volatile ("mfence" ::: "memory");
- T result = *value;
- asm volatile ("mfence" ::: "memory");
- return result;
- }
-
- static T loadRelaxed(volatile const T* value) {
- return *value;
- }
-
- static void store(volatile T* dest, T newValue) {
- asm volatile ("mfence" ::: "memory");
- *dest = newValue;
- asm volatile ("mfence" ::: "memory");
- }
-
- static T fetchAndAdd(volatile T* dest, T increment) {
-
- T result = increment;
- asm volatile ("lock xadd %[src], %[dest]"
- : [dest] "+m" (*dest),
- [src] "+r" (result)
- :
- : "memory", "cc");
- return result;
- }
-
- private:
- AtomicIntrinsics();
- ~AtomicIntrinsics();
- };
-
- /**
- * Instantiation of AtomicIntrinsics<T> where sizeof<T> exceeds sizeof(void*).
- *
- * On 32-bit systems, this handles the 64-bit word type. Not used on 64-bit systems.
- *
- * Note that the implementations of swap, store and fetchAndAdd spin until they succeed. This
- * implementation is thread-safe, but may have poor performance in high-contention environments.
- * However, no superior solution exists for IA-32 (32-bit x86) systems.
- */
- template <typename T>
- class AtomicIntrinsics<T, typename boost::disable_if_c<sizeof(T) <= sizeof(void*)>::type> {
- public:
- static T compareAndSwap(volatile T* dest, T expected, T newValue) {
- T result = expected;
- asm volatile ("push %%eax\n"
- "push %%ebx\n"
- "push %%ecx\n"
- "push %%edx\n"
- "mov (%%edx), %%ebx\n"
- "mov 4(%%edx), %%ecx\n"
- "mov (%%edi), %%eax\n"
- "mov 4(%%edi), %%edx\n"
- "lock cmpxchg8b (%%esi)\n"
- "mov %%eax, (%%edi)\n"
- "mov %%edx, 4(%%edi)\n"
- "pop %%edx\n"
- "pop %%ecx\n"
- "pop %%ebx\n"
- "pop %%eax\n"
- :
- : "S" (dest),
- "D" (&result),
- "d" (&newValue)
- : "memory", "cc");
- return result;
- }
-
- static T swap(volatile T* dest, T newValue) {
-
- T expected;
- T actual;
- do {
- expected = *dest;
- actual = compareAndSwap(dest, expected, newValue);
- } while (actual != expected);
- return actual;
- }
-
- static T load(volatile const T* value) {
- return compareAndSwap(const_cast<volatile T*>(value), T(0), T(0));
- }
-
- static void store(volatile T* dest, T newValue) {
- swap(dest, newValue);
- }
-
- static T fetchAndAdd(volatile T* dest, T increment) {
-
- T expected;
- T actual;
- do {
- expected = load(dest);
- actual = compareAndSwap(dest, expected, expected + increment);
- } while (actual != expected);
- return actual;
- }
-
- private:
- AtomicIntrinsics();
- ~AtomicIntrinsics();
- };
-
-} // namespace mongo
diff --git a/src/mongo/platform/atomic_intrinsics_gcc_sync.h b/src/mongo/platform/atomic_intrinsics_gcc_sync.h
deleted file mode 100644
index 2ff7b33f4be..00000000000
--- a/src/mongo/platform/atomic_intrinsics_gcc_sync.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* Copyright 2014 10gen Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Implementation of the AtomicIntrinsics<T>::* operations for systems on any
- * architecture using a GCC 4.1+ compatible compiler toolchain.
- */
-
-#pragma once
-
-#include <boost/utility.hpp>
-
-namespace mongo {
-
- /**
- * Instantiation of AtomicIntrinsics<> for all word types T.
- */
- template <typename T, typename IsTLarge=void>
- class AtomicIntrinsics {
- public:
-
- static T compareAndSwap(volatile T* dest, T expected, T newValue) {
- return __sync_val_compare_and_swap(dest, expected, newValue);
- }
-
- static T swap(volatile T* dest, T newValue) {
- T currentValue = *dest;
- while (true) {
- const T result = compareAndSwap(dest, currentValue, newValue);
- if (result == currentValue)
- return result;
- currentValue = result;
- }
- }
-
- static T load(volatile const T* value) {
- __sync_synchronize();
- T result = *value;
- __sync_synchronize();
- return result;
- }
-
- static T loadRelaxed(volatile const T* value) {
- asm volatile("" ::: "memory");
- return *value;
- }
-
- static void store(volatile T* dest, T newValue) {
- __sync_synchronize();
- *dest = newValue;
- __sync_synchronize();
- }
-
- static T fetchAndAdd(volatile T* dest, T increment) {
- return __sync_fetch_and_add(dest, increment);
- }
-
- private:
- AtomicIntrinsics();
- ~AtomicIntrinsics();
- };
-
- template <typename T>
- class AtomicIntrinsics<T, typename boost::disable_if_c<sizeof(T) <= sizeof(void*)>::type> {
- public:
-
- static T compareAndSwap(volatile T* dest, T expected, T newValue) {
- return __sync_val_compare_and_swap(dest, expected, newValue);
- }
-
- static T swap(volatile T* dest, T newValue) {
- T currentValue = *dest;
- while (true) {
- const T result = compareAndSwap(dest, currentValue, newValue);
- if (result == currentValue)
- return result;
- currentValue = result;
- }
- }
-
- static T load(volatile const T* value) {
- return compareAndSwap(const_cast<volatile T*>(value), T(0), T(0));
- }
-
- static void store(volatile T* dest, T newValue) {
- swap(dest, newValue);
- }
-
- static T fetchAndAdd(volatile T* dest, T increment) {
- return __sync_fetch_and_add(dest, increment);
- }
-
- private:
- AtomicIntrinsics();
- ~AtomicIntrinsics();
- };
-
-} // namespace mongo
diff --git a/src/mongo/platform/atomic_word.h b/src/mongo/platform/atomic_word.h
index 7601d9bed06..ac39a24c0ed 100644
--- a/src/mongo/platform/atomic_word.h
+++ b/src/mongo/platform/atomic_word.h
@@ -1,4 +1,4 @@
-/* Copyright 2012 10gen Inc.
+/* Copyright 2014 10gen Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
@@ -27,8 +27,142 @@
#pragma once
-#if defined(MONGO_HAVE_CXX11_ATOMICS)
-#include "mongo/platform/atomic_word_cxx11.h"
-#else
-#include "mongo/platform/atomic_word_intrinsics.h"
-#endif
+#include <atomic>
+#include <type_traits>
+
+#include <boost/static_assert.hpp>
+
+namespace mongo {
+
+ /**
+ * Implementation of the AtomicWord interface in terms of the C++11 Atomics.
+ */
+ template <typename _WordType>
+ class AtomicWord {
+
+ public:
+ /**
+ * Underlying value type.
+ */
+ typedef _WordType WordType;
+
+ /**
+ * Construct a new word with the given initial value.
+ */
+ explicit AtomicWord(WordType value=WordType(0)) : _value(value) {}
+
+ /**
+ * Gets the current value of this AtomicWord.
+ *
+ * Has acquire and release semantics.
+ */
+ WordType load() const {
+ return _value.load();
+ }
+
+ /**
+ * Gets the current value of this AtomicWord.
+ *
+ * Has relaxed semantics.
+ */
+ WordType loadRelaxed() const {
+ return _value.load(std::memory_order_relaxed);
+ }
+
+ /**
+ * Sets the value of this AtomicWord to "newValue".
+ *
+ * Has acquire and release semantics.
+ */
+ void store(WordType newValue) {
+ return _value.store(newValue);
+ }
+
+ /**
+ * Atomically swaps the current value of this with "newValue".
+ *
+ * Returns the old value.
+ *
+ * Has acquire and release semantics.
+ */
+ WordType swap(WordType newValue) {
+ return _value.exchange(newValue);
+ }
+
+ /**
+ * Atomic compare and swap.
+ *
+ * If this value equals "expected", sets this to "newValue".
+ * Always returns the original of this.
+ *
+ * Has acquire and release semantics.
+ */
+ WordType compareAndSwap(WordType expected, WordType newValue) {
+ // NOTE: Subtle: compare_exchange mutates its first argument.
+ _value.compare_exchange_strong(expected, newValue);
+ return expected;
+ }
+
+ /**
+ * Get the current value of this, add "increment" and store it, atomically.
+ *
+ * Returns the value of this before incrementing.
+ *
+ * Has acquire and release semantics.
+ */
+ WordType fetchAndAdd(WordType increment) {
+ return _value.fetch_add(increment);
+ }
+
+ /**
+ * Get the current value of this, subtract "decrement" and store it, atomically.
+ *
+ * Returns the value of this before decrementing.
+ *
+ * Has acquire and release semantics.
+ */
+ WordType fetchAndSubtract(WordType decrement) {
+ return _value.fetch_sub(decrement);
+ }
+
+ /**
+ * Get the current value of this, add "increment" and store it, atomically.
+ *
+ * Returns the value of this after incrementing.
+ *
+ * Has acquire and release semantics.
+ */
+ WordType addAndFetch(WordType increment) {
+ return fetchAndAdd(increment) + increment;
+ }
+
+ /**
+ * Get the current value of this, subtract "decrement" and store it, atomically.
+ *
+ * Returns the value of this after decrementing.
+ *
+ * Has acquire and release semantics.
+ */
+ WordType subtractAndFetch(WordType decrement) {
+ return fetchAndSubtract(decrement) - decrement;
+ }
+
+ private:
+ std::atomic<WordType> _value;
+ };
+
+#define _ATOMIC_WORD_DECLARE(NAME, WTYPE) \
+ typedef class AtomicWord<WTYPE> NAME; \
+ namespace { \
+ BOOST_STATIC_ASSERT(sizeof(NAME) == sizeof(WTYPE)); \
+ BOOST_STATIC_ASSERT(std::is_standard_layout<WTYPE>::value); \
+ } // namespace
+
+ _ATOMIC_WORD_DECLARE(AtomicUInt32, unsigned);
+ _ATOMIC_WORD_DECLARE(AtomicUInt64, unsigned long long);
+ _ATOMIC_WORD_DECLARE(AtomicInt32, int);
+ _ATOMIC_WORD_DECLARE(AtomicInt64, long long);
+#undef _ATOMIC_WORD_DECLARE
+
+} // namespace mongo
+
diff --git a/src/mongo/platform/atomic_word_cxx11.h b/src/mongo/platform/atomic_word_cxx11.h
deleted file mode 100644
index ddf981bb9b9..00000000000
--- a/src/mongo/platform/atomic_word_cxx11.h
+++ /dev/null
@@ -1,193 +0,0 @@
-/* Copyright 2014 10gen Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#if !defined(MONGO_HAVE_CXX11_ATOMICS)
-#error "Cannot use atomic_word_cxx11.h without C++11 <atomic> support"
-#endif
-
-// This file is a bit unusual. Most other source files in this codebase assume that C++11
-// things are only usable if __cplusplus >= 201103L. However, we have made an explicit decision
-// to use <atomic> when available, even if full C++11 conformance is not advertised. As a
-// result, we unconditionally include <atomic>, but guard all other C++11 features under
-// __cplusplus >= 201103L so that we can work on platforms that don't yet offer those features, but
-// do offer <atomic>
-
-#include <atomic>
-
-#if __cplusplus >= 201103L
-#include <type_traits>
-#endif
-
-#include <boost/static_assert.hpp>
-
-#include "mongo/base/disallow_copying.h"
-
-namespace mongo {
-
- /**
- * Implementation of the AtomicWord interface in terms of the C++11 Atomics.
- */
- template <typename _WordType>
- class AtomicWord {
-
-#if __cplusplus < 201103L
- // AtomicWords are not copyable in C++03.
- MONGO_DISALLOW_COPYING(AtomicWord);
-#endif
-
- public:
- /**
- * Underlying value type.
- */
- typedef _WordType WordType;
-
- /**
- * Construct a new word with the given initial value.
- */
- explicit AtomicWord(WordType value=WordType(0)) : _value(value) {}
-
-#if __cplusplus >= 201103L
- // In C++11, AtomicWords are not copyable or movable.
- AtomicWord(const AtomicWord&) = delete;
- AtomicWord& operator=(const AtomicWord&) = delete;
- AtomicWord(AtomicWord&&) = delete;
- AtomicWord& operator=(AtomicWord&&) = delete;
-#endif
-
- /**
- * Gets the current value of this AtomicWord.
- *
- * Has acquire and release semantics.
- */
- WordType load() const {
- return _value.load();
- }
-
- /**
- * Gets the current value of this AtomicWord.
- *
- * Has relaxed semantics.
- */
- WordType loadRelaxed() const {
- return _value.load(std::memory_order_relaxed);
- }
-
- /**
- * Sets the value of this AtomicWord to "newValue".
- *
- * Has acquire and release semantics.
- */
- void store(WordType newValue) {
- return _value.store(newValue);
- }
-
- /**
- * Atomically swaps the current value of this with "newValue".
- *
- * Returns the old value.
- *
- * Has acquire and release semantics.
- */
- WordType swap(WordType newValue) {
- return _value.exchange(newValue);
- }
-
- /**
- * Atomic compare and swap.
- *
- * If this value equals "expected", sets this to "newValue".
- * Always returns the original of this.
- *
- * Has acquire and release semantics.
- */
- WordType compareAndSwap(WordType expected, WordType newValue) {
- // NOTE: Subtle: compare_exchange mutates its first argument.
- _value.compare_exchange_strong(expected, newValue);
- return expected;
- }
-
- /**
- * Get the current value of this, add "increment" and store it, atomically.
- *
- * Returns the value of this before incrementing.
- *
- * Has acquire and release semantics.
- */
- WordType fetchAndAdd(WordType increment) {
- return _value.fetch_add(increment);
- }
-
- /**
- * Get the current value of this, subtract "decrement" and store it, atomically.
- *
- * Returns the value of this before decrementing.
- *
- * Has acquire and release semantics.
- */
- WordType fetchAndSubtract(WordType decrement) {
- return _value.fetch_sub(decrement);
- }
-
- /**
- * Get the current value of this, add "increment" and store it, atomically.
- *
- * Returns the value of this after incrementing.
- *
- * Has acquire and release semantics.
- */
- WordType addAndFetch(WordType increment) {
- return fetchAndAdd(increment) + increment;
- }
-
- /**
- * Get the current value of this, subtract "decrement" and store it, atomically.
- *
- * Returns the value of this after decrementing.
- *
- * Has acquire and release semantics.
- */
- WordType subtractAndFetch(WordType decrement) {
- return fetchAndSubtract(decrement) - decrement;
- }
-
- private:
- std::atomic<WordType> _value;
- };
-
-#if __cplusplus >= 201103L
-#define _ATOMIC_WORD_DECLARE(NAME, WTYPE) \
- typedef class AtomicWord<WTYPE> NAME; \
- namespace { \
- BOOST_STATIC_ASSERT(sizeof(NAME) == sizeof(WTYPE)); \
- BOOST_STATIC_ASSERT(std::is_standard_layout<WTYPE>::value); \
- } // namespace
-#else
-#define _ATOMIC_WORD_DECLARE(NAME, WTYPE) \
- typedef class AtomicWord<WTYPE> NAME; \
- namespace { \
- BOOST_STATIC_ASSERT(sizeof(NAME) == sizeof(WTYPE)); \
- } // namespace
-#endif
-
- _ATOMIC_WORD_DECLARE(AtomicUInt32, unsigned);
- _ATOMIC_WORD_DECLARE(AtomicUInt64, unsigned long long);
- _ATOMIC_WORD_DECLARE(AtomicInt32, int);
- _ATOMIC_WORD_DECLARE(AtomicInt64, long long);
-#undef _ATOMIC_WORD_DECLARE
-
-} // namespace mongo
-
diff --git a/src/mongo/platform/atomic_word_intrinsics.h b/src/mongo/platform/atomic_word_intrinsics.h
deleted file mode 100644
index 7b1997526e2..00000000000
--- a/src/mongo/platform/atomic_word_intrinsics.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/* Copyright 2012 10gen Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <boost/static_assert.hpp>
-
-#include "mongo/base/disallow_copying.h"
-#include "mongo/platform/atomic_intrinsics.h"
-#include "mongo/platform/compiler.h"
-
-namespace mongo {
-
- /**
- * Template type for word types supporting indivisible memory operations, implemented
- * in terms of the atomic_intrinsics header.
- *
- * Effects of operations with "acquire" semantics are visible to other threads before effects of
- * any subsequent operation by the calling thread. Effects of operations with "release"
- * semantics are visible to other processors only after the effects of previous operations on
- * the current thread are visible.
- *
- * NOTE(schwerin): This implementation assumes that instances are naturally aligned.
- * Instances that are not naturally aligned may operate incorrectly, or not at all. Natural
- * alignment for this purpose means that the byte address of the beginning of the object is an
- * integer multiple of the size of the type, in bytes.
- *
- * NOTE(schwerin): This is a low level concurrency type, it is very hard to use correctly, and
- * you should not decide to use it lightly.
- *
- * NOTE(schwerin): This type is and must be a POD type, or per C++11 rules, a "Standard-layout"
- * type.
- */
- template <typename _WordType>
- class AtomicWord {
- MONGO_DISALLOW_COPYING(AtomicWord);
-
- public:
- /**
- * Underlying value type.
- */
- typedef _WordType WordType;
-
- /**
- * Construct a new word with the given initial value.
- */
- explicit AtomicWord(WordType value=WordType(0)) : _value(value) {}
-
- /**
- * Gets the current value of this AtomicWord.
- *
- * Has acquire and release semantics.
- */
- WordType load() const { return AtomicIntrinsics<WordType>::load(&_value); }
-
- /**
- * Gets the current value of this AtomicWord.
- *
- * Has relaxed semantics.
- */
- WordType loadRelaxed() const { return AtomicIntrinsics<WordType>::loadRelaxed(&_value); }
-
- /**
- * Sets the value of this AtomicWord to "newValue".
- *
- * Has acquire and release semantics.
- */
- void store(WordType newValue) { AtomicIntrinsics<WordType>::store(&_value, newValue); }
-
- /**
- * Atomically swaps the current value of this with "newValue".
- *
- * Returns the old value.
- *
- * Has acquire and release semantics.
- */
- WordType swap(WordType newValue) {
- return AtomicIntrinsics<WordType>::swap(&_value, newValue);
- }
-
- /**
- * Atomic compare and swap.
- *
- * If this value equals "expected", sets this to "newValue".
- * Always returns the original of this.
- *
- * Has acquire and release semantics.
- */
- WordType compareAndSwap(WordType expected, WordType newValue) {
- return AtomicIntrinsics<WordType>::compareAndSwap(&_value, expected, newValue);
- }
-
- /**
- * Get the current value of this, add "increment" and store it, atomically.
- *
- * Returns the value of this before incrementing.
- *
- * Has acquire and release semantics.
- */
- WordType fetchAndAdd(WordType increment) {
- return AtomicIntrinsics<WordType>::fetchAndAdd(&_value, increment);
- }
-
- /**
- * Get the current value of this, subtract "decrement" and store it, atomically.
- *
- * Returns the value of this before decrementing.
- *
- * Has acquire and release semantics.
- */
- WordType fetchAndSubtract(WordType decrement) {
- return fetchAndAdd(WordType(0) - decrement);
- }
-
- /**
- * Get the current value of this, add "increment" and store it, atomically.
- *
- * Returns the value of this after incrementing.
- *
- * Has acquire and release semantics.
- */
- WordType addAndFetch(WordType increment) {
- return fetchAndAdd(increment) + increment;
- }
-
- /**
- * Get the current value of this, subtract "decrement" and store it, atomically.
- *
- * Returns the value of this after decrementing.
- *
- * Has acquire and release semantics.
- */
- WordType subtractAndFetch(WordType decrement) {
- return fetchAndSubtract(decrement) - decrement;
- }
-
- private:
- volatile WordType _value;
- };
-
-#define _ATOMIC_WORD_DECLARE(NAME, WTYPE) \
- typedef class AtomicWord<WTYPE> NAME; \
- namespace { BOOST_STATIC_ASSERT(sizeof(NAME) == sizeof(WTYPE)); }
-
- _ATOMIC_WORD_DECLARE(AtomicUInt32, unsigned);
- _ATOMIC_WORD_DECLARE(AtomicUInt64, unsigned long long);
- _ATOMIC_WORD_DECLARE(AtomicInt32, int);
- _ATOMIC_WORD_DECLARE(AtomicInt64, long long);
-#undef _ATOMIC_WORD_DECLARE
-
-} // namespace mongo
-
diff --git a/src/mongo/platform/hash_namespace.h b/src/mongo/platform/hash_namespace.h
index be1fb95c4d9..6e0b7fcf38a 100644
--- a/src/mongo/platform/hash_namespace.h
+++ b/src/mongo/platform/hash_namespace.h
@@ -27,50 +27,8 @@
#pragma once
-// We need to drag in a C++ header so we can examine __GXX_EXPERIMENTAL_CXX0X__ or
-// _LIBCPP_VERSION meaningfully. The <new> header is pretty lightweight, mostly unavoidable,
-// and almost certain to bring in the standard library configuration macros.
-#include <new>
-
-// NOTE(acm): Before gcc-4.7, __cplusplus is always defined to be 1, so we can't reliably
-// detect C++11 support by exclusively checking the value of __cplusplus. Additionaly, libc++,
-// whether in C++11 or C++03 mode, doesn't use TR1 and drops things into std instead.
-#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(_LIBCPP_VERSION)
-
-#include <functional>
-
-#define MONGO_HASH_NAMESPACE_START namespace std {
-#define MONGO_HASH_NAMESPACE_END }
-#define MONGO_HASH_NAMESPACE std
-
-#elif defined(_MSC_VER) && _MSC_VER >= 1500
-
-#if _MSC_VER >= 1600 /* Visual Studio 2010+ */
-
#include <functional>
#define MONGO_HASH_NAMESPACE_START namespace std {
#define MONGO_HASH_NAMESPACE_END }
#define MONGO_HASH_NAMESPACE std
-
-#else /* Older Visual Studio */
-
-#include <tr1/functional>
-
-#define MONGO_HASH_NAMESPACE_START namespace std { namespace tr1 {
-#define MONGO_HASH_NAMESPACE_END }}
-#define MONGO_HASH_NAMESPACE std::tr1
-
-#endif
-
-#elif defined(__GNUC__)
-
-#include <tr1/functional>
-
-#define MONGO_HASH_NAMESPACE_START namespace std { namespace tr1 {
-#define MONGO_HASH_NAMESPACE_END }}
-#define MONGO_HASH_NAMESPACE std::tr1
-
-#else
-#error "Cannot determine namespace for 'hash'"
-#endif
diff --git a/src/mongo/platform/unordered_map.h b/src/mongo/platform/unordered_map.h
index c88f05229fb..5bf3e340962 100644
--- a/src/mongo/platform/unordered_map.h
+++ b/src/mongo/platform/unordered_map.h
@@ -27,16 +27,6 @@
#pragma once
-// We need to drag in a C++ header so we can examine __GXX_EXPERIMENTAL_CXX0X__ or
-// _LIBCPP_VERSION meaningfully. The <new> header is pretty lightweight, mostly unavoidable,
-// and almost certain to bring in the standard library configuration macros.
-#include <new>
-
-// NOTE(acm): Before gcc-4.7, __cplusplus is always defined to be 1, so we can't reliably
-// detect C++11 support by exclusively checking the value of __cplusplus. Additionaly, libc++,
-// whether in C++11 or C++03 mode, doesn't use TR1 and drops things into std instead.
-#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(_LIBCPP_VERSION)
-
#include <unordered_map>
namespace mongo {
@@ -44,31 +34,3 @@ namespace mongo {
using std::unordered_map;
} // namespace mongo
-
-#elif defined(_MSC_VER) && _MSC_VER >= 1500
-
-#include <unordered_map>
-
-namespace mongo {
-
-#if _MSC_VER >= 1600 /* Visual Studio 2010+ */
- using std::unordered_map;
-#else
- using std::tr1::unordered_map;
-#endif
-
-} // namespace mongo
-
-#elif defined(__GNUC__)
-
-#include <tr1/unordered_map>
-
-namespace mongo {
-
- using std::tr1::unordered_map;
-
-} // namespace mongo
-
-#else
-#error "Compiler's standard library does not provide a C++ unordered_map implementation."
-#endif
diff --git a/src/mongo/platform/unordered_set.h b/src/mongo/platform/unordered_set.h
index 20b392095eb..4733ab73973 100644
--- a/src/mongo/platform/unordered_set.h
+++ b/src/mongo/platform/unordered_set.h
@@ -27,16 +27,6 @@
#pragma once
-// We need to drag in a C++ header so we can examine __GXX_EXPERIMENTAL_CXX0X__ or
-// _LIBCPP_VERSION meaningfully. The <new> header is pretty lightweight, mostly unavoidable,
-// and almost certain to bring in the standard library configuration macros.
-#include <new>
-
-// NOTE(acm): Before gcc-4.7, __cplusplus is always defined to be 1, so we can't reliably
-// detect C++11 support by exclusively checking the value of __cplusplus. Additionaly, libc++,
-// whether in C++11 or C++03 mode, doesn't use TR1 and drops things into std instead.
-#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(_LIBCPP_VERSION)
-
#include <unordered_set>
namespace mongo {
@@ -44,31 +34,3 @@ namespace mongo {
using std::unordered_set;
} // namespace mongo
-
-#elif defined(_MSC_VER) && _MSC_VER >= 1500
-
-#include <unordered_set>
-
-namespace mongo {
-
-#if _MSC_VER >= 1600 /* Visual Studio 2010+ */
- using std::unordered_set;
-#else
- using std::tr1::unordered_set;
-#endif
-
-} // namespace mongo
-
-#elif defined(__GNUC__)
-
-#include <tr1/unordered_set>
-
-namespace mongo {
-
- using std::tr1::unordered_set;
-
-} // namespace mongo
-
-#else
-#error "Compiler's standard library does not provide a C++ unordered_set implementation."
-#endif