1*19c468b4SFrançois Tigeot /* 2*19c468b4SFrançois Tigeot * Copyright (c) 2016 François Tigeot 3*19c468b4SFrançois Tigeot * All rights reserved. 4*19c468b4SFrançois Tigeot * 5*19c468b4SFrançois Tigeot * Redistribution and use in source and binary forms, with or without 6*19c468b4SFrançois Tigeot * modification, are permitted provided that the following conditions 7*19c468b4SFrançois Tigeot * are met: 8*19c468b4SFrançois Tigeot * 1. Redistributions of source code must retain the above copyright 9*19c468b4SFrançois Tigeot * notice unmodified, this list of conditions, and the following 10*19c468b4SFrançois Tigeot * disclaimer. 11*19c468b4SFrançois Tigeot * 2. Redistributions in binary form must reproduce the above copyright 12*19c468b4SFrançois Tigeot * notice, this list of conditions and the following disclaimer in the 13*19c468b4SFrançois Tigeot * documentation and/or other materials provided with the distribution. 14*19c468b4SFrançois Tigeot * 15*19c468b4SFrançois Tigeot * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16*19c468b4SFrançois Tigeot * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17*19c468b4SFrançois Tigeot * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18*19c468b4SFrançois Tigeot * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19*19c468b4SFrançois Tigeot * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20*19c468b4SFrançois Tigeot * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21*19c468b4SFrançois Tigeot * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22*19c468b4SFrançois Tigeot * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23*19c468b4SFrançois Tigeot * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24*19c468b4SFrançois Tigeot * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25*19c468b4SFrançois Tigeot */ 26*19c468b4SFrançois Tigeot 27*19c468b4SFrançois Tigeot #ifndef _ASM_BUG_H_ 28*19c468b4SFrançois Tigeot #define _ASM_BUG_H_ 29*19c468b4SFrançois Tigeot 30*19c468b4SFrançois Tigeot #define _WARN_STR(x) #x 31*19c468b4SFrançois Tigeot 32*19c468b4SFrançois Tigeot #define WARN_ON(condition) ({ \ 33*19c468b4SFrançois Tigeot int __ret = !!(condition); \ 34*19c468b4SFrançois Tigeot if (__ret) \ 35*19c468b4SFrançois Tigeot kprintf("WARNING %s failed at %s:%d\n", \ 36*19c468b4SFrançois Tigeot _WARN_STR(condition), __FILE__, __LINE__); \ 37*19c468b4SFrançois Tigeot unlikely(__ret); \ 38*19c468b4SFrançois Tigeot }) 39*19c468b4SFrançois Tigeot 40*19c468b4SFrançois Tigeot #define WARN_ON_ONCE(condition) ({ \ 41*19c468b4SFrançois Tigeot static int __warned; \ 42*19c468b4SFrançois Tigeot int __ret = !!(condition); \ 43*19c468b4SFrançois Tigeot if (__ret && !__warned) { \ 44*19c468b4SFrançois Tigeot kprintf("WARNING %s failed at %s:%d\n", \ 45*19c468b4SFrançois Tigeot _WARN_STR(condition), __FILE__, __LINE__); \ 46*19c468b4SFrançois Tigeot __warned = 1; \ 47*19c468b4SFrançois Tigeot } \ 48*19c468b4SFrançois Tigeot unlikely(__ret); \ 49*19c468b4SFrançois Tigeot }) 50*19c468b4SFrançois Tigeot 51*19c468b4SFrançois Tigeot #define WARN_ON_SMP(condition) WARN_ON(condition) 52*19c468b4SFrançois Tigeot 53*19c468b4SFrançois Tigeot #endif /* _ASM_BUG_H_ */ 54