api_rt_dbg.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef _API_RT_DBG_H_
  2. #define _API_RT_DBG_H_
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif // __cplusplus
  6. #define API_RT_ASSERT_NONE 0
  7. #define API_RT_ASSERT_MIN 1
  8. #define API_RT_ASSERT_FULL 2
  9. #define API_RT_USE_ASSERT API_RT_ASSERT_MIN
  10. #if API_RT_USE_ASSERT == API_RT_ASSERT_FULL
  11. #define ASSERT_EQ(X, Y) \
  12. do \
  13. { \
  14. if (((X) != (Y))) \
  15. { \
  16. assert_fail(__FILE__, __LINE__); \
  17. while (1) \
  18. ; \
  19. } \
  20. } while (0)
  21. #define ASSERT_LESS(X, Y) \
  22. do \
  23. { \
  24. if (((X) >= (Y))) \
  25. { \
  26. assert_fail(__FILE__, __LINE__); \
  27. while (1) \
  28. ; \
  29. } \
  30. } while (0)
  31. #elif API_RT_USE_ASSERT == API_RT_ASSERT_MIN
  32. #define ASSERT_EQ(X, Y) \
  33. do \
  34. { \
  35. if (((X) != (Y))) \
  36. { \
  37. while (1) \
  38. ; \
  39. } \
  40. } while (0)
  41. #define ASSERT_LESS(X, Y) \
  42. do \
  43. { \
  44. if (((X) >= (Y))) \
  45. { \
  46. while (1) \
  47. ; \
  48. } \
  49. } while (0)
  50. #elif API_RT_USE_ASSERT == API_RT_ASSERT_NONE
  51. #define ASSERT_EQ(X, Y)
  52. #define ASSERT_LESS(X, Y)
  53. #endif
  54. typedef struct
  55. {
  56. int FailCount;
  57. char *LastFileName;
  58. int LastLineNo;
  59. } AssertFailRecord;
  60. extern AssertFailRecord AssertRecord;
  61. void assert_fail(char *fileName, int lineNo);
  62. #ifdef __cplusplus
  63. }
  64. #endif // __cplusplus
  65. #endif