1c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifndef __LINUX_COMPILER_H
2c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define __LINUX_COMPILER_H
3c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
4c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifndef __ASSEMBLY__
5c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
6c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifdef __CHECKER__
7c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __user		__attribute__((noderef, address_space(1)))
8c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __kernel	/* default address space */
9c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __safe		__attribute__((safe))
10c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __force	__attribute__((force))
11c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __nocast	__attribute__((nocast))
12c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __iomem	__attribute__((noderef, address_space(2)))
13c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __acquires(x)	__attribute__((context(0,1)))
14c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __releases(x)	__attribute__((context(1,0)))
15c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __acquire(x)	__context__(1)
16c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __release(x)	__context__(-1)
17c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __cond_lock(x)	((x) ? ({ __context__(1); 1; }) : 0)
18c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queruextern void __chk_user_ptr(void __user *);
19c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queruextern void __chk_io_ptr(void __iomem *);
20c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#else
21c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __user
22c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __kernel
23c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __safe
24c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __force
25c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __nocast
26c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __iomem
27c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __chk_user_ptr(x) (void)0
28c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __chk_io_ptr(x) (void)0
29c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __builtin_warning(x, y...) (1)
30c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __acquires(x)
31c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __releases(x)
32c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __acquire(x) (void)0
33c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __release(x) (void)0
34c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __cond_lock(x) (x)
35c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif
36c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
37c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifdef __KERNEL__
38c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
39c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#if __GNUC__ > 4
40c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#error no compiler-gcc.h file for this gcc version
41c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#elif __GNUC__ == 4
42c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# include <linux/compiler-gcc4.h>
43c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#elif __GNUC__ == 3
44c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# include <linux/compiler-gcc3.h>
45c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#else
46c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# error Sorry, your compiler is too old/not recognized.
47c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif
48c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
49c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/* Intel compiler defines __GNUC__. So we will overwrite implementations
50c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * coming from above header files here
51c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru */
52c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifdef __INTEL_COMPILER
53c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# include <linux/compiler-intel.h>
54c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif
55c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
56c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/*
57c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * Generic compiler-dependent macros required for kernel
58c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * build go below this comment. Actual compiler/compiler version
59c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * specific implementations come from the above header files
60c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru */
61c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
62c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define likely(x)	__builtin_expect(!!(x), 1)
63c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define unlikely(x)	__builtin_expect(!!(x), 0)
64c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
65c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/* Optimization barrier */
66c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifndef barrier
67c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define barrier() __memory_barrier()
68c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif
69c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
70c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifndef RELOC_HIDE
71c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define RELOC_HIDE(ptr, off)					\
72c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru  ({ unsigned long __ptr;					\
73c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru     __ptr = (unsigned long) (ptr);				\
74c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru    (typeof(ptr)) (__ptr + (off)); })
75c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif
76c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
77c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif /* __KERNEL__ */
78c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
79c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif /* __ASSEMBLY__ */
80c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
81c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifdef __KERNEL__
82c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/*
83c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * Allow us to mark functions as 'deprecated' and have gcc emit a nice
84c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * warning for each use, in hopes of speeding the functions removal.
85c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * Usage is:
86c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * 		int __deprecated foo(void)
87c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru */
88c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifndef __deprecated
89c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __deprecated		/* unimplemented */
90c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif
91c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
92c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifdef MODULE
93c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define __deprecated_for_modules __deprecated
94c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#else
95c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define __deprecated_for_modules
96c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif
97c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
98c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifndef __must_check
99c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define __must_check
100c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif
101c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
102c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/*
103c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * Allow us to avoid 'defined but not used' warnings on functions and data,
104c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * as well as force them to be emitted to the assembly file.
105c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru *
106c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * As of gcc 3.3, static functions that are not marked with attribute((used))
107c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * may be elided from the assembly file.  As of gcc 3.3, static data not so
108c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * marked will not be elided, but this may change in a future gcc version.
109c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru *
110c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * In prior versions of gcc, such functions and data would be emitted, but
111c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * would be warned about except with attribute((unused)).
112c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru */
113c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifndef __attribute_used__
114c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __attribute_used__	/* unimplemented */
115c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif
116c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
117c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/*
118c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * From the GCC manual:
119c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru *
120c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * Many functions have no effects except the return value and their
121c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * return value depends only on the parameters and/or global
122c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * variables.  Such a function can be subject to common subexpression
123c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * elimination and loop optimization just as an arithmetic operator
124c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * would be.
125c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * [...]
126c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru */
127c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifndef __attribute_pure__
128c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __attribute_pure__	/* unimplemented */
129c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif
130c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
131c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifndef noinline
132c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define noinline
133c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif
134c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
135c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifndef __always_inline
136c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#define __always_inline inline
137c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif
138c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
139c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif /* __KERNEL__ */
140c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
141c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru/*
142c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * From the GCC manual:
143c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru *
144c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * Many functions do not examine any values except their arguments,
145c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * and have no effects except the return value.  Basically this is
146c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * just slightly more strict class than the `pure' attribute above,
147c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * since function is not allowed to read global memory.
148c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru *
149c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * Note that a function that has pointer arguments and examines the
150c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * data pointed to must _not_ be declared `const'.  Likewise, a
151c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * function that calls a non-`const' function usually must not be
152c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * `const'.  It does not make sense for a `const' function to return
153c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru * `void'.
154c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru */
155c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#ifndef __attribute_const__
156c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru# define __attribute_const__	/* unimplemented */
157c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif
158c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru
159c559cd81139f97cecad1ad91a0b2e25a5936d53Jean-Baptiste Queru#endif /* __LINUX_COMPILER_H */
160