xref: /OK3568_Linux_fs/kernel/tools/include/linux/compiler-gcc.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef _TOOLS_LINUX_COMPILER_H_
3*4882a593Smuzhiyun #error "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
4*4882a593Smuzhiyun #endif
5*4882a593Smuzhiyun 
6*4882a593Smuzhiyun /*
7*4882a593Smuzhiyun  * Common definitions for all gcc versions go here.
8*4882a593Smuzhiyun  */
9*4882a593Smuzhiyun #ifndef GCC_VERSION
10*4882a593Smuzhiyun #define GCC_VERSION (__GNUC__ * 10000		\
11*4882a593Smuzhiyun 		     + __GNUC_MINOR__ * 100	\
12*4882a593Smuzhiyun 		     + __GNUC_PATCHLEVEL__)
13*4882a593Smuzhiyun #endif
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #if GCC_VERSION >= 70000 && !defined(__CHECKER__)
16*4882a593Smuzhiyun # define __fallthrough __attribute__ ((fallthrough))
17*4882a593Smuzhiyun #endif
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun #if GCC_VERSION >= 40300
20*4882a593Smuzhiyun # define __compiletime_error(message) __attribute__((error(message)))
21*4882a593Smuzhiyun #endif /* GCC_VERSION >= 40300 */
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun /* &a[0] degrades to a pointer: a different type from an array */
24*4882a593Smuzhiyun #define __must_be_array(a)	BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun #ifndef __pure
27*4882a593Smuzhiyun #define  __pure		__attribute__((pure))
28*4882a593Smuzhiyun #endif
29*4882a593Smuzhiyun #define  noinline	__attribute__((noinline))
30*4882a593Smuzhiyun #ifndef __packed
31*4882a593Smuzhiyun #define __packed	__attribute__((packed))
32*4882a593Smuzhiyun #endif
33*4882a593Smuzhiyun #ifndef __noreturn
34*4882a593Smuzhiyun #define __noreturn	__attribute__((noreturn))
35*4882a593Smuzhiyun #endif
36*4882a593Smuzhiyun #ifndef __aligned
37*4882a593Smuzhiyun #define __aligned(x)	__attribute__((aligned(x)))
38*4882a593Smuzhiyun #endif
39*4882a593Smuzhiyun #define __printf(a, b)	__attribute__((format(printf, a, b)))
40*4882a593Smuzhiyun #define __scanf(a, b)	__attribute__((format(scanf, a, b)))
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun #if GCC_VERSION >= 50100
43*4882a593Smuzhiyun #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
44*4882a593Smuzhiyun #endif
45