git: 235fe911df59 - stable/14 - include: add a userland version of __assert_unreachable
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 18 Mar 2025 12:59:58 UTC
The branch stable/14 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=235fe911df596333ea63152baa7ec4eecdeb7d12 commit 235fe911df596333ea63152baa7ec4eecdeb7d12 Author: Kyle Evans <kevans@FreeBSD.org> AuthorDate: 2025-01-13 00:41:25 +0000 Commit: Christos Margiolis <christos@FreeBSD.org> CommitDate: 2025-03-18 12:55:24 +0000 include: add a userland version of __assert_unreachable The kernel has had a version of this since c79cee71363d ("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 (cherry picked from commit 712f81feea416e9f8aaf040173883876a50a7d34) --- include/assert.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/assert.h b/include/assert.h index 54e1456b9e0d..b483465dfc5f 100644 --- a/include/assert.h +++ b/include/assert.h @@ -45,15 +45,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_