From ced8ab50af1429d9ba7651da1b3b78014fd76e79 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Mon, 11 Nov 2024 10:22:26 -0700 Subject: libmisc: Write my own assert.h --- libcr/CMakeLists.txt | 3 +++ libcr/coroutine.c | 16 +++------------- 2 files changed, 6 insertions(+), 13 deletions(-) (limited to 'libcr') diff --git a/libcr/CMakeLists.txt b/libcr/CMakeLists.txt index ae7c8fe..fbc7618 100644 --- a/libcr/CMakeLists.txt +++ b/libcr/CMakeLists.txt @@ -8,6 +8,9 @@ target_include_directories(libcr SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/incl target_sources(libcr INTERFACE coroutine.c ) +target_link_libraries(libcr INTERFACE + libmisc +) target_compile_options(libcr INTERFACE -fno-split-stack ) diff --git a/libcr/coroutine.c b/libcr/coroutine.c index 41d987e..ed1c8e0 100644 --- a/libcr/coroutine.c +++ b/libcr/coroutine.c @@ -4,12 +4,13 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -#include #include /* for setjmp(), longjmp(), jmp_buf */ #include /* for uint8_t */ #include /* for printf(), fprintf(), stderr */ #include /* for aligned_alloc(), free() */ +#include + #include /* Configuration **************************************************************/ @@ -363,17 +364,6 @@ static cid_t coroutine_running = 0; #define debugf(...) #endif -#ifdef __GLIBC__ - #define assertf(expr, ...) ({ \ - if (!(expr)) { \ - errorf("assertion: " __VA_ARGS__); \ - __assert_fail(#expr, __FILE__, __LINE__, __func__); \ - } \ - }) -#else - #define assertf(expr, ...) assert(expr) -#endif - static inline const char* coroutine_state_str(enum coroutine_state state) { assert(state < ARRAY_LEN(coroutine_state_strs)); return coroutine_state_strs[state]; @@ -470,7 +460,7 @@ cid_t coroutine_add_with_stack_size(size_t stack_size, cr_fn_t fn, void *args) { debugf("...stack_base=%p\n", stack_base); /* run until cr_begin() */ cr_plat_call_with_stack(stack_base, fn, args); - __builtin_unreachable(); /* should cr_begin() instead of returning */ + assert_notreached("should cr_begin() instead of returning"); } assert_cid_state(child, state == CR_RUNNABLE); if (parent) -- cgit v1.2.3-2-g168b