X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/01a605198da7bc5883a3dfa96b38f4f7c04f67f9..5fc669295655ec0eea7722aa4a48921dc6b700ec:/lunaix-os/includes/lunaix/spike.h diff --git a/lunaix-os/includes/lunaix/spike.h b/lunaix-os/includes/lunaix/spike.h index cbdadfb..8297f0e 100644 --- a/lunaix-os/includes/lunaix/spike.h +++ b/lunaix-os/includes/lunaix/spike.h @@ -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__; \ })