Subversion Repositories Kolibri OS

Rev

Rev 3747 | Rev 5056 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #ifndef _ASM_GENERIC_BUG_H
  2. #define _ASM_GENERIC_BUG_H
  3.  
  4. //extern __printf(3, 4)
  5. //void warn_slowpath_fmt(const char *file, const int line,
  6. //                       const char *fmt, ...);
  7. //extern __printf(4, 5)
  8. //void warn_slowpath_fmt_taint(const char *file, const int line, unsigned taint,
  9. //                             const char *fmt, ...);
  10.  
  11. //extern void warn_slowpath_null(const char *file, const int line);
  12.  
  13. #define __WARN()                printf("\nWARNING: at %s:%d\n", __FILE__, __LINE__)
  14. //#define __WARN_printf(arg...)   printf("\nWARNING: at %s:%d\n", __FILE__, __LINE__)
  15. #define __WARN_printf(arg...)   do { printf(arg); __WARN(); } while (0)
  16.  
  17. #define WARN(condition, format...) ({                                   \
  18.         int __ret_warn_on = !!(condition);                              \
  19.         if (unlikely(__ret_warn_on))                                    \
  20.             __WARN_printf(format);                                      \
  21.         unlikely(__ret_warn_on);                                        \
  22. })
  23.  
  24.  
  25. #define WARN_ON(condition) ({                                           \
  26.         int __ret_warn_on = !!(condition);                              \
  27.         if (unlikely(__ret_warn_on))                                    \
  28.                 __WARN();                                               \
  29.         unlikely(__ret_warn_on);                                        \
  30. })
  31.  
  32.  
  33. #define WARN_ONCE(condition, format...) ({                      \
  34.         static bool __warned;                                   \
  35.         int __ret_warn_once = !!(condition);                    \
  36.                                                                 \
  37.         if (unlikely(__ret_warn_once))                          \
  38.                 if (WARN(!__warned, format))                    \
  39.                         __warned = true;                        \
  40.         unlikely(__ret_warn_once);                              \
  41. })
  42.  
  43.  
  44. #define WARN_ON_ONCE(condition) ({                              \
  45.         static bool __warned;                                   \
  46.         int __ret_warn_once = !!(condition);                    \
  47.                                                                 \
  48.         if (unlikely(__ret_warn_once))                          \
  49.                 if (WARN_ON(!__warned))                         \
  50.                         __warned = true;                        \
  51.         unlikely(__ret_warn_once);                              \
  52. })
  53.  
  54. #define BUG() do { \
  55.          printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
  56.  } while (0)
  57.  
  58. #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
  59.  
  60. #define BUILD_BUG_ON_NOT_POWER_OF_2(n)                  \
  61.         BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
  62.  
  63.  
  64. #define printk_once(fmt, ...)                   \
  65. ({                                              \
  66.         static bool __print_once;               \
  67.                                                 \
  68.         if (!__print_once) {                    \
  69.                 __print_once = true;            \
  70.                 printk(fmt, ##__VA_ARGS__);     \
  71.         }                                       \
  72. })
  73.  
  74.  
  75. #define pr_warn_once(fmt, ...)                                  \
  76.         printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
  77.  
  78. #endif
  79.