Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:42:25

0001 // Copyright 2020 the V8 project authors. All rights reserved.
0002 // Use of this source code is governed by a BSD-style license that can be
0003 // found in the LICENSE file.
0004 
0005 #ifndef INCLUDE_CPPGC_INTERNAL_LOGGING_H_
0006 #define INCLUDE_CPPGC_INTERNAL_LOGGING_H_
0007 
0008 #include "cppgc/source-location.h"
0009 #include "v8config.h"  // NOLINT(build/include_directory)
0010 
0011 namespace cppgc {
0012 namespace internal {
0013 
0014 void V8_EXPORT DCheckImpl(const char*,
0015                           const SourceLocation& = SourceLocation::Current());
0016 [[noreturn]] void V8_EXPORT
0017 FatalImpl(const char*, const SourceLocation& = SourceLocation::Current());
0018 
0019 // Used to ignore -Wunused-variable.
0020 template <typename>
0021 struct EatParams {};
0022 
0023 #if defined(DEBUG)
0024 #define CPPGC_DCHECK_MSG(condition, message)  \
0025   do {                                        \
0026     if (V8_UNLIKELY(!(condition))) {          \
0027       ::cppgc::internal::DCheckImpl(message); \
0028     }                                         \
0029   } while (false)
0030 #else  // !defined(DEBUG)
0031 #define CPPGC_DCHECK_MSG(condition, message)                \
0032   (static_cast<void>(::cppgc::internal::EatParams<decltype( \
0033                          static_cast<void>(condition), message)>{}))
0034 #endif  // !defined(DEBUG)
0035 
0036 #define CPPGC_DCHECK(condition) CPPGC_DCHECK_MSG(condition, #condition)
0037 
0038 #define CPPGC_CHECK_MSG(condition, message)  \
0039   do {                                       \
0040     if (V8_UNLIKELY(!(condition))) {         \
0041       ::cppgc::internal::FatalImpl(message); \
0042     }                                        \
0043   } while (false)
0044 
0045 #define CPPGC_CHECK(condition) CPPGC_CHECK_MSG(condition, #condition)
0046 
0047 }  // namespace internal
0048 }  // namespace cppgc
0049 
0050 #endif  // INCLUDE_CPPGC_INTERNAL_LOGGING_H_