#include <folly/synchronization/detail/Hardware.h>
#include <atomic>
#include <cstdlib>
#include <stdexcept>
#include <utility>
#include <boost/preprocessor/repetition/repeat.hpp>
#include <folly/CppAttributes.h>
#include <folly/lang/Assume.h>
#include <folly/lang/Exception.h>
#if FOLLY_X64 && defined(__RTM__)
#include <immintrin.h>
#define FOLLY_RTM_SUPPORT …
#else
#define FOLLY_RTM_SUPPORT …
#endif
#if FOLLY_RTM_SUPPORT
#if defined(__GNUC__) || defined(__clang__)
#include <cpuid.h>
#elif defined(_MSC_VER)
#include <intrin.h>
#endif
#endif
namespace folly {
static bool rtmEnabledImpl() { … }
bool rtmEnabled() { … }
#if FOLLY_RTM_SUPPORT
#define FOLLY_RTM_DISABLED_NORETURN
#else
#define FOLLY_RTM_DISABLED_NORETURN …
#endif
FOLLY_RTM_DISABLED_NORETURN static unsigned rtmBeginFunc() { … }
FOLLY_RTM_DISABLED_NORETURN static void rtmEndFunc() { … }
FOLLY_RTM_DISABLED_NORETURN static bool rtmTestFunc() { … }
[[noreturn]] FOLLY_DISABLE_SANITIZERS static void rtmAbortFunc(
[[maybe_unused]] uint8_t status) { … }
namespace detail {
unsigned rtmBeginDisabled() { … }
void rtmEndDisabled() { … }
bool rtmTestDisabled() { … }
[[noreturn]] void rtmAbortDisabled(uint8_t) { … }
static void rewrite() { … }
unsigned rtmBeginVE() { … }
void rtmEndVE() { … }
bool rtmTestVE() { … }
void rtmAbortVE(uint8_t status) { … }
std::atomic<unsigned (*)()> rtmBeginV{ … };
std::atomic<void (*)()> rtmEndV{ … };
std::atomic<bool (*)()> rtmTestV{ … };
std::atomic<void (*)(uint8_t)> rtmAbortV{ … };
}
}