From 81ecfb6240fdd3a8229f0740242612212e062a6c Mon Sep 17 00:00:00 2001 From: Minep Date: Wed, 23 Aug 2023 17:56:09 +0100 Subject: [PATCH] hotfix: a better hinting on non-returning spin function fix: make sometimes can't find 'python' if it's alias does not exported to makefile's shell --- lunaix-os/includes/lunaix/spike.h | 14 +++++--------- lunaix-os/kernel/spike.c | 8 ++++---- lunaix-os/makeinc/toolchain.mkinc | 2 +- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/lunaix-os/includes/lunaix/spike.h b/lunaix-os/includes/lunaix/spike.h index 356e4b3..a2a0e21 100644 --- a/lunaix-os/includes/lunaix/spike.h +++ b/lunaix-os/includes/lunaix/spike.h @@ -64,17 +64,13 @@ : 0) \ : (31 - __builtin_clz(x))) -#define DO_SPIN \ - { \ - volatile int __infloop = 1; \ - while (__infloop) \ - ; \ - } - inline static void noret spin() { - DO_SPIN + volatile int __infloop = 1; + while (__infloop) + ; + __builtin_unreachable(); } #ifndef __LUNAIXOS_NASSERT__ @@ -97,7 +93,7 @@ __assert_fail(const char* expr, const char* file, unsigned int line) #define assert(cond) (void)(cond); // assert nothing #define assert_msg(cond, msg) (void)(cond); // assert nothing -#endif // __LUNAIXOS_NASSERT__ +#endif // __LUNAIXOS_NASSERT__ void noret panick(const char* msg); diff --git a/lunaix-os/kernel/spike.c b/lunaix-os/kernel/spike.c index 67f9abe..cb1bc1f 100644 --- a/lunaix-os/kernel/spike.c +++ b/lunaix-os/kernel/spike.c @@ -4,7 +4,7 @@ static char buffer[1024]; -void +void noret __assert_fail(const char* expr, const char* file, unsigned int line) { ksprintf(buffer, "%s (%s:%u)", expr, file, line); @@ -15,14 +15,14 @@ __assert_fail(const char* expr, const char* file, unsigned int line) // kernel/asm/x86/interrupts.c) cpu_trap_panic(buffer); - DO_SPIN // never reach + spin(); // never reach } void noret panick(const char* msg) { cpu_trap_panic(msg); - DO_SPIN + spin(); } void @@ -34,5 +34,5 @@ panickf(const char* fmt, ...) va_end(args); asm("int %0" ::"i"(LUNAIX_SYS_PANIC), "D"(buffer)); - DO_SPIN + spin(); } diff --git a/lunaix-os/makeinc/toolchain.mkinc b/lunaix-os/makeinc/toolchain.mkinc index 70ef37b..79ea4cb 100644 --- a/lunaix-os/makeinc/toolchain.mkinc +++ b/lunaix-os/makeinc/toolchain.mkinc @@ -1,7 +1,7 @@ CC := i686-elf-gcc AS := i686-elf-as AR := i686-elf-ar -PY := python +PY := python3 ARCH_OPT := -D__ARCH_IA32 -- 2.27.0