X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/b632f535c4a6882bdca0317fb88cbe6e165f24eb..64e5fa9a495e388c922157b9a616204c299f5e05:/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 356e4b3..9e2d427 100644 --- a/lunaix-os/includes/lunaix/spike.h +++ b/lunaix-os/includes/lunaix/spike.h @@ -22,6 +22,8 @@ #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define is_pot(val) (((val) != 0) || ((val) & ((val)-1)) == 0) + /** * @brief Fast log base 2 for integer, utilizing constant unfolding. * Adopted from @@ -62,20 +64,7 @@ : ((x) & (1ul << 2)) ? 2 \ : ((x) & (1ul << 1)) ? 1 \ : 0) \ - : (31 - __builtin_clz(x))) - -#define DO_SPIN \ - { \ - volatile int __infloop = 1; \ - while (__infloop) \ - ; \ - } - -inline static void noret -spin() -{ - DO_SPIN -} + : (31 - clz(x))) #ifndef __LUNAIXOS_NASSERT__ #define assert(cond) \ @@ -92,12 +81,12 @@ spin() void __assert_fail(const char* expr, const char* file, unsigned int line) - __attribute__((noinline, noreturn)); + __attribute__((noinline, noreturn)); #else #define assert(cond) (void)(cond); // assert nothing #define assert_msg(cond, msg) (void)(cond); // assert nothing -#endif // __LUNAIXOS_NASSERT__ +#endif // __LUNAIXOS_NASSERT__ void noret panick(const char* msg);