blob: bd39b2090ad1ba226112fcd74bf46ca15406912a [file] [log] [blame]
Arnaldo Carvalho de Melo19261402017-02-10 11:41:11 -03001#ifndef _TOOLS_LINUX_COMPILER_H_
2#error "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
3#endif
4
5/*
6 * Common definitions for all gcc versions go here.
7 */
8#define GCC_VERSION (__GNUC__ * 10000 \
9 + __GNUC_MINOR__ * 100 \
10 + __GNUC_PATCHLEVEL__)
11
12#if GCC_VERSION >= 70000 && !defined(__CHECKER__)
13# define __fallthrough __attribute__ ((fallthrough))
14#endif
Arnaldo Carvalho de Melo49006532017-02-22 16:48:24 -030015
16#if GCC_VERSION >= 40300
17# define __compiletime_error(message) __attribute__((error(message)))
18#endif /* GCC_VERSION >= 40300 */
Arnaldo Carvalho de Melof6441af2017-04-17 11:25:00 -030019
20/* &a[0] degrades to a pointer: a different type from an array */
21#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
Arnaldo Carvalho de Melo6c346642017-06-16 11:39:15 -030022
Arnaldo Carvalho de Melo9dd4ca42017-06-16 11:39:15 -030023#define noinline __attribute__((noinline))
24
Arnaldo Carvalho de Meloc9f5da72017-06-16 11:39:15 -030025#define __packed __attribute__((packed))
26
Arnaldo Carvalho de Melo6c346642017-06-16 11:39:15 -030027#define __noreturn __attribute__((noreturn))
Arnaldo Carvalho de Meloafaed6d2017-06-16 11:57:54 -030028
Arnaldo Carvalho de Melo5c97cac2017-06-16 11:39:15 -030029#define __aligned(x) __attribute__((aligned(x)))
Arnaldo Carvalho de Meloafaed6d2017-06-16 11:57:54 -030030#define __printf(a, b) __attribute__((format(printf, a, b)))
Arnaldo Carvalho de Melo3ee350f2017-06-16 11:57:54 -030031#define __scanf(a, b) __attribute__((format(scanf, a, b)))