X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/003db17f7a36a8098827f40df8fedc087b5a26f6..3b6a05fc894d0c1a3d431045ee5a53955ba093a0:/lunaix-os/includes/lunaix/spike.h?ds=sidebyside diff --git a/lunaix-os/includes/lunaix/spike.h b/lunaix-os/includes/lunaix/spike.h index 4e17993..298593d 100644 --- a/lunaix-os/includes/lunaix/spike.h +++ b/lunaix-os/includes/lunaix/spike.h @@ -3,18 +3,18 @@ // Some helper functions. As helpful as Spike the Dragon! :) -// 除法向上取整 +// 除法 v/(2^k) 向上取整 #define CEIL(v, k) (((v) + (1 << (k)) - 1) >> (k)) #define ICEIL(x, y) ((x) / (y) + ((x) % (y) != 0)) -// 除法向下取整 +// 除法 v/(2^k) 向下取整 #define FLOOR(v, k) ((v) >> (k)) // 获取v最近的最大k倍数 #define ROUNDUP(v, k) (((v) + (k)-1) & ~((k)-1)) -// 获取v最近的最小k倍数 +// 获取v最近的最小k倍数 (k=2^m) #define ROUNDDOWN(v, k) ((v) & ~((k)-1)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) @@ -71,7 +71,7 @@ spin() ; } -#ifdef __LUNAIXOS_DEBUG__ +#ifndef __LUNAIXOS_NASSERT__ #define assert(cond) \ if (!(cond)) { \ __assert_fail(#cond, __FILE__, __LINE__); \ @@ -87,11 +87,15 @@ __assert_fail(const char* expr, const char* file, unsigned int line) #else #define assert(cond) (void)(cond); // assert nothing #define assert_msg(cond, msg) (void)(cond); // assert nothing -#endif + +#endif // __LUNAIXOS_NASSERT__ void panick(const char* msg); +void +panickf(const char* fmt, ...); + #define wait_until(cond) \ while (!(cond)) \ ;