diff options
-rwxr-xr-x | build-aux/stack.c.gen | 9 | ||||
-rw-r--r-- | lib9p/srv.c | 4 | ||||
-rw-r--r-- | libcr/coroutine.c | 4 | ||||
-rw-r--r-- | libcr/include/libcr/coroutine.h | 6 | ||||
-rw-r--r-- | libmisc/assert.c | 20 |
5 files changed, 28 insertions, 15 deletions
diff --git a/build-aux/stack.c.gen b/build-aux/stack.c.gen index 97775a6..57191e3 100755 --- a/build-aux/stack.c.gen +++ b/build-aux/stack.c.gen @@ -224,8 +224,13 @@ def main(ci_fnames: list[str]) -> None: missing.add(funcname) return 0 if funcname in chain: - cycles.add(f"{chain[chain.index(funcname):] + [funcname]}") - return 9999999 + if "__assert_msg_fail" in chain: + if funcname == "__wrap_printf": + return 0 + pass + else: + cycles.add(f"{chain[chain.index(funcname):] + [funcname]}") + return 9999999 node = graph[funcname] if dbg: print(f"//dbg: {funcname}\t{node.nstatic}") diff --git a/lib9p/srv.c b/lib9p/srv.c index e4212e5..608d470 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -6,7 +6,7 @@ #include <alloca.h> #include <inttypes.h> /* for PRI* */ -#include <stdio.h> /* for fprintf(), stderr */ +#include <stdio.h> /* for printf() */ #include <string.h> /* for strerror() */ #include <libcr/coroutine.h> @@ -104,7 +104,7 @@ struct _lib9p_srv_req { /* base utilities *************************************************************/ #define nonrespond_errorf(fmt, ...) \ - fprintf(stderr, "error: " fmt "\n" __VA_OPT__(,) __VA_ARGS__) + printf("error: " fmt "\n" __VA_OPT__(,) __VA_ARGS__) static uint32_t rerror_overhead_for_version(enum lib9p_version version, uint8_t *scratch) { diff --git a/libcr/coroutine.c b/libcr/coroutine.c index ed1c8e0..553acc8 100644 --- a/libcr/coroutine.c +++ b/libcr/coroutine.c @@ -6,7 +6,7 @@ #include <setjmp.h> /* for setjmp(), longjmp(), jmp_buf */ #include <stdint.h> /* for uint8_t */ -#include <stdio.h> /* for printf(), fprintf(), stderr */ +#include <stdio.h> /* for printf() */ #include <stdlib.h> /* for aligned_alloc(), free() */ #include <libmisc/assert.h> @@ -356,7 +356,7 @@ static cid_t coroutine_running = 0; /* utility functions **********************************************************/ -#define errorf(...) fprintf(stderr, "error: " __VA_ARGS__) +#define errorf(...) printf("error: " __VA_ARGS__) #define infof(...) printf("info: " __VA_ARGS__) #if CONFIG_COROUTINE_DEBUG #define debugf(...) printf("dbg: " __VA_ARGS__) diff --git a/libcr/include/libcr/coroutine.h b/libcr/include/libcr/coroutine.h index 368974f..d673fb6 100644 --- a/libcr/include/libcr/coroutine.h +++ b/libcr/include/libcr/coroutine.h @@ -95,9 +95,9 @@ cid_t coroutine_add(cr_fn_t fn, void *args); /** * The main scheduler loop. * - * "Should" never return, but will print a message to stderr and - * return if there are no coroutines (there were no calls to - * coroutine_add(), or all coroutines cr_exit()). + * "Should" never return, but will print a message and return if there + * are no coroutines (there were no calls to coroutine_add(), or all + * coroutines cr_exit()). */ void coroutine_main(void); diff --git a/libmisc/assert.c b/libmisc/assert.c index 987fb4d..9b1a0bc 100644 --- a/libmisc/assert.c +++ b/libmisc/assert.c @@ -4,20 +4,28 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -#include <stdio.h> /* for fprintf(), stderr */ -#include <stdlib.h> /* for abort() */ +#include <stdbool.h> /* for bool, true, false */ +#include <stdio.h> /* for printf() */ +#include <stdlib.h> /* for abort() */ #include <libmisc/assert.h> #ifndef NDEBUG + +static bool in_fail = false; + __attribute__((__noreturn__)) void __assert_msg_fail(const char *expr, const char *file, unsigned int line, const char *func, const char *msg) { - fprintf(stderr, "error: %s:%u:%s(): assertion \"%s\" failed%s%s\n", - file, line, func, - expr, - msg ? ": " : "", msg); + if (!in_fail) { + in_fail = true; + printf("error: %s:%u:%s(): assertion \"%s\" failed%s%s\n", + file, line, func, + expr, + msg ? ": " : "", msg); + } abort(); } + #endif |