chromium/third_party/ruy/src/ruy/check_macros.h

/* Copyright 2019 Google LLC. All Rights Reserved.

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.
==============================================================================*/

// self-contained, minimal, CHECK/DCHECK macros similar to glog.

#ifndef RUY_RUY_CHECK_MACROS_H_
#define RUY_RUY_CHECK_MACROS_H_

#include <cstdio>
#include <cstdlib>
#include <functional>
#include <type_traits>

namespace ruy {
namespace check_macros {

constexpr int kValueBufSize =;

template <typename T, typename Enable = void>
struct ToString {};

template <>
struct ToString<float, void> {};

template <>
struct ToString<double, void> {};

ToString<T, typename std::enable_if<std::is_integral<T>::value>::type>;

ToString<T *, void>;

ToString<T, typename std::enable_if<std::is_enum<T>::value>::type>;

inline void CheckImpl(bool condition, const char* file, int line,
                      const char* macro, const char* condition_str) {}

template <template <typename T> class Comparison, typename LhsType,
          typename RhsType>
inline void CheckImpl(const char* file, int line, const char* macro,
                      const char* lhs, const LhsType& lhs_value,
                      const char* op_symbol, const char* rhs,
                      const RhsType& rhs_value) {}

#define RUY_CHECK_IMPL(macro, condition)

#define RUY_CHECK_OP_IMPL(macro, lhs, op_symbol, op_comparison, rhs)

#define RUY_CHECK(condition)
#define RUY_CHECK_EQ(x, y)
#define RUY_CHECK_NE(x, y)
#define RUY_CHECK_GE(x, y)
#define RUY_CHECK_GT(x, y)
#define RUY_CHECK_LE(x, y)
#define RUY_CHECK_LT(x, y)

#ifdef NDEBUG
#define RUY_DCHECK_IS_ENABLED
#else
#define RUY_DCHECK_IS_ENABLED
#endif

#define RUY_DCHECK(condition)
#define RUY_DCHECK_EQ(x, y)
#define RUY_DCHECK_NE(x, y)
#define RUY_DCHECK_GE(x, y)
#define RUY_DCHECK_GT(x, y)
#define RUY_DCHECK_LE(x, y)
#define RUY_DCHECK_LT(x, y)

}  // end namespace check_macros
}  // end namespace ruy

#endif  // RUY_RUY_CHECK_MACROS_H_