llvm/third-party/benchmark/src/check.h

#ifndef CHECK_H_
#define CHECK_H_

#include <cmath>
#include <cstdlib>
#include <ostream>

#include "benchmark/export.h"
#include "internal_macros.h"
#include "log.h"

#if defined(__GNUC__) || defined(__clang__)
#define BENCHMARK_NOEXCEPT
#define BENCHMARK_NOEXCEPT_OP(x)
#elif defined(_MSC_VER) && !defined(__clang__)
#if _MSC_VER >= 1900
#define BENCHMARK_NOEXCEPT
#define BENCHMARK_NOEXCEPT_OP
#else
#define BENCHMARK_NOEXCEPT
#define BENCHMARK_NOEXCEPT_OP
#endif
#define __func__ __FUNCTION__
#else
#define BENCHMARK_NOEXCEPT
#define BENCHMARK_NOEXCEPT_OP
#endif

namespace benchmark {
namespace internal {

AbortHandlerT;

BENCHMARK_EXPORT
AbortHandlerT*& GetAbortHandler();

BENCHMARK_NORETURN inline void CallAbortHandler() {}

// CheckHandler is the class constructed by failing BM_CHECK macros.
// CheckHandler will log information about the failures and abort when it is
// destructed.
class CheckHandler {};

}  // end namespace internal
}  // end namespace benchmark

// The BM_CHECK macro returns a std::ostream object that can have extra
// information written to it.
#ifndef NDEBUG
#define BM_CHECK
#else
#define BM_CHECK(b)
#endif

// clang-format off
// preserve whitespacing between operators for alignment
#define BM_CHECK_EQ(a, b)
#define BM_CHECK_NE(a, b)
#define BM_CHECK_GE(a, b)
#define BM_CHECK_LE(a, b)
#define BM_CHECK_GT(a, b)
#define BM_CHECK_LT(a, b)

#define BM_CHECK_FLOAT_EQ(a, b, eps)
#define BM_CHECK_FLOAT_NE(a, b, eps)
#define BM_CHECK_FLOAT_GE(a, b, eps)
#define BM_CHECK_FLOAT_LE(a, b, eps)
#define BM_CHECK_FLOAT_GT(a, b, eps)
#define BM_CHECK_FLOAT_LT(a, b, eps)
//clang-format on

#endif  // CHECK_H_