mirror of
https://git.freebsd.org/src.git
synced 2026-01-11 19:57:22 +00:00
include: add a userland version of __assert_unreachable
The kernel has had a version of this since
c79cee7136 ("kernel: provide panicky version of __unreachable"), and
userland can benefit from the same. __unreachable is largely
inadequate because it's *not* an assertion of any sort, so we're not
really alerted to a problem that we could've anticipated.
Reviewed by: emaste, imp, jhb, olce
Differential Revision: https://reviews.freebsd.org/D48077
This commit is contained in:
parent
df48361e77
commit
712f81feea
1 changed files with 7 additions and 0 deletions
|
|
@ -43,15 +43,22 @@
|
|||
|
||||
#undef assert
|
||||
#undef _assert
|
||||
#undef __assert_unreachable
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define assert(e) ((void)0)
|
||||
#define _assert(e) ((void)0)
|
||||
#if __BSD_VISIBLE
|
||||
#define __assert_unreachable() __unreachable()
|
||||
#endif /* __BSD_VISIBLE */
|
||||
#else
|
||||
#define _assert(e) assert(e)
|
||||
|
||||
#define assert(e) ((e) ? (void)0 : __assert(__func__, __FILE__, \
|
||||
__LINE__, #e))
|
||||
#if __BSD_VISIBLE
|
||||
#define __assert_unreachable() assert(0 && "unreachable segment reached")
|
||||
#endif /* __BSD_VISIBLE */
|
||||
#endif /* NDEBUG */
|
||||
|
||||
#ifndef _ASSERT_H_
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue