2019-02-12 16:45:14 +01:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2019-02-12 16:45:14 +01:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
2019-02-12 21:19:11 +01:00
|
|
|
|
|
|
|
#define TD_DUMMY_CHECK(condition) ((void)(condition))
|
|
|
|
|
2019-02-12 18:48:13 +01:00
|
|
|
#define CHECK(condition) \
|
|
|
|
if (!(condition)) { \
|
|
|
|
::td::detail::process_check_error(#condition, __FILE__, __LINE__); \
|
2019-02-12 16:45:14 +01:00
|
|
|
}
|
2019-02-12 18:48:13 +01:00
|
|
|
|
2019-02-12 21:19:11 +01:00
|
|
|
// clang-format off
|
|
|
|
#ifdef NDEBUG
|
|
|
|
#define DCHECK TD_DUMMY_CHECK
|
2019-02-13 11:33:14 +01:00
|
|
|
#else
|
|
|
|
#define DCHECK CHECK
|
2019-02-12 18:48:13 +01:00
|
|
|
#endif
|
2019-02-12 21:19:11 +01:00
|
|
|
// clang-format on
|
2019-02-12 18:48:13 +01:00
|
|
|
|
2019-02-12 21:19:11 +01:00
|
|
|
#define UNREACHABLE() ::td::detail::process_check_error("Unreachable", __FILE__, __LINE__)
|
2019-02-12 18:48:13 +01:00
|
|
|
|
2019-02-12 16:45:14 +01:00
|
|
|
namespace td {
|
|
|
|
namespace detail {
|
2019-02-12 21:19:11 +01:00
|
|
|
|
2019-02-12 18:48:13 +01:00
|
|
|
[[noreturn]] void process_check_error(const char *message, const char *file, int line);
|
2019-02-12 21:19:11 +01:00
|
|
|
|
|
|
|
} // namespace detail
|
2019-02-12 16:45:14 +01:00
|
|
|
} // namespace td
|