summaryrefslogtreecommitdiff
path: root/libcr
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-11-11 10:22:26 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-11-11 10:22:26 -0700
commitced8ab50af1429d9ba7651da1b3b78014fd76e79 (patch)
tree4f0975a2594c4bfa97ebaa6b263e712858d2e8a4 /libcr
parentd84daf84d2ced072782ef3c61e5088b06d950939 (diff)
libmisc: Write my own assert.hHEADmain
Diffstat (limited to 'libcr')
-rw-r--r--libcr/CMakeLists.txt3
-rw-r--r--libcr/coroutine.c16
2 files changed, 6 insertions, 13 deletions
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 <assert.h>
#include <setjmp.h> /* for setjmp(), longjmp(), jmp_buf */
#include <stdint.h> /* for uint8_t */
#include <stdio.h> /* for printf(), fprintf(), stderr */
#include <stdlib.h> /* for aligned_alloc(), free() */
+#include <libmisc/assert.h>
+
#include <libcr/coroutine.h>
/* 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)