-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move to a CCCL wide assert definition
- Loading branch information
Showing
73 changed files
with
322 additions
and
365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of libcu++, the C++ Standard Library for your entire system, | ||
// under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef __CCCL_ASSERT_H | ||
#define __CCCL_ASSERT_H | ||
|
||
#include <cuda/__cccl_config> | ||
|
||
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) | ||
# pragma GCC system_header | ||
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) | ||
# pragma clang system_header | ||
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) | ||
# pragma system_header | ||
#endif // no system header | ||
|
||
#include <cuda/std/cassert> | ||
#include <cuda/std/cstdlib> | ||
|
||
#if __has_attribute(__format__) | ||
// The attribute uses 1-based indices for ordinary and static member functions. | ||
// The attribute uses 2-based indices for non-static member functions. | ||
# define _CCCL_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \ | ||
__attribute__((__format__(archetype, format_string_index, first_format_arg_index))) | ||
#else | ||
# define _CCCL_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */ | ||
#endif | ||
|
||
_CCCL_NORETURN _CCCL_ATTRIBUTE_FORMAT(__printf__, 1, 2) | ||
_LIBCUDACXX_HIDE_FROM_ABI void __cccl_verbose_abort(const char*, ...) | ||
{ | ||
NV_IF_ELSE_TARGET(NV_IS_HOST, (::abort();), (__trap();)) | ||
_LIBCUDACXX_UNREACHABLE(); | ||
} | ||
|
||
#if defined(_DEBUG) || defined(DEBUG) | ||
# ifndef _CCCL_ENABLE_DEBUG_MODE | ||
# define _CCCL_ENABLE_DEBUG_MODE | ||
# endif // !_CCCL_ENABLE_DEBUG_MODE | ||
#endif // _DEBUG || DEBUG | ||
|
||
// Compatibility with older cccl versions | ||
#if defined(_LIBCUDACXX_ENABLE_DEBUG_MODE) || defined(_LIBCUDACXX_DEBUG) || defined(_LIBCUDACXX_ENABLE_ASSERTIONS) | ||
# ifndef _CCCL_ENABLE_DEBUG_MODE | ||
# define _CCCL_ENABLE_DEBUG_MODE | ||
# endif // !_CCCL_ENABLE_DEBUG_MODE | ||
#endif // _LIBCUDACXX_ENABLE_DEBUG_MODE || _LIBCUDACXX_DEBUG || _LIBCUDACXX_ENABLE_ASSERTIONS | ||
|
||
// Automatically enable assertions when the debug mode is enabled manually. | ||
#ifdef _CCCL_ENABLE_DEBUG_MODE | ||
# ifndef _CCCL_ENABLE_ASSERTIONS | ||
# define _CCCL_ENABLE_ASSERTIONS | ||
# endif // !_CCCL_ENABLE_ASSERTIONS | ||
#endif // _CCCL_ENABLE_DEBUG_MODE | ||
|
||
// Assert that is enabled unconditionally | ||
#define _CCCL_VERIFY(expression, message) \ | ||
__builtin_expect(static_cast<bool>(expression), 1) \ | ||
? (void) 0 \ | ||
: __cccl_verbose_abort("%s:%d: assertion %s failed: %s", __FILE__, __LINE__, #expression, message) | ||
|
||
#ifdef _CCCL_ENABLE_ASSERTIONS | ||
# define _CCCL_ASSERT(expression, message) _CCCL_VERIFY(expression, message) | ||
#else // ^^^ _CCCL_ENABLE_ASSERTIONS ^^^ / vvv !_CCCL_ENABLE_ASSERTIONS vvv | ||
# define _CCCL_ASSERT(expression, message) ((void) 0) | ||
#endif // !_CCCL_ENABLE_ASSERTIONS | ||
|
||
#endif // __CCCL_ASSERT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.