Merge branch 'master' into sata-ahci-dev
[lunaix-os.git] / lunaix-os / includes / lunaix / spike.h
index 1ce7481aabfb752242dff6ab7e018c3618fba07b..6f91924dc19a174d280cb3bb7c98905f8cd91837 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,7 +17,7 @@
 // 获取v最近的最小k倍数
 #define ROUNDDOWN(v, k) ((v) & ~((k)-1))
 
-#define __USER__ __attribute__((section("usrtext")))
+#define __USER__ __attribute__((section(".usrtext")))
 
 inline static void
 spin()
@@ -52,4 +54,12 @@ panick(const char* msg);
     while (!(cond))                                                            \
         ;
 
+#define wait_until_expire(cond, max)                                           \
+    ({                                                                         \
+        unsigned int __wcounter__ = (max);                                     \
+        while (!(cond) && __wcounter__-- > 0)                                  \
+            ;                                                                  \
+        __wcounter__;                                                          \
+    })
+
 #endif /* __LUNAIX_SPIKE_H */