hotfix: a better hinting on non-returning spin function
authorMinep <lunaixsky@qq.com>
Wed, 23 Aug 2023 16:56:09 +0000 (17:56 +0100)
committerMinep <lunaixsky@qq.com>
Wed, 23 Aug 2023 16:56:09 +0000 (17:56 +0100)
fix: make sometimes can't find 'python' if it's alias does not exported to makefile's shell

lunaix-os/includes/lunaix/spike.h
lunaix-os/kernel/spike.c
lunaix-os/makeinc/toolchain.mkinc

index 356e4b392bcca12b28dd5f93b2f56fc81e3c3910..a2a0e21d5f66c1c56e33e2947306fb930d78ca2e 100644 (file)
                                                       : 0)                      \
                              : (31 - __builtin_clz(x)))
 
                                                       : 0)                      \
                              : (31 - __builtin_clz(x)))
 
-#define DO_SPIN                                                                \
-    {                                                                          \
-        volatile int __infloop = 1;                                            \
-        while (__infloop)                                                      \
-            ;                                                                  \
-    }
-
 inline static void noret
 spin()
 {
 inline static void noret
 spin()
 {
-    DO_SPIN
+    volatile int __infloop = 1;
+    while (__infloop)
+        ;
+    __builtin_unreachable();
 }
 
 #ifndef __LUNAIXOS_NASSERT__
 }
 
 #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
 
 #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);
 
 void noret
 panick(const char* msg);
index 67f9abe07eaa402d55df61d72169c644601ee03e..cb1bc1f2777dc485bf4f46ee680c5dc45d2e4061 100644 (file)
@@ -4,7 +4,7 @@
 
 static char buffer[1024];
 
 
 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);
 __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);
 
     //  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);
 }
 
 void noret
 panick(const char* msg)
 {
     cpu_trap_panic(msg);
-    DO_SPIN
+    spin();
 }
 
 void
 }
 
 void
@@ -34,5 +34,5 @@ panickf(const char* fmt, ...)
     va_end(args);
 
     asm("int %0" ::"i"(LUNAIX_SYS_PANIC), "D"(buffer));
     va_end(args);
 
     asm("int %0" ::"i"(LUNAIX_SYS_PANIC), "D"(buffer));
-    DO_SPIN
+    spin();
 }
 }
index 70ef37bf9c989ad716a2719e2cb722f7fa127ea8..79ea4cbea63730d268d0fa0a01e6c551b4e779f9 100644 (file)
@@ -1,7 +1,7 @@
 CC := i686-elf-gcc
 AS := i686-elf-as
 AR := i686-elf-ar
 CC := i686-elf-gcc
 AS := i686-elf-as
 AR := i686-elf-ar
-PY := python
+PY := python3
 
 
 ARCH_OPT := -D__ARCH_IA32
 
 
 ARCH_OPT := -D__ARCH_IA32