2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2018-10-28 09:36:21 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
2018-10-31 02:09:11 +01:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
|
|
|
|
|
|
__BEGIN_DECLS
|
2018-10-28 09:36:21 +01:00
|
|
|
|
2021-07-12 01:15:22 -06:00
|
|
|
#ifndef NDEBUG
|
2021-06-29 10:31:48 +02:00
|
|
|
__attribute__((noreturn)) void __assertion_failed(const char* msg);
|
2020-04-13 11:20:43 +02:00
|
|
|
# define __stringify_helper(x) # x
|
|
|
|
|
# define __stringify(x) __stringify_helper(x)
|
2021-07-12 21:37:31 +01:00
|
|
|
# define assert(expr) \
|
|
|
|
|
(__builtin_expect(!(expr), 0) \
|
|
|
|
|
? __assertion_failed(#expr "\n" __FILE__ ":" __stringify(__LINE__)) \
|
|
|
|
|
: void(0))
|
|
|
|
|
|
2019-04-23 21:52:02 +02:00
|
|
|
#else
|
2020-12-23 21:23:41 +01:00
|
|
|
# define assert(expr) ((void)(0))
|
2021-04-18 08:43:10 +02:00
|
|
|
# define VERIFY_NOT_REACHED() _abort()
|
2019-04-23 21:52:02 +02:00
|
|
|
#endif
|
|
|
|
|
|
2021-06-29 10:31:48 +02:00
|
|
|
__attribute__((noreturn)) void _abort();
|
2021-04-11 18:22:48 +02:00
|
|
|
|
2021-03-07 16:54:38 +02:00
|
|
|
#ifndef __cplusplus
|
|
|
|
|
# define static_assert _Static_assert
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-10-31 02:09:11 +01:00
|
|
|
__END_DECLS
|