prd_utils_internal.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (C) 2023 Alibaba Group Holding Limited
  3. */
  4. #ifndef PRD_UTILS_INTERNAL_H
  5. #define PRD_UTILS_INTERNAL_H
  6. #include <errno.h>
  7. #define MKTAG_NEGA(e) (-(e))
  8. #define LOG_COLOR_RED_YELLO_BACK "\033[1;31;43m"
  9. #define LOG_COLOR_RED "\033[2;31;49m"
  10. #define LOG_COLOR_YELLOW "\033[2;33;49m"
  11. #define LOG_COLOR_GREEN "\033[2;32;49m"
  12. #define LOG_COLOR_BLUE "\033[2;34;49m"
  13. #define LOG_COLOR_GRAY "\033[1;30m"
  14. #define LOG_COLOR_WHITE "\033[1;47;49m"
  15. #define LOG_COLOR_RESET "\033[0m"
  16. #define PRD_UTILS_LOG(fmt, args...) \
  17. do {printf("[%s():%d] ",__FUNCTION__, __LINE__); printf(fmt,##args);} while(0)
  18. #define PRD_UTILS_ASSERT(expr) \
  19. do { \
  20. if (!(expr)) { \
  21. printf(LOG_COLOR_RED \
  22. "\nASSERT failed at:\n"\
  23. " >File name: %s\n" \
  24. " >Function : %s\n" \
  25. " >Line No. : %d\n" \
  26. " >Condition: %s\n" \
  27. LOG_COLOR_RESET, \
  28. __FILE__,__FUNCTION__, __LINE__, #expr);\
  29. exit(-1); \
  30. } \
  31. } while(0)
  32. #endif /* PRD_UTILS_INTERNAL_H */