Subversion Repositories Kolibri OS

Rev

Rev 3031 | Rev 3480 | 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.  
  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(1){ delay(10); };                                                    \
  57.  } while (0)
  58.  
  59. #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
  60.  
  61.  
  62.  
  63. #endif
  64.