blob: 70fe612957338c84ffeb61f03c358c6ca1e32789 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Arnaldo Carvalho de Melo19261402017-02-10 11:41:11 -03002#ifndef _TOOLS_LINUX_COMPILER_H_
3#error "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
4#endif
5
6/*
7 * Common definitions for all gcc versions go here.
8 */
9#define GCC_VERSION (__GNUC__ * 10000 \
10 + __GNUC_MINOR__ * 100 \
11 + __GNUC_PATCHLEVEL__)
12
13#if GCC_VERSION >= 70000 && !defined(__CHECKER__)
14# define __fallthrough __attribute__ ((fallthrough))
15#endif
Arnaldo Carvalho de Melo49006532017-02-22 16:48:24 -030016
17#if GCC_VERSION >= 40300
18# define __compiletime_error(message) __attribute__((error(message)))
19#endif /* GCC_VERSION >= 40300 */
Arnaldo Carvalho de Melof6441af2017-04-17 11:25:00 -030020
21/* &a[0] degrades to a pointer: a different type from an array */
22#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
Arnaldo Carvalho de Melo6c346642017-06-16 11:39:15 -030023
Arnaldo Carvalho de Melo6e1690c2018-05-17 15:12:36 -030024#ifndef __pure
25#define __pure __attribute__((pure))
26#endif
Arnaldo Carvalho de Melo9dd4ca42017-06-16 11:39:15 -030027#define noinline __attribute__((noinline))
Arnaldo Carvalho de Melo259d4072017-09-05 10:52:02 -030028#ifndef __packed
Arnaldo Carvalho de Meloc9f5da72017-06-16 11:39:15 -030029#define __packed __attribute__((packed))
Arnaldo Carvalho de Melo259d4072017-09-05 10:52:02 -030030#endif
31#ifndef __noreturn
Arnaldo Carvalho de Melo6c346642017-06-16 11:39:15 -030032#define __noreturn __attribute__((noreturn))
Arnaldo Carvalho de Melo259d4072017-09-05 10:52:02 -030033#endif
34#ifndef __aligned
Arnaldo Carvalho de Melo5c97cac2017-06-16 11:39:15 -030035#define __aligned(x) __attribute__((aligned(x)))
Arnaldo Carvalho de Melo259d4072017-09-05 10:52:02 -030036#endif
Arnaldo Carvalho de Meloafaed6d2017-06-16 11:57:54 -030037#define __printf(a, b) __attribute__((format(printf, a, b)))
Arnaldo Carvalho de Melo3ee350f2017-06-16 11:57:54 -030038#define __scanf(a, b) __attribute__((format(scanf, a, b)))