summaryrefslogtreecommitdiff
path: root/src/mongo/platform
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/platform')
-rw-r--r--src/mongo/platform/atomic_proxy.h9
-rw-r--r--src/mongo/platform/atomic_word.h11
-rw-r--r--src/mongo/platform/decimal128.cpp5
-rw-r--r--src/mongo/platform/endian.h16
-rw-r--r--src/mongo/platform/process_id.cpp5
5 files changed, 26 insertions, 20 deletions
diff --git a/src/mongo/platform/atomic_proxy.h b/src/mongo/platform/atomic_proxy.h
index ae7960cb930..7f1dcb2061a 100644
--- a/src/mongo/platform/atomic_proxy.h
+++ b/src/mongo/platform/atomic_proxy.h
@@ -33,6 +33,7 @@
#include <cstring>
#include <type_traits>
+#include "mongo/base/static_assert.h"
#include "mongo/config.h"
namespace mongo {
@@ -43,10 +44,12 @@ namespace mongo {
*/
template <typename T, typename BaseWordT>
class AtomicProxy {
- static_assert(sizeof(T) == sizeof(BaseWordT), "T and BaseWordT must have the same size");
- static_assert(std::is_integral<BaseWordT>::value, "BaseWordT must be an integral type");
+ MONGO_STATIC_ASSERT_MSG(sizeof(T) == sizeof(BaseWordT),
+ "T and BaseWordT must have the same size");
+ MONGO_STATIC_ASSERT_MSG(std::is_integral<BaseWordT>::value,
+ "BaseWordT must be an integral type");
#if MONGO_HAVE_STD_IS_TRIVIALLY_COPYABLE
- static_assert(std::is_trivially_copyable<T>::value, "T must be trivially copyable");
+ MONGO_STATIC_ASSERT_MSG(std::is_trivially_copyable<T>::value, "T must be trivially copyable");
#endif
public:
using value_type = T;
diff --git a/src/mongo/platform/atomic_word.h b/src/mongo/platform/atomic_word.h
index f38763719a1..eb19496f0ba 100644
--- a/src/mongo/platform/atomic_word.h
+++ b/src/mongo/platform/atomic_word.h
@@ -30,6 +30,7 @@
#include <atomic>
#include <type_traits>
+#include "mongo/base/static_assert.h"
namespace mongo {
@@ -149,11 +150,11 @@ private:
std::atomic<WordType> _value; // NOLINT
};
-#define _ATOMIC_WORD_DECLARE(NAME, WTYPE) \
- typedef class AtomicWord<WTYPE> NAME; \
- namespace { \
- static_assert(sizeof(NAME) == sizeof(WTYPE), "sizeof(NAME) == sizeof(WTYPE)"); \
- static_assert(std::is_standard_layout<WTYPE>::value, "std::is_standard_layout<WTYPE>::value"); \
+#define _ATOMIC_WORD_DECLARE(NAME, WTYPE) \
+ typedef class AtomicWord<WTYPE> NAME; \
+ namespace { \
+ MONGO_STATIC_ASSERT(sizeof(NAME) == sizeof(WTYPE)); \
+ MONGO_STATIC_ASSERT(std::is_standard_layout<WTYPE>::value); \
} // namespace
_ATOMIC_WORD_DECLARE(AtomicUInt32, unsigned);
diff --git a/src/mongo/platform/decimal128.cpp b/src/mongo/platform/decimal128.cpp
index 8d6dad6f7e4..d6a57fde649 100644
--- a/src/mongo/platform/decimal128.cpp
+++ b/src/mongo/platform/decimal128.cpp
@@ -44,6 +44,7 @@
#include <third_party/IntelRDFPMathLib20U1/LIBRARY/src/bid_functions.h>
#undef _WCHAR_T
+#include "mongo/base/static_assert.h"
#include "mongo/config.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/stringutils.h"
@@ -841,8 +842,8 @@ const std::uint64_t t17hi32 = t17 >> 32;
// t17hi32*t17hi32 + 2*t17hi32*t17lo32 + t17lo32*t17lo32 where the 2nd term
// is shifted right by 32 and the 3rd term by 64 (which effectively drops the 3rd term)
const std::uint64_t t34hi64 = t17hi32 * t17hi32 + (((t17hi32 * t17lo32) >> 31));
-static_assert(t34hi64 == 0x1ed09bead87c0, "");
-static_assert(t34lo64 == 0x378d8e63ffffffff, "");
+MONGO_STATIC_ASSERT(t34hi64 == 0x1ed09bead87c0);
+MONGO_STATIC_ASSERT(t34lo64 == 0x378d8e63ffffffff);
} // namespace
// (t34hi64 << 64) + t34lo64 == 1e34 - 1
diff --git a/src/mongo/platform/endian.h b/src/mongo/platform/endian.h
index faa6f686e29..f94586dc84a 100644
--- a/src/mongo/platform/endian.h
+++ b/src/mongo/platform/endian.h
@@ -32,6 +32,7 @@
#include <cstring>
#include <type_traits>
+#include "mongo/base/static_assert.h"
#include "mongo/config.h"
#include "mongo/platform/decimal128.h"
@@ -340,7 +341,7 @@ struct ByteOrderConverter<float> {
typedef float T;
inline static T nativeToBig(T t) {
- static_assert(sizeof(T) == sizeof(uint32_t), "sizeof(T) == sizeof(uint32_t)");
+ MONGO_STATIC_ASSERT(sizeof(T) == sizeof(uint32_t));
uint32_t temp;
std::memcpy(&temp, &t, sizeof(t));
@@ -379,7 +380,7 @@ struct ByteOrderConverter<double> {
typedef double T;
inline static T nativeToBig(T t) {
- static_assert(sizeof(T) == sizeof(uint64_t), "sizeof(T) == sizeof(uint64_t)");
+ MONGO_STATIC_ASSERT(sizeof(T) == sizeof(uint64_t));
uint64_t temp;
std::memcpy(&temp, &t, sizeof(t));
@@ -452,32 +453,31 @@ struct IntegralTypeMap {
template <>
struct IntegralTypeMap<signed char> {
- static_assert(CHAR_BIT == 8, "CHAR_BIT == 8");
+ MONGO_STATIC_ASSERT(CHAR_BIT == 8);
typedef int8_t type;
};
template <>
struct IntegralTypeMap<unsigned char> {
- static_assert(CHAR_BIT == 8, "CHAR_BIT == 8");
+ MONGO_STATIC_ASSERT(CHAR_BIT == 8);
typedef uint8_t type;
};
template <>
struct IntegralTypeMap<char> {
- static_assert(CHAR_BIT == 8, "CHAR_BIT == 8");
+ MONGO_STATIC_ASSERT(CHAR_BIT == 8);
typedef std::conditional<std::is_signed<char>::value, int8_t, uint8_t>::type type;
};
template <>
struct IntegralTypeMap<long long> {
- static_assert(sizeof(long long) == sizeof(int64_t), "sizeof(long long) == sizeof(int64_t)");
+ MONGO_STATIC_ASSERT(sizeof(long long) == sizeof(int64_t));
typedef int64_t type;
};
template <>
struct IntegralTypeMap<unsigned long long> {
- static_assert(sizeof(unsigned long long) == sizeof(uint64_t),
- "sizeof(unsigned long long) == sizeof(uint64_t)");
+ MONGO_STATIC_ASSERT(sizeof(unsigned long long) == sizeof(uint64_t));
typedef uint64_t type;
};
diff --git a/src/mongo/platform/process_id.cpp b/src/mongo/platform/process_id.cpp
index 12bab6fbeab..d7b51bb064a 100644
--- a/src/mongo/platform/process_id.cpp
+++ b/src/mongo/platform/process_id.cpp
@@ -33,10 +33,11 @@
#include <limits>
#include <sstream>
+#include "mongo/base/static_assert.h"
+
namespace mongo {
-static_assert(sizeof(NativeProcessId) == sizeof(uint32_t),
- "sizeof(NativeProcessId) == sizeof(uint32_t)");
+MONGO_STATIC_ASSERT(sizeof(NativeProcessId) == sizeof(uint32_t));
namespace {
#ifdef _WIN32