summaryrefslogtreecommitdiff
path: root/mali_kbase/mali_malisw.h
blob: d9db189e8684bc633557edb609f4534d98633657 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
 *
 * (C) COPYRIGHT 2014-2015, 2018, 2020-2022 ARM Limited. All rights reserved.
 *
 * This program is free software and is provided to you under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation, and any use by you of this program is subject to the terms
 * of such GNU license.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, you can access it online at
 * http://www.gnu.org/licenses/gpl-2.0.html.
 *
 */

/*
 * Kernel-wide include for common macros and types.
 */

#ifndef _MALISW_H_
#define _MALISW_H_

#include <linux/version.h>

/**
 * MIN - Return the lesser of two values.
 * @x: value1
 * @y: value2
 *
 * As a macro it may evaluate its arguments more than once.
 * Refer to MAX macro for more details
 */
#define MIN(x, y)	((x) < (y) ? (x) : (y))

/**
 * MAX - Return the greater of two values.
 * @x: value1
 * @y: value2
 *
 * As a macro it may evaluate its arguments more than once.
 * If called on the same two arguments as MIN it is guaranteed to return
 * the one that MIN didn't return. This is significant for types where not
 * all values are comparable e.g. NaNs in floating-point types. But if you want
 * to retrieve the min and max of two values, consider using a conditional swap
 * instead.
 */
#define MAX(x, y)	((x) < (y) ? (y) : (x))

/**
 * CSTD_UNUSED - Function-like macro for suppressing unused variable warnings.
 *
 * @x: unused variable
 *
 * Where possible such variables should be removed; this macro is present for
 * cases where we much support API backwards compatibility.
 */
#define CSTD_UNUSED(x)	((void)(x))

/**
 * CSTD_NOP - Function-like macro for use where "no behavior" is desired.
 * @...: no-op
 *
 * This is useful when compile time macros turn a function-like macro in to a
 * no-op, but where having no statement is otherwise invalid.
 */
#define CSTD_NOP(...)	((void)#__VA_ARGS__)

/**
 * CSTD_STR1 - Function-like macro for stringizing a single level macro.
 * @x: macro's value
 *
 * @code
 * #define MY_MACRO 32
 * CSTD_STR1( MY_MACRO )
 * > "MY_MACRO"
 * @endcode
 */
#define CSTD_STR1(x)	#x

/**
 * CSTD_STR2 - Function-like macro for stringizing a macro's value.
 * @x: macro's value
 *
 * This should not be used if the macro is defined in a way which may have no
 * value; use the alternative @c CSTD_STR2N macro should be used instead.
 * @code
 * #define MY_MACRO 32
 * CSTD_STR2( MY_MACRO )
 * > "32"
 * @endcode
 */
#define CSTD_STR2(x)	CSTD_STR1(x)

 #ifndef fallthrough
 #define fallthrough    __fallthrough
 #endif /* fallthrough */

#ifndef __fallthrough
#define __fallthrough  __attribute__((fallthrough))
#endif /* __fallthrough */

#endif /* _MALISW_H_ */