feat: twifs - pseudo file system for lunaix kernel state exposure
[lunaix-os.git] / lunaix-os / includes / lunaix / spike.h
index cbdadfb80d8bd45c3d4d5ed284d05b1fa49a29a6..8297f0e9af5ffc9a9308f1985093b6fea80d8825 100644 (file)
@@ -6,6 +6,8 @@
 // 除法向上取整
 #define CEIL(v, k) (((v) + (1 << (k)) - 1) >> (k))
 
+#define ICEIL(x, y) ((x) / (y) + ((x) % (y) != 0))
+
 // 除法向下取整
 #define FLOOR(v, k) ((v) >> (k))
 
@@ -15,6 +17,9 @@
 // 获取v最近的最小k倍数
 #define ROUNDDOWN(v, k) ((v) & ~((k)-1))
 
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+
 #define __USER__ __attribute__((section(".usrtext")))
 
 inline static void
@@ -55,7 +60,7 @@ panick(const char* msg);
 #define wait_until_expire(cond, max)                                           \
     ({                                                                         \
         unsigned int __wcounter__ = (max);                                     \
-        while (!(cond) && __wcounter__-- > 0)                                  \
+        while (!(cond) && __wcounter__-- > 1)                                  \
             ;                                                                  \
         __wcounter__;                                                          \
     })