add lunaix dynamic linker as submodule
[lunaix-os.git] / lunaix-os / includes / lunaix / spike.h
index 2d718f5bda460e5f707d2ebdf4d4b65ab0c9236e..356e4b392bcca12b28dd5f93b2f56fc81e3c3910 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __LUNAIX_SPIKE_H
 #define __LUNAIX_SPIKE_H
 
 #ifndef __LUNAIX_SPIKE_H
 #define __LUNAIX_SPIKE_H
 
+#include <lunaix/compiler.h>
+
 /** Some helper functions. As helpful as Spike the Dragon! :) **/
 
 // 除法 v/(2^k) 向上取整
 /** Some helper functions. As helpful as Spike the Dragon! :) **/
 
 // 除法 v/(2^k) 向上取整
@@ -20,8 +22,6 @@
 #define MIN(a, b) ((a) < (b) ? (a) : (b))
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
 
 #define MIN(a, b) ((a) < (b) ? (a) : (b))
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
 
-#define likely(x) __builtin_expect((x), 1)
-
 /**
  * @brief Fast log base 2 for integer, utilizing constant unfolding.
  * Adopted from
 /**
  * @brief Fast log base 2 for integer, utilizing constant unfolding.
  * Adopted from
                                                       : 0)                      \
                              : (31 - __builtin_clz(x)))
 
                                                       : 0)                      \
                              : (31 - __builtin_clz(x)))
 
-#define __USER__ __attribute__((section(".usrtext")))
-
 #define DO_SPIN                                                                \
 #define DO_SPIN                                                                \
-    while (1)                                                                  \
-        ;
+    {                                                                          \
+        volatile int __infloop = 1;                                            \
+        while (__infloop)                                                      \
+            ;                                                                  \
+    }
 
 
-inline static void
+inline static void noret
 spin()
 {
     DO_SPIN
 spin()
 {
     DO_SPIN
@@ -98,10 +99,10 @@ __assert_fail(const char* expr, const char* file, unsigned int line)
 
 #endif                                      // __LUNAIXOS_NASSERT__
 
 
 #endif                                      // __LUNAIXOS_NASSERT__
 
-void
+void noret
 panick(const char* msg);
 
 panick(const char* msg);
 
-void
+void noret
 panickf(const char* fmt, ...);
 
 #define wait_until(cond)                                                       \
 panickf(const char* fmt, ...);
 
 #define wait_until(cond)                                                       \