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