xref: /OK3568_Linux_fs/kernel/drivers/gpu/arm/bifrost/mali_malisw.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 /*
3  *
4  * (C) COPYRIGHT 2014-2015, 2018, 2020-2022 ARM Limited. All rights reserved.
5  *
6  * This program is free software and is provided to you under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation, and any use by you of this program is subject to the terms
9  * of such GNU license.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you can access it online at
18  * http://www.gnu.org/licenses/gpl-2.0.html.
19  *
20  */
21 
22 /*
23  * Kernel-wide include for common macros and types.
24  */
25 
26 #ifndef _MALISW_H_
27 #define _MALISW_H_
28 
29 #include <linux/version.h>
30 
31 /**
32  * MIN - Return the lesser of two values.
33  * @x: value1
34  * @y: value2
35  *
36  * As a macro it may evaluate its arguments more than once.
37  * Refer to MAX macro for more details
38  */
39 #define MIN(x, y)	((x) < (y) ? (x) : (y))
40 
41 /**
42  * MAX - Return the greater of two values.
43  * @x: value1
44  * @y: value2
45  *
46  * As a macro it may evaluate its arguments more than once.
47  * If called on the same two arguments as MIN it is guaranteed to return
48  * the one that MIN didn't return. This is significant for types where not
49  * all values are comparable e.g. NaNs in floating-point types. But if you want
50  * to retrieve the min and max of two values, consider using a conditional swap
51  * instead.
52  */
53 #define MAX(x, y)	((x) < (y) ? (y) : (x))
54 
55 /**
56  * CSTD_UNUSED - Function-like macro for suppressing unused variable warnings.
57  *
58  * @x: unused variable
59  *
60  * Where possible such variables should be removed; this macro is present for
61  * cases where we much support API backwards compatibility.
62  */
63 #define CSTD_UNUSED(x)	((void)(x))
64 
65 /**
66  * CSTD_NOP - Function-like macro for use where "no behavior" is desired.
67  * @...: no-op
68  *
69  * This is useful when compile time macros turn a function-like macro in to a
70  * no-op, but where having no statement is otherwise invalid.
71  */
72 #define CSTD_NOP(...)	((void)#__VA_ARGS__)
73 
74 /**
75  * CSTD_STR1 - Function-like macro for stringizing a single level macro.
76  * @x: macro's value
77  *
78  * @code
79  * #define MY_MACRO 32
80  * CSTD_STR1( MY_MACRO )
81  * > "MY_MACRO"
82  * @endcode
83  */
84 #define CSTD_STR1(x)	#x
85 
86 /**
87  * CSTD_STR2 - Function-like macro for stringizing a macro's value.
88  * @x: macro's value
89  *
90  * This should not be used if the macro is defined in a way which may have no
91  * value; use the alternative @c CSTD_STR2N macro should be used instead.
92  * @code
93  * #define MY_MACRO 32
94  * CSTD_STR2( MY_MACRO )
95  * > "32"
96  * @endcode
97  */
98 #define CSTD_STR2(x)	CSTD_STR1(x)
99 
100  #ifndef fallthrough
101  #define fallthrough    __fallthrough
102  #endif /* fallthrough */
103 
104 #ifndef __fallthrough
105 #define __fallthrough  __attribute__((fallthrough))
106 #endif /* __fallthrough */
107 
108 #endif /* _MALISW_H_ */
109