Decoupling Architectural-specific Code (#35)
[lunaix-os.git] / lunaix-os / includes / lunaix / spike.h
index f73fbe1d2bb7e061c5492af6e4b367e20a12c186..cf40bab54d4c0079c06b7a8434ad2cdda496a626 100644 (file)
 #ifndef __LUNAIXOS_NASSERT__
 #define assert(cond)                                                           \
     do {                                                                       \
 #ifndef __LUNAIXOS_NASSERT__
 #define assert(cond)                                                           \
     do {                                                                       \
-        if (!(cond)) {                                                         \
+        if (unlikely(!(cond))) {                                                         \
             __assert_fail(#cond, __FILE__, __LINE__);                          \
         }                                                                      \
     } while(0)
 
 #define assert_msg(cond, msg)                                                  \
     do {                                                                       \
             __assert_fail(#cond, __FILE__, __LINE__);                          \
         }                                                                      \
     } while(0)
 
 #define assert_msg(cond, msg)                                                  \
     do {                                                                       \
-        if (!(cond)) {                                                         \
+        if (unlikely(!(cond))) {                                                         \
             __assert_fail(msg, __FILE__, __LINE__);                            \
         }                                                                      \
     } while(0)
             __assert_fail(msg, __FILE__, __LINE__);                            \
         }                                                                      \
     } while(0)
@@ -84,7 +84,7 @@
 #define must_success(statement)                                                \
     do {                                                                       \
         int err = (statement);                                                 \
 #define must_success(statement)                                                \
     do {                                                                       \
         int err = (statement);                                                 \
-        if (err) panickf(#statement "failed with errcode=%d", err);           \
+        if (err) fail(#statement " failed");                                   \
     } while(0)
 
 #define fail(msg) __assert_fail(msg, __FILE__, __LINE__);
     } while(0)
 
 #define fail(msg) __assert_fail(msg, __FILE__, __LINE__);
@@ -101,9 +101,6 @@ __assert_fail(const char* expr, const char* file, unsigned int line)
 void noret
 panick(const char* msg);
 
 void noret
 panick(const char* msg);
 
-void noret
-panickf(const char* fmt, ...);
-
 #define wait_until(cond)                                                       \
     while (!(cond))                                                            \
         ;
 #define wait_until(cond)                                                       \
     while (!(cond))                                                            \
         ;