1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _ASM_GENERIC_BUG_H 3 #define _ASM_GENERIC_BUG_H 4 #include "printk.h" 5 #include "build_bug.h" 6 #include "linux/compiler.h" 7 8 9 #ifndef WARN 10 #define WARN(condition, format...) \ 11 ({ \ 12 int __ret_warn_on = !!(condition); \ 13 if (unlikely(__ret_warn_on)) { \ 14 efi_warn("(%s:%d)", __FILE__, __LINE__); \ 15 efi_printk(format); \ 16 } \ 17 unlikely(__ret_warn_on); \ 18 }) 19 #endif 20 21 #ifndef WARN_ON 22 #define WARN_ON(condition) \ 23 ({ \ 24 int __ret_warn_on = !!(condition); \ 25 if (unlikely(__ret_warn_on)) \ 26 efi_warn("(%s:%d)\n", __FILE__, __LINE__); \ 27 unlikely(__ret_warn_on); \ 28 }) 29 #endif 30 31 #define WARN_ON_ONCE(condition) WARN_ON(condition) 32 #define WARN_ONCE(condition, format...) WARN(condition, format) 33 #define WARN_TAINT(condition, taint, format...) WARN(condition, format) 34 #define WARN_TAINT_ONCE(condition, taint, format...) WARN(condition, format) 35 36 /* Optimization barrier */ 37 #ifndef barrier 38 /* The "volatile" is due to gcc bugs */ 39 #define barrier() __asm__ __volatile__("" : : : "memory") 40 #endif 41 42 #define BUILD_BUG_ON(condition) \ 43 do { \ 44 efi_err("BUILD_BUG_ON(%s)\n", #condition); \ 45 while (1) \ 46 ; \ 47 } while (1) 48 49 #ifdef __CHECKER__ 50 #define BUILD_BUG_ON_ZERO(e) (0) 51 #else /* __CHECKER__ */ 52 /* 53 * Force a compilation error if condition is true, but also produce a 54 * result (of value 0 and type int), so the expression can be used 55 * e.g. in a structure initializer (or where-ever else comma expressions 56 * aren't permitted). 57 */ 58 #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int : (-!!(e)); }))) 59 #endif /* __CHECKER__ */ 60 61 62 #endif 63