xref: /dflybsd-src/sys/dev/drm/include/linux/bug.h (revision 3f2dd94a569761201b5b0a18b2f697f97fe1b9dc)
10effaaacSFrançois Tigeot /*
2464a791cSFrançois Tigeot  * Copyright (c) 2015-2020 François Tigeot <ftigeot@wolfpond.org>
30effaaacSFrançois Tigeot  * All rights reserved.
40effaaacSFrançois Tigeot  *
50effaaacSFrançois Tigeot  * Redistribution and use in source and binary forms, with or without
60effaaacSFrançois Tigeot  * modification, are permitted provided that the following conditions
70effaaacSFrançois Tigeot  * are met:
80effaaacSFrançois Tigeot  * 1. Redistributions of source code must retain the above copyright
90effaaacSFrançois Tigeot  *    notice unmodified, this list of conditions, and the following
100effaaacSFrançois Tigeot  *    disclaimer.
110effaaacSFrançois Tigeot  * 2. Redistributions in binary form must reproduce the above copyright
120effaaacSFrançois Tigeot  *    notice, this list of conditions and the following disclaimer in the
130effaaacSFrançois Tigeot  *    documentation and/or other materials provided with the distribution.
140effaaacSFrançois Tigeot  *
150effaaacSFrançois Tigeot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
160effaaacSFrançois Tigeot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
170effaaacSFrançois Tigeot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
180effaaacSFrançois Tigeot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
190effaaacSFrançois Tigeot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
200effaaacSFrançois Tigeot  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
210effaaacSFrançois Tigeot  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
220effaaacSFrançois Tigeot  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
230effaaacSFrançois Tigeot  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
240effaaacSFrançois Tigeot  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
250effaaacSFrançois Tigeot  */
260effaaacSFrançois Tigeot 
270effaaacSFrançois Tigeot #ifndef LINUX_BUG_H
280effaaacSFrançois Tigeot #define LINUX_BUG_H
290effaaacSFrançois Tigeot 
3019c468b4SFrançois Tigeot #include <asm/bug.h>
3119c468b4SFrançois Tigeot #include <linux/compiler.h>
3219c468b4SFrançois Tigeot 
33464a791cSFrançois Tigeot /*
34464a791cSFrançois Tigeot  * Some conditions result in a "expression in static assertion is not constant"
35464a791cSFrançois Tigeot  * compilation error; just disable the check for now.
36464a791cSFrançois Tigeot  */
37464a791cSFrançois Tigeot #define BUILD_BUG_ON(condition)
380effaaacSFrançois Tigeot 
39b61dea7fSFrançois Tigeot #define	BUILD_BUG_ON_NOT_POWER_OF_2(n)			      \
40161c3d83SSascha Wildner 	CTASSERT(((n) != 0) && (powerof2((n))))
41b61dea7fSFrançois Tigeot 
42d3bbf4bcSFrançois Tigeot #define	BUILD_BUG()	BUILD_BUG_ON(1)
43d3bbf4bcSFrançois Tigeot 
44ff464e6bSzrj #define	BUILD_BUG_ON_MSG(cond, msg)	do { } while (0)
451219e912SFrançois Tigeot 
46a85cb24fSFrançois Tigeot #define BUILD_BUG_ON_INVALID(expr)	((void)(expr))
47a85cb24fSFrançois Tigeot 
48*3f2dd94aSFrançois Tigeot #define BUILD_BUG_ON_ZERO(x)	0
49*3f2dd94aSFrançois Tigeot 
500effaaacSFrançois Tigeot #endif /* LINUX_BUG_H */
51