Motr  M0
assert.h File Reference
#include <stddef.h>
#include <stdarg.h>
Include dependency graph for assert.h:

Go to the source code of this file.

Data Structures

struct  m0_panic_ctx
 

Macros

#define __MOTR_LIB_ASSERT_H__
 
#define M0_ASSERT_OFF   (0)
 
#define M0_ASSERT_EX_ON   (0)
 
#define likely(x)   __builtin_expect(!!(x), 1)
 
#define unlikely(x)   __builtin_expect(!!(x), 0)
 
#define M0_ASSERT__INIT(msg, fmt, ...)
 
#define M0_ASSERT_INFO(cond, fmt, ...)
 
#define M0_IMPOSSIBLE(fmt, ...)
 
#define M0_ASSERT(cond)   M0_ASSERT_INFO((cond), NULL)
 
#define M0_ASSERT_EX(cond)
 
#define M0_ASSERT_INFO_EX(cond, fmt, ...)
 
#define M0_PRE(cond)   M0_ASSERT(cond)
 
#define M0_PRE_EX(cond)   M0_ASSERT_EX(cond)
 
#define M0_POST(cond)   M0_ASSERT(cond)
 
#define M0_POST_EX(cond)   M0_ASSERT_EX(cond)
 
#define M0_INVARIANT_EX(cond)   M0_ASSERT_EX(cond)
 
#define M0_CHECK_EX(cond)   (!M0_ASSERT_EX_ON || (cond))
 
#define M0_CASSERT(cond)   do { switch (1) {case 0: case !!(cond): ;} } while (0)
 
#define M0_BASSERT(cond)   extern char __static_assertion[(cond) ? 1 : -1]
 
#define _0C(exp)
 

Functions

void m0_panic (const struct m0_panic_ctx *ctx,...)
 
M0_INTERNAL void m0_panic_only (const struct m0_panic_ctx *ctx,...)
 
M0_INTERNAL void m0_arch_panic (const struct m0_panic_ctx *ctx, va_list ap) __attribute__((noreturn))
 
void m0_backtrace (void)
 
M0_INTERNAL void m0_arch_backtrace (void)
 
 __attribute__ ((format(printf, 1, 2))) static inline void printf_check(const char *fmt
 
M0_INTERNAL void m0__assertion_hook (void)
 
M0_INTERNAL void m0_debugger_invoke (void)
 

Macro Definition Documentation

◆ __MOTR_LIB_ASSERT_H__

#define __MOTR_LIB_ASSERT_H__

Definition at line 26 of file assert.h.

◆ M0_ASSERT

#define M0_ASSERT (   cond)    M0_ASSERT_INFO((cond), NULL)

◆ M0_ASSERT__INIT

#define M0_ASSERT__INIT (   msg,
  fmt,
  ... 
)
Value:
static const struct m0_panic_ctx __pctx = { \
msg, __func__, __FILE__, __LINE__, fmt \
}; \
printf_check(fmt, ##__VA_ARGS__); \
m0_assert_intercept()
char * fmt(const char *format,...) __attribute__((format(printf

◆ M0_ASSERT_EX

#define M0_ASSERT_EX (   cond)
Value:
({ \
M0_ASSERT(cond); \
})
#define M0_ASSERT_EX_ON
Definition: assert.h:62

◆ M0_ASSERT_INFO

#define M0_ASSERT_INFO (   cond,
  fmt,
  ... 
)
Value:
({ \
M0_ASSERT__INIT(#cond, fmt, ##__VA_ARGS__); \
(M0_ASSERT_OFF || likely(cond) ? \
(void)0 : m0_panic(&__pctx, ##__VA_ARGS__)); \
})
void m0_panic(const struct m0_panic_ctx *ctx,...)
Definition: assert.c:40
#define M0_ASSERT_OFF
Definition: assert.h:56
char * fmt(const char *format,...) __attribute__((format(printf
#define likely(x)
Definition: assert.h:70

◆ M0_ASSERT_INFO_EX

#define M0_ASSERT_INFO_EX (   cond,
  fmt,
  ... 
)
Value:
({ \
M0_ASSERT_INFO((cond), (fmt), ##__VA_ARGS__); \
})
char * fmt(const char *format,...) __attribute__((format(printf
#define M0_ASSERT_EX_ON
Definition: assert.h:62

◆ M0_BASSERT

#define M0_BASSERT (   cond)    extern char __static_assertion[(cond) ? 1 : -1]

◆ M0_CASSERT

#define M0_CASSERT (   cond)    do { switch (1) {case 0: case !!(cond): ;} } while (0)

◆ M0_CHECK_EX

#define M0_CHECK_EX (   cond)    (!M0_ASSERT_EX_ON || (cond))

◆ M0_IMPOSSIBLE

#define M0_IMPOSSIBLE (   fmt,
  ... 
)
Value:
({ \
M0_ASSERT__INIT("Impossible", "Impossible happened! " fmt, \
##__VA_ARGS__); \
m0_panic(&__pctx, ##__VA_ARGS__); \
})
char * fmt(const char *format,...) __attribute__((format(printf

◆ M0_INVARIANT_EX

#define M0_INVARIANT_EX (   cond)    M0_ASSERT_EX(cond)

◆ M0_POST

#define M0_POST (   cond)    M0_ASSERT(cond)

◆ M0_POST_EX

#define M0_POST_EX (   cond)    M0_ASSERT_EX(cond)

◆ M0_PRE

#define M0_PRE (   cond)    M0_ASSERT(cond)

◆ M0_PRE_EX

#define M0_PRE_EX (   cond)    M0_ASSERT_EX(cond)