Move rtc_base/checks.h and includes to webrtc namespace
Bug: webrtc:42232595 Change-Id: I5459af35b9bbab57748dd74cb9151562b9ff2607 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/376480 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Evan Shrubsole <eshr@webrtc.org> Cr-Commit-Position: refs/heads/main@{#43856}
This commit is contained in:
parent
150943c078
commit
c84133987c
@ -59,7 +59,7 @@ void AppendFormat(std::string* s, const char* fmt, ...) {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace rtc {
|
||||
namespace webrtc {
|
||||
namespace webrtc_checks_impl {
|
||||
|
||||
#if !defined(WEBRTC_CHROMIUM_BUILD)
|
||||
@ -224,17 +224,17 @@ RTC_NORETURN void UnreachableCodeReached() {
|
||||
#endif // !RTC_DCHECK_IS_ON
|
||||
|
||||
} // namespace webrtc_checks_impl
|
||||
} // namespace rtc
|
||||
} // namespace webrtc
|
||||
|
||||
// Function to call from the C version of the RTC_CHECK and RTC_DCHECK macros.
|
||||
RTC_NORETURN void rtc_FatalMessage(const char* file,
|
||||
int line,
|
||||
const char* msg) {
|
||||
#if RTC_CHECK_MSG_ENABLED
|
||||
static constexpr rtc::webrtc_checks_impl::CheckArgType t[] = {
|
||||
rtc::webrtc_checks_impl::CheckArgType::kEnd};
|
||||
rtc::webrtc_checks_impl::FatalLog(file, line, msg, t);
|
||||
static constexpr webrtc::webrtc_checks_impl::CheckArgType t[] = {
|
||||
webrtc::webrtc_checks_impl::CheckArgType::kEnd};
|
||||
webrtc::webrtc_checks_impl::FatalLog(file, line, msg, t);
|
||||
#else
|
||||
rtc::webrtc_checks_impl::FatalLog(file, line);
|
||||
webrtc::webrtc_checks_impl::FatalLog(file, line);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
#ifndef RTC_BASE_CHECKS_H_
|
||||
#define RTC_BASE_CHECKS_H_
|
||||
|
||||
// If you for some reson need to know if DCHECKs are on, test the value of
|
||||
// If you for some reason need to know if DCHECKs are on, test the value of
|
||||
// RTC_DCHECK_IS_ON. (Test its value, not if it's defined; it'll always be
|
||||
// defined, to either a true or a false value.)
|
||||
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
|
||||
@ -52,7 +52,9 @@ RTC_NORETURN void rtc_FatalMessage(const char* file, int line, const char* msg);
|
||||
#ifdef __cplusplus
|
||||
// C++ version.
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
#include "absl/meta/type_traits.h"
|
||||
#include "absl/strings/has_absl_stringify.h"
|
||||
@ -101,7 +103,10 @@ RTC_NORETURN void rtc_FatalMessage(const char* file, int line, const char* msg);
|
||||
//
|
||||
// - RTC_FATAL() aborts unconditionally.
|
||||
|
||||
namespace rtc {
|
||||
// TODO(bugs.webrtc.org/42232595): Remove this macro once Chrome has migrated.
|
||||
#define RTC_CHECKS_IN_WEBRTC_NAMESPACE 1
|
||||
|
||||
namespace webrtc {
|
||||
namespace webrtc_checks_impl {
|
||||
enum class CheckArgType : int8_t {
|
||||
kEnd = 0,
|
||||
@ -205,7 +210,7 @@ inline Val<CheckArgType::kVoidP, const void*> MakeVal(const void* x) {
|
||||
|
||||
template <typename T>
|
||||
inline Val<CheckArgType::kVoidP, const void*> MakeVal(
|
||||
const rtc::scoped_refptr<T>& p) {
|
||||
const webrtc::scoped_refptr<T>& p) {
|
||||
return {p.get()};
|
||||
}
|
||||
|
||||
@ -383,14 +388,14 @@ RTC_NORETURN RTC_EXPORT void UnreachableCodeReached();
|
||||
#define RTC_EAT_STREAM_PARAMETERS(ignored) \
|
||||
(true ? true : ((void)(ignored), true)) \
|
||||
? static_cast<void>(0) \
|
||||
: ::rtc::webrtc_checks_impl::FatalLogCall<false>("", 0, "") & \
|
||||
::rtc::webrtc_checks_impl::LogStreamer<>()
|
||||
: ::webrtc::webrtc_checks_impl::FatalLogCall<false>("", 0, "") & \
|
||||
::webrtc::webrtc_checks_impl::LogStreamer<>()
|
||||
|
||||
// Call RTC_EAT_STREAM_PARAMETERS with an argument that fails to compile if
|
||||
// values of the same types as `a` and `b` can't be compared with the given
|
||||
// operation, and that would evaluate `a` and `b` if evaluated.
|
||||
#define RTC_EAT_STREAM_PARAMETERS_OP(op, a, b) \
|
||||
RTC_EAT_STREAM_PARAMETERS(((void)::rtc::Safe##op(a, b)))
|
||||
RTC_EAT_STREAM_PARAMETERS(((void)::webrtc::Safe##op(a, b)))
|
||||
|
||||
// RTC_CHECK dies with a fatal error if condition is not true. It is *not*
|
||||
// controlled by NDEBUG or anything else, so the check will be executed
|
||||
@ -404,32 +409,32 @@ RTC_NORETURN RTC_EXPORT void UnreachableCodeReached();
|
||||
#if RTC_CHECK_MSG_ENABLED
|
||||
#define RTC_CHECK(condition) \
|
||||
(condition) ? static_cast<void>(0) \
|
||||
: ::rtc::webrtc_checks_impl::FatalLogCall<false>( \
|
||||
: ::webrtc::webrtc_checks_impl::FatalLogCall<false>( \
|
||||
__FILE__, __LINE__, #condition) & \
|
||||
::rtc::webrtc_checks_impl::LogStreamer<>()
|
||||
::webrtc::webrtc_checks_impl::LogStreamer<>()
|
||||
|
||||
#define RTC_CHECK_OP(name, op, val1, val2) \
|
||||
::rtc::Safe##name((val1), (val2)) \
|
||||
::webrtc::Safe##name((val1), (val2)) \
|
||||
? static_cast<void>(0) \
|
||||
: ::rtc::webrtc_checks_impl::FatalLogCall<true>( \
|
||||
: ::webrtc::webrtc_checks_impl::FatalLogCall<true>( \
|
||||
__FILE__, __LINE__, #val1 " " #op " " #val2) & \
|
||||
::rtc::webrtc_checks_impl::LogStreamer<>() << (val1) << (val2)
|
||||
::webrtc::webrtc_checks_impl::LogStreamer<>() << (val1) << (val2)
|
||||
#else
|
||||
#define RTC_CHECK(condition) \
|
||||
(condition) ? static_cast<void>(0) \
|
||||
: true ? ::rtc::webrtc_checks_impl::FatalLogCall<false>(__FILE__, __LINE__, \
|
||||
"") & \
|
||||
::rtc::webrtc_checks_impl::LogStreamer<>() \
|
||||
: ::rtc::webrtc_checks_impl::FatalLogCall<false>("", 0, "") & \
|
||||
::rtc::webrtc_checks_impl::LogStreamer<>()
|
||||
: true ? ::webrtc::webrtc_checks_impl::FatalLogCall<false>(__FILE__, \
|
||||
__LINE__, "") & \
|
||||
::webrtc::webrtc_checks_impl::LogStreamer<>() \
|
||||
: ::webrtc::webrtc_checks_impl::FatalLogCall<false>("", 0, "") & \
|
||||
::webrtc::webrtc_checks_impl::LogStreamer<>()
|
||||
|
||||
#define RTC_CHECK_OP(name, op, val1, val2) \
|
||||
::rtc::Safe##name((val1), (val2)) ? static_cast<void>(0) \
|
||||
: true ? ::rtc::webrtc_checks_impl::FatalLogCall<true>(__FILE__, __LINE__, \
|
||||
"") & \
|
||||
::rtc::webrtc_checks_impl::LogStreamer<>() \
|
||||
: ::rtc::webrtc_checks_impl::FatalLogCall<false>("", 0, "") & \
|
||||
::rtc::webrtc_checks_impl::LogStreamer<>()
|
||||
::webrtc::Safe##name((val1), (val2)) ? static_cast<void>(0) \
|
||||
: true ? ::webrtc::webrtc_checks_impl::FatalLogCall<true>(__FILE__, \
|
||||
__LINE__, "") & \
|
||||
::webrtc::webrtc_checks_impl::LogStreamer<>() \
|
||||
: ::webrtc::webrtc_checks_impl::FatalLogCall<false>("", 0, "") & \
|
||||
::webrtc::webrtc_checks_impl::LogStreamer<>()
|
||||
#endif
|
||||
|
||||
#define RTC_CHECK_EQ(val1, val2) RTC_CHECK_OP(Eq, ==, val1, val2)
|
||||
@ -467,14 +472,14 @@ RTC_NORETURN RTC_EXPORT void UnreachableCodeReached();
|
||||
// assert that a point in the code is never reached.
|
||||
#define RTC_CHECK_NOTREACHED() \
|
||||
do { \
|
||||
::rtc::webrtc_checks_impl::UnreachableCodeReached( \
|
||||
::webrtc::webrtc_checks_impl::UnreachableCodeReached( \
|
||||
RTC_UNREACHABLE_FILE_AND_LINE_CALL_ARGS); \
|
||||
} while (0)
|
||||
|
||||
#define RTC_FATAL() \
|
||||
::rtc::webrtc_checks_impl::FatalLogCall<false>(__FILE__, __LINE__, \
|
||||
::webrtc::webrtc_checks_impl::FatalLogCall<false>(__FILE__, __LINE__, \
|
||||
"FATAL()") & \
|
||||
::rtc::webrtc_checks_impl::LogStreamer<>()
|
||||
::webrtc::webrtc_checks_impl::LogStreamer<>()
|
||||
|
||||
// Performs the integer division a/b and returns the result. CHECKs that the
|
||||
// remainder is zero.
|
||||
@ -484,6 +489,12 @@ inline T CheckedDivExact(T a, T b) {
|
||||
return a / b;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
// Re-export symbols from the webrtc namespace for backwards compatibility.
|
||||
// TODO(bugs.webrtc.org/4222596): Remove once all references are updated.
|
||||
namespace rtc {
|
||||
using ::webrtc::CheckedDivExact;
|
||||
} // namespace rtc
|
||||
|
||||
#else // __cplusplus not defined
|
||||
|
||||
@ -10,12 +10,12 @@
|
||||
|
||||
// This file defines six constexpr functions:
|
||||
//
|
||||
// rtc::SafeEq // ==
|
||||
// rtc::SafeNe // !=
|
||||
// rtc::SafeLt // <
|
||||
// rtc::SafeLe // <=
|
||||
// rtc::SafeGt // >
|
||||
// rtc::SafeGe // >=
|
||||
// webrtc::SafeEq // ==
|
||||
// webrtc::SafeNe // !=
|
||||
// webrtc::SafeLt // <
|
||||
// webrtc::SafeLe // <=
|
||||
// webrtc::SafeGt // >
|
||||
// webrtc::SafeGe // >=
|
||||
//
|
||||
// They each accept two arguments of arbitrary types, and in almost all cases,
|
||||
// they simply call the appropriate comparison operator. However, if both
|
||||
@ -38,7 +38,7 @@
|
||||
|
||||
#include "rtc_base/type_traits.h"
|
||||
|
||||
namespace rtc {
|
||||
namespace webrtc {
|
||||
|
||||
namespace safe_cmp_impl {
|
||||
|
||||
@ -170,6 +170,17 @@ RTC_SAFECMP_MAKE_FUN(Gt)
|
||||
RTC_SAFECMP_MAKE_FUN(Ge)
|
||||
#undef RTC_SAFECMP_MAKE_FUN
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
// Re-export symbols from the webrtc namespace for backwards compatibility.
|
||||
// TODO(bugs.webrtc.org/4222596): Remove once all references are updated.
|
||||
namespace rtc {
|
||||
using ::webrtc::SafeEq;
|
||||
using ::webrtc::SafeGe;
|
||||
using ::webrtc::SafeGt;
|
||||
using ::webrtc::SafeLe;
|
||||
using ::webrtc::SafeLt;
|
||||
using ::webrtc::SafeNe;
|
||||
} // namespace rtc
|
||||
|
||||
#endif // RTC_BASE_NUMERICS_SAFE_COMPARE_H_
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
namespace rtc {
|
||||
namespace webrtc {
|
||||
|
||||
// Determines if the given class has zero-argument .data() and .size() methods
|
||||
// whose return values are convertible to T* and size_t, respectively.
|
||||
@ -136,6 +136,15 @@ static_assert(!IsIntlike<S>::value, "");
|
||||
|
||||
} // namespace test_enum_intlike
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
// Re-export symbols from the webrtc namespace for backwards compatibility.
|
||||
// TODO(bugs.webrtc.org/4222596): Remove once all references are updated.
|
||||
namespace rtc {
|
||||
template <typename DS, typename T>
|
||||
using HasDataAndSize = ::webrtc::HasDataAndSize<DS, T>;
|
||||
template <typename T>
|
||||
using IsIntlike = ::webrtc::IsIntlike<T>;
|
||||
} // namespace rtc
|
||||
|
||||
#endif // RTC_BASE_TYPE_TRAITS_H_
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user