1 #ifndef __LUNAIX_SPIKE_H
2 #define __LUNAIX_SPIKE_H
4 // Some helper functions. As helpful as Spike the Dragon! :)
7 #define CEIL(v, k) (((v) + (1 << (k)) - 1) >> (k))
10 #define FLOOR(v, k) ((v) >> (k))
13 #define ROUNDUP(v, k) (((v) + (k)-1) & ~((k)-1))
16 #define ROUNDDOWN(v, k) ((v) & ~((k)-1))
18 #define __USER__ __attribute__((section("usrtext")))
27 #ifdef __LUNAIXOS_DEBUG__
28 #define assert(cond) \
30 __assert_fail(#cond, __FILE__, __LINE__); \
33 #define assert_msg(cond, msg) \
35 __assert_fail(msg, __FILE__, __LINE__); \
38 __assert_fail(const char* expr, const char* file, unsigned int line)
39 __attribute__((noinline, noreturn));
41 #define assert(cond) (void)(cond); // assert nothing
42 #define assert_msg(cond, msg) (void)(cond); // assert nothing
46 panick(const char* msg);
48 #define wait_until(cond) \
51 #define loop_until(cond) \
55 #endif /* __LUNAIX_SPIKE_H */