+#ifdef __LUNAIXOS_DEBUG__
+#define assert(cond) \
+ if (!(cond)) { \
+ __assert_fail(#cond, __FILE__, __LINE__); \
+ }
+
+#define assert_msg(cond, msg) \
+ if (!(cond)) { \
+ __assert_fail(msg, __FILE__, __LINE__); \
+ }
+void
+__assert_fail(const char* expr, const char* file, unsigned int line)
+ __attribute__((noinline, noreturn));
+#else
+#define assert(cond) (void)(cond); // assert nothing
+#define assert_msg(cond, msg) (void)(cond); // assert nothing
+#endif
+
+void
+panick(const char* msg);
+
+#define wait_until(cond) \
+ while (!(cond)) \
+ ;
+#define loop_until(cond) \
+ while (!(cond)) \
+ ;
+
+#define wait_until_expire(cond, max) \
+ ({ \
+ unsigned int __wcounter__ = (max); \
+ while (!(cond) && __wcounter__-- > 1) \
+ ; \
+ __wcounter__; \
+ })
+