diff options
author | Luke Chen <luke.chen@mongodb.com> | 2019-08-21 05:23:37 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-08-21 05:23:37 +0000 |
commit | ac41c65f6355f83aac70136324c98561ac79daa1 (patch) | |
tree | a7c3f7ef090b59c6a06838a02c96bd1d49e1c729 /src/third_party/wiredtiger/src/include/msvc.h | |
parent | f54709196711c63a429b71f47c584661286d675f (diff) | |
download | mongo-ac41c65f6355f83aac70136324c98561ac79daa1.tar.gz |
Import wiredtiger: 7dfd9391862bc9a6d84868c4dc51689c45a3aacf from branch mongodb-4.4
ref: c809757d8b..7dfd939186
for: 4.3.1
WT-4658 Apply Clang Format
WT-4810 Adding WT_ERR_ASSERT and WT_RET_ASSERT macros
WT-5046 Prepared transactions aren't properly cleared from global table with WT_CONN_LOG_DEBUG_MODE enabled
Diffstat (limited to 'src/third_party/wiredtiger/src/include/msvc.h')
-rw-r--r-- | src/third_party/wiredtiger/src/include/msvc.h | 121 |
1 files changed, 79 insertions, 42 deletions
diff --git a/src/third_party/wiredtiger/src/include/msvc.h b/src/third_party/wiredtiger/src/include/msvc.h index f4d8dc942f6..232683b2af2 100644 --- a/src/third_party/wiredtiger/src/include/msvc.h +++ b/src/third_party/wiredtiger/src/include/msvc.h @@ -11,50 +11,44 @@ #error "Only x64 is supported with MSVC" #endif -#define inline __inline +#define inline __inline /* MSVC Doesn't provide __func__, it has __FUNCTION__ */ #ifdef _MSC_VER -#define __func__ __FUNCTION__ +#define __func__ __FUNCTION__ #endif -#define WT_PTRDIFFT_FMT "Id" /* ptrdiff_t format string */ -#define WT_SIZET_FMT "Iu" /* size_t format string */ +#define WT_PTRDIFFT_FMT "Id" /* ptrdiff_t format string */ +#define WT_SIZET_FMT "Iu" /* size_t format string */ /* MSVC-specific attributes. */ -#define WT_PACKED_STRUCT_BEGIN(name) \ - __pragma(pack(push,1)) \ - struct name { +#define WT_PACKED_STRUCT_BEGIN(name) __pragma(pack(push, 1)) struct name { -#define WT_PACKED_STRUCT_END \ - }; \ - __pragma(pack(pop)) +#define WT_PACKED_STRUCT_END \ + } \ + ; \ + __pragma(pack(pop)) -#define WT_GCC_FUNC_ATTRIBUTE(x) -#define WT_GCC_FUNC_DECL_ATTRIBUTE(x) +#define WT_GCC_FUNC_ATTRIBUTE(x) +#define WT_GCC_FUNC_DECL_ATTRIBUTE(x) -#define WT_ATOMIC_FUNC(name, ret, type, s, t) \ -static inline ret \ -__wt_atomic_add##name(type *vp, type v) \ -{ \ - return (_InterlockedExchangeAdd ## s((t *)(vp), (t)(v)) + (v)); \ -} \ -static inline ret \ -__wt_atomic_fetch_add##name(type *vp, type v) \ -{ \ - return (_InterlockedExchangeAdd ## s((t *)(vp), (t)(v))); \ -} \ -static inline ret \ -__wt_atomic_sub##name(type *vp, type v) \ -{ \ - return (_InterlockedExchangeAdd ## s((t *)(vp), - (t)v) - (v)); \ -} \ -static inline bool \ -__wt_atomic_cas##name(type *vp, type old, type new) \ -{ \ - return (_InterlockedCompareExchange ## s \ - ((t *)(vp), (t)(new), (t)(old)) == (t)(old)); \ -} +#define WT_ATOMIC_FUNC(name, ret, type, s, t) \ + static inline ret __wt_atomic_add##name(type *vp, type v) \ + { \ + return (_InterlockedExchangeAdd##s((t *)(vp), (t)(v)) + (v)); \ + } \ + static inline ret __wt_atomic_fetch_add##name(type *vp, type v) \ + { \ + return (_InterlockedExchangeAdd##s((t *)(vp), (t)(v))); \ + } \ + static inline ret __wt_atomic_sub##name(type *vp, type v) \ + { \ + return (_InterlockedExchangeAdd##s((t *)(vp), -(t)v) - (v)); \ + } \ + static inline bool __wt_atomic_cas##name(type *vp, type old, type new) \ + { \ + return (_InterlockedCompareExchange##s((t *)(vp), (t)(new), (t)(old)) == (t)(old)); \ + } WT_ATOMIC_FUNC(8, uint8_t, uint8_t, 8, char) WT_ATOMIC_FUNC(16, uint16_t, uint16_t, 16, short) @@ -70,17 +64,60 @@ WT_ATOMIC_FUNC(size, size_t, size_t, 64, __int64) /* * __wt_atomic_cas_ptr -- - * Pointer compare and swap. + * Pointer compare and swap. */ static inline bool __wt_atomic_cas_ptr(void *vp, void *old, void *new) { - return (_InterlockedCompareExchange64( - vp, (int64_t)new, (int64_t)old) == ((int64_t)old)); + return (_InterlockedCompareExchange64(vp, (int64_t) new, (int64_t)old) == ((int64_t)old)); } -static inline void WT_BARRIER(void) { _ReadWriteBarrier(); } -static inline void WT_FULL_BARRIER(void) { _mm_mfence(); } -static inline void WT_PAUSE(void) { _mm_pause(); } -static inline void WT_READ_BARRIER(void) { _mm_lfence(); } -static inline void WT_WRITE_BARRIER(void) { _mm_sfence(); } +/* + * WT_BARRIER -- + * MSVC implementation of WT_BARRIER. + */ +static inline void +WT_BARRIER(void) +{ + _ReadWriteBarrier(); +} + +/* + * WT_FULL_BARRIER -- + * MSVC implementation of WT_FULL_BARRIER. + */ +static inline void +WT_FULL_BARRIER(void) +{ + _mm_mfence(); +} + +/* + * WT_PAUSE -- + * MSVC implementation of WT_PAUSE. + */ +static inline void +WT_PAUSE(void) +{ + _mm_pause(); +} + +/* + * WT_READ_BARRIER -- + * MSVC implementation of WT_READ_BARRIER. + */ +static inline void +WT_READ_BARRIER(void) +{ + _mm_lfence(); +} + +/* + * WT_WRITE_BARRIER -- + * MSVC implementation of WT_WRITE_BARRIER. + */ +static inline void +WT_WRITE_BARRIER(void) +{ + _mm_sfence(); +} |