From bb901855558378d8256ea2abc7c0dcea57e6bd20 Mon Sep 17 00:00:00 2001 From: Evan Typanski Date: Tue, 25 Aug 2026 12:28:21 -0400 Subject: [PATCH 1/3] aarch64: drop stray semicolon in FIBER_ARCH_REGS Co-Authored-By: Claude Opus 5 --- include/fiber/fiber_mach.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fiber/fiber_mach.h b/include/fiber/fiber_mach.h index 7fd405a..7271045 100644 --- a/include/fiber/fiber_mach.h +++ b/include/fiber/fiber_mach.h @@ -90,7 +90,7 @@ void *lr; /* r30 */ \ void *fp; /* r29 */ \ void *r[10]; /* r19 - r28 */ \ - double d[8]; /* d8 - d15 */ + double d[8] /* d8 - d15 */ #elif HU_ARCH_RISCV_P && HU_OS_POSIX_P # define FIBER_TARGET_RISCV_ELF 1 From 92669a549efa881264998f786bcbacba21142c2f Mon Sep 17 00:00:00 2001 From: Evan Typanski Date: Tue, 25 Aug 2026 12:28:21 -0400 Subject: [PATCH 2/3] Fix clang warnings in fiber.c Prototypes for get_page_size/fiber_stack_alignment, unreserve _probe_stack_weak_dummy, cast via void * in push/probe_stack, and restrict is_stack_aligned to assert builds. Co-Authored-By: Claude Opus 5 --- src/fiber.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/fiber.c b/src/fiber.c index af34652..7dc6d01 100644 --- a/src/fiber.c +++ b/src/fiber.c @@ -57,18 +57,21 @@ stack_align_n(char *sp, size_t n) return (char *) ((uintptr_t) sp & ~(uintptr_t) (n - 1)); } -HU_MAYBE_UNUSED -bool +#ifndef NDEBUG +/* only used in assertions */ +static inline bool is_stack_aligned(void *sp) { return ((uintptr_t) sp & (STACK_ALIGNMENT - 1)) == 0; } +#endif static inline void push(char **sp, void *val) { *sp -= WORD_SIZE; - *(void **) *sp = val; + /* sp is kept word aligned, cast via void * to silence -Wcast-align */ + *(void **) (void *) *sp = val; } typedef struct @@ -147,7 +150,7 @@ free_pages(void *p) HU_CONST_FN static size_t -get_page_size() +get_page_size(void) { static size_t PAGE_SIZE = 0; size_t pgsz = PAGE_SIZE; @@ -285,10 +288,10 @@ fiber_switch(Fiber *from, Fiber *to) #if hu_has_attribute(weak) # define HAVE_probe_stack_weak_dummy __attribute__((weak)) void -_probe_stack_weak_dummy(volatile char *sp, size_t sz); +fiber_probe_stack_weak_dummy(volatile char *sp, size_t sz); __attribute__((weak)) void -_probe_stack_weak_dummy(volatile char *sp, size_t sz) +fiber_probe_stack_weak_dummy(volatile char *sp, size_t sz) { (void) sp; (void) sz; @@ -305,13 +308,14 @@ probe_stack(volatile char *sp0, size_t sz, size_t pgsz) #endif size_t i = 0; while (i < sz) { - *(volatile uintptr_t *) sp |= (uintptr_t) 0; + /* sp is page aligned, cast via void * to silence -Wcast-align */ + *(volatile uintptr_t *) (volatile void *) sp |= (uintptr_t) 0; i += pgsz; sp -= pgsz; } #ifdef HAVE_probe_stack_weak_dummy - _probe_stack_weak_dummy(sp0, sz); + fiber_probe_stack_weak_dummy(sp0, sz); #endif } @@ -368,7 +372,7 @@ fiber_exec_on(Fiber *active, Fiber *temp, FiberFunc f, void *args) } size_t -fiber_stack_alignment() +fiber_stack_alignment(void) { return STACK_ALIGNMENT; } From 427a64de8870455d8feef1cb8d7beb98e508ef87 Mon Sep 17 00:00:00 2001 From: Evan Typanski Date: Tue, 25 Aug 2026 12:28:21 -0400 Subject: [PATCH 3/3] Silence -Weverything warnings that do not apply Co-Authored-By: Claude Opus 5 --- CMakeLists.txt | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa4e0c9..52a037c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,7 @@ endif() set(cflags) set(priv_cflags) +set(warn_suppress) set(defines) set(ldflags) set(asm_lang "ASM") @@ -52,6 +53,23 @@ if(CMU_COMP_GNUC) endif() endif() +if(CMU_COMP_CLANG) + # applied after CMU_FLAGS_W4 (which enables -Weverything), warnings that do + # not apply to this code base: + list( + APPEND warn_suppress + # keep -Wno-* below working on clang versions that lack them + -Wno-unknown-warning-option + # we target C99, mixing declarations and code is intentional + -Wno-declaration-after-statement + # implementing fibers means doing raw pointer arithmetic on stacks + -Wno-unsafe-buffer-usage + # C++ compatibility warning triggered by hu_cxx_static_cast(), this + # translation unit is always compiled as C + -Wno-implicit-void-ptr-cast + ) +endif() + if(FIBER_ASM_CHECK_ALIGNMENT) list(APPEND defines "-DFIBER_ASM_CHECK_ALIGNMENT=1") endif() @@ -133,7 +151,8 @@ if(FIBER_LTO) endif() target_compile_options(fiber PUBLIC ${cflags}) -target_compile_options(fiber PRIVATE ${priv_cflags} ${CMU_FLAGS_W4}) +target_compile_options(fiber PRIVATE ${priv_cflags} ${CMU_FLAGS_W4} + ${warn_suppress}) if(ldflags) cmu_target_link_options(fiber PUBLIC ${ldflags})