assert.h 596 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include "types.h"
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. void crash(void);
  7. void _debugger_breakpoint(void);
  8. #ifdef __cplusplus
  9. }
  10. #endif
  11. #ifndef NDEBUG
  12. #define breakpoint() _debugger_breakpoint()
  13. #else
  14. #define breakpoint() _crash()
  15. #endif
  16. #ifndef NDEBUG
  17. #define assert(_statement) \
  18. if (!(_statement)) { \
  19. breakpoint(); \
  20. crash(); \
  21. }
  22. #define assert_likely(_statement) \
  23. if (unlikely(!(_statement))) { \
  24. breakpoint(); \
  25. crash(); \
  26. }
  27. #else
  28. #define assert(_statement) ;
  29. #endif