source: mainline/uspace/lib/c/include/assert.h@ cd1e3fc0

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
RevLine 
[4f34b6a]1/*
[d7f7a4a]2 * SPDX-FileCopyrightText: 2005 Martin Decky
3 * SPDX-FileCopyrightText: 2006 Josef Cejka
[4f34b6a]4 *
[d7f7a4a]5 * SPDX-License-Identifier: BSD-3-Clause
[4f34b6a]6 */
7
[fadd381]8/** @addtogroup libc
[b2951e2]9 * @{
10 */
11/** @file
12 */
13
[e8d3c6f5]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
[4805495]18#ifndef _LIBC_ASSERT_H_
19#define _LIBC_ASSERT_H_
[4f34b6a]20
[bc56f30]21#include <_bits/decls.h>
22
[7ea7605d]23#ifndef __cplusplus
[0a520db]24#define static_assert _Static_assert
[7ea7605d]25#endif
[1cf26ab]26
[bc56f30]27__C_DECLS_BEGIN;
28
[e8d3c6f5]29extern void __helenos_assert_abort(const char *, const char *, unsigned int)
30 __attribute__((noreturn));
31
32extern void __helenos_assert_quick_abort(const char *, const char *, unsigned int)
33 __attribute__((noreturn));
34
[bc56f30]35__C_DECLS_END;
36
[e8d3c6f5]37#endif
38
[4f34b6a]39/** Debugging assert macro
40 *
41 * If NDEBUG is not set, the assert() macro
[c7bbf029]42 * evaluates expr and if it is false prints
[4f34b6a]43 * error message and terminate program.
44 *
45 * @param expr Expression which is expected to be true.
46 *
47 */
48
[e8d3c6f5]49#undef assert
[202f57b]50
[e8d3c6f5]51#ifndef NDEBUG
[18b6a88]52#define assert(expr) ((expr) ? (void) 0 : __helenos_assert_abort(#expr, __FILE__, __LINE__))
[e8d3c6f5]53#else
[18b6a88]54#define assert(expr) ((void) 0)
[e8d3c6f5]55#endif
[202f57b]56
[e8d3c6f5]57#ifdef _HELENOS_SOURCE
[202f57b]58
[e8d3c6f5]59#undef safe_assert
[955f2a5]60
[e8d3c6f5]61#ifndef NDEBUG
[18b6a88]62#define safe_assert(expr) ((expr) ? (void) 0 : __helenos_assert_quick_abort(#expr, __FILE__, __LINE__))
[e8d3c6f5]63#else
[18b6a88]64#define safe_assert(expr) ((void) 0)
[4f34b6a]65#endif
[b2951e2]66
[e8d3c6f5]67#endif /* _HELENOS_SOURCE */
68
[fadd381]69/** @}
[b2951e2]70 */
Note: See TracBrowser for help on using the repository browser.