|
Last change
on this file since cd1e3fc0 was d7f7a4a, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 3 years ago |
|
Replace some license headers with SPDX identifier
Headers are replaced using tools/transorm-copyright.sh only
when it can be matched verbatim with the license header used
throughout most of the codebase.
|
-
Property mode
set to
100644
|
|
File size:
1.4 KB
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | * SPDX-FileCopyrightText: 2005 Martin Decky
|
|---|
| 3 | * SPDX-FileCopyrightText: 2006 Josef Cejka
|
|---|
| 4 | *
|
|---|
| 5 | * SPDX-License-Identifier: BSD-3-Clause
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | /** @addtogroup libc
|
|---|
| 9 | * @{
|
|---|
| 10 | */
|
|---|
| 11 | /** @file
|
|---|
| 12 | */
|
|---|
| 13 |
|
|---|
| 14 | // XXX: The definition of `assert()` is not guarded.
|
|---|
| 15 | // One must not use `#pragma once` in this header.
|
|---|
| 16 | // This is in accordance with the C standard.
|
|---|
| 17 |
|
|---|
| 18 | #ifndef _LIBC_ASSERT_H_
|
|---|
| 19 | #define _LIBC_ASSERT_H_
|
|---|
| 20 |
|
|---|
| 21 | #include <_bits/decls.h>
|
|---|
| 22 |
|
|---|
| 23 | #ifndef __cplusplus
|
|---|
| 24 | #define static_assert _Static_assert
|
|---|
| 25 | #endif
|
|---|
| 26 |
|
|---|
| 27 | __C_DECLS_BEGIN;
|
|---|
| 28 |
|
|---|
| 29 | extern void __helenos_assert_abort(const char *, const char *, unsigned int)
|
|---|
| 30 | __attribute__((noreturn));
|
|---|
| 31 |
|
|---|
| 32 | extern void __helenos_assert_quick_abort(const char *, const char *, unsigned int)
|
|---|
| 33 | __attribute__((noreturn));
|
|---|
| 34 |
|
|---|
| 35 | __C_DECLS_END;
|
|---|
| 36 |
|
|---|
| 37 | #endif
|
|---|
| 38 |
|
|---|
| 39 | /** Debugging assert macro
|
|---|
| 40 | *
|
|---|
| 41 | * If NDEBUG is not set, the assert() macro
|
|---|
| 42 | * evaluates expr and if it is false prints
|
|---|
| 43 | * error message and terminate program.
|
|---|
| 44 | *
|
|---|
| 45 | * @param expr Expression which is expected to be true.
|
|---|
| 46 | *
|
|---|
| 47 | */
|
|---|
| 48 |
|
|---|
| 49 | #undef assert
|
|---|
| 50 |
|
|---|
| 51 | #ifndef NDEBUG
|
|---|
| 52 | #define assert(expr) ((expr) ? (void) 0 : __helenos_assert_abort(#expr, __FILE__, __LINE__))
|
|---|
| 53 | #else
|
|---|
| 54 | #define assert(expr) ((void) 0)
|
|---|
| 55 | #endif
|
|---|
| 56 |
|
|---|
| 57 | #ifdef _HELENOS_SOURCE
|
|---|
| 58 |
|
|---|
| 59 | #undef safe_assert
|
|---|
| 60 |
|
|---|
| 61 | #ifndef NDEBUG
|
|---|
| 62 | #define safe_assert(expr) ((expr) ? (void) 0 : __helenos_assert_quick_abort(#expr, __FILE__, __LINE__))
|
|---|
| 63 | #else
|
|---|
| 64 | #define safe_assert(expr) ((void) 0)
|
|---|
| 65 | #endif
|
|---|
| 66 |
|
|---|
| 67 | #endif /* _HELENOS_SOURCE */
|
|---|
| 68 |
|
|---|
| 69 | /** @}
|
|---|
| 70 | */
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.