printk.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef __KERNEL_PRINTK__
  2. #define __KERNEL_PRINTK__
  3. #include <stdio.h>
  4. #include <linux/compiler.h>
  5. #define KERN_EMERG
  6. #define KERN_ALERT
  7. #define KERN_CRIT
  8. #define KERN_ERR
  9. #define KERN_WARNING
  10. #define KERN_NOTICE
  11. #define KERN_INFO
  12. #define KERN_DEBUG
  13. #define KERN_CONT
  14. #define printk(fmt, ...) \
  15. printf(fmt, ##__VA_ARGS__)
  16. /*
  17. * Dummy printk for disabled debugging statements to use whilst maintaining
  18. * gcc's format checking.
  19. */
  20. #define no_printk(fmt, ...) \
  21. ({ \
  22. if (0) \
  23. printk(fmt, ##__VA_ARGS__); \
  24. 0; \
  25. })
  26. #define __printk(level, fmt, ...) \
  27. ({ \
  28. level < CONFIG_LOGLEVEL ? printk(fmt, ##__VA_ARGS__) : 0; \
  29. })
  30. #ifndef pr_fmt
  31. #define pr_fmt(fmt) fmt
  32. #endif
  33. #define pr_emerg(fmt, ...) \
  34. __printk(0, pr_fmt(fmt), ##__VA_ARGS__)
  35. #define pr_alert(fmt, ...) \
  36. __printk(1, pr_fmt(fmt), ##__VA_ARGS__)
  37. #define pr_crit(fmt, ...) \
  38. __printk(2, pr_fmt(fmt), ##__VA_ARGS__)
  39. #define pr_err(fmt, ...) \
  40. __printk(3, pr_fmt(fmt), ##__VA_ARGS__)
  41. #define pr_warning(fmt, ...) \
  42. __printk(4, pr_fmt(fmt), ##__VA_ARGS__)
  43. #define pr_warn pr_warning
  44. #define pr_notice(fmt, ...) \
  45. __printk(5, pr_fmt(fmt), ##__VA_ARGS__)
  46. #define pr_info(fmt, ...) \
  47. __printk(6, pr_fmt(fmt), ##__VA_ARGS__)
  48. #define pr_cont(fmt, ...) \
  49. printk(fmt, ##__VA_ARGS__)
  50. /* pr_devel() should produce zero code unless DEBUG is defined */
  51. #ifdef DEBUG
  52. #define pr_devel(fmt, ...) \
  53. __printk(7, pr_fmt(fmt), ##__VA_ARGS__)
  54. #else
  55. #define pr_devel(fmt, ...) \
  56. no_printk(pr_fmt(fmt), ##__VA_ARGS__)
  57. #endif
  58. #ifdef DEBUG
  59. #define pr_debug(fmt, ...) \
  60. __printk(7, pr_fmt(fmt), ##__VA_ARGS__)
  61. #else
  62. #define pr_debug(fmt, ...) \
  63. no_printk(pr_fmt(fmt), ##__VA_ARGS__)
  64. #endif
  65. #define printk_once(fmt, ...) \
  66. printk(fmt, ##__VA_ARGS__)
  67. #endif