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