diff options
author | David Rientjes <rientjes@google.com> | 2007-05-09 05:35:27 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-09 15:30:56 -0400 |
commit | 0d7ebbbc6eaa5539f78ab20ed6ff1725a4e332ef (patch) | |
tree | ddef8183ac6440e96678fd4d1159ee86619e2a97 | |
parent | f7e4217b007d1f73e7e3cf10ba4fea4a608c603f (diff) |
compiler: introduce __used and __maybe_unused
__used is defined to be __attribute__((unused)) for all pre-3.3 gcc
compilers to suppress warnings for unused functions because perhaps they
are referenced only in inline assembly. It is defined to be
__attribute__((used)) for gcc 3.3 and later so that the code is still
emitted for such functions.
__maybe_unused is defined to be __attribute__((unused)) for both function
and variable use if it could possibly be unreferenced due to the evaluation
of preprocessor macros. Function prototypes shall be marked with
__maybe_unused if the actual definition of the function is dependant on
preprocessor macros.
No update to compiler-intel.h is necessary because ICC supports both
__attribute__((used)) and __attribute__((unused)) as specified by the gcc
manual.
__attribute_used__ is deprecated and will be removed once all current
code is converted to using __used.
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Adrian Bunk <bunk@stusta.de>
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/compiler-gcc.h | 1 | ||||
-rw-r--r-- | include/linux/compiler-gcc3.h | 6 | ||||
-rw-r--r-- | include/linux/compiler-gcc4.h | 3 | ||||
-rw-r--r-- | include/linux/compiler.h | 21 |
4 files changed, 25 insertions, 6 deletions
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index a9f794716a81..03ec2311fb29 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h | |||
@@ -40,3 +40,4 @@ | |||
40 | #define noinline __attribute__((noinline)) | 40 | #define noinline __attribute__((noinline)) |
41 | #define __attribute_pure__ __attribute__((pure)) | 41 | #define __attribute_pure__ __attribute__((pure)) |
42 | #define __attribute_const__ __attribute__((__const__)) | 42 | #define __attribute_const__ __attribute__((__const__)) |
43 | #define __maybe_unused __attribute__((unused)) | ||
diff --git a/include/linux/compiler-gcc3.h b/include/linux/compiler-gcc3.h index ecd621fd27d2..a9e2863c2dbf 100644 --- a/include/linux/compiler-gcc3.h +++ b/include/linux/compiler-gcc3.h | |||
@@ -4,9 +4,11 @@ | |||
4 | #include <linux/compiler-gcc.h> | 4 | #include <linux/compiler-gcc.h> |
5 | 5 | ||
6 | #if __GNUC_MINOR__ >= 3 | 6 | #if __GNUC_MINOR__ >= 3 |
7 | # define __attribute_used__ __attribute__((__used__)) | 7 | # define __used __attribute__((__used__)) |
8 | # define __attribute_used__ __used /* deprecated */ | ||
8 | #else | 9 | #else |
9 | # define __attribute_used__ __attribute__((__unused__)) | 10 | # define __used __attribute__((__unused__)) |
11 | # define __attribute_used__ __used /* deprecated */ | ||
10 | #endif | 12 | #endif |
11 | 13 | ||
12 | #if __GNUC_MINOR__ >= 4 | 14 | #if __GNUC_MINOR__ >= 4 |
diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h index fd0cc7c4a636..a03e9398a6c2 100644 --- a/include/linux/compiler-gcc4.h +++ b/include/linux/compiler-gcc4.h | |||
@@ -12,7 +12,8 @@ | |||
12 | # define __inline __inline __attribute__((always_inline)) | 12 | # define __inline __inline __attribute__((always_inline)) |
13 | #endif | 13 | #endif |
14 | 14 | ||
15 | #define __attribute_used__ __attribute__((__used__)) | 15 | #define __used __attribute__((__used__)) |
16 | #define __attribute_used__ __used /* deprecated */ | ||
16 | #define __must_check __attribute__((warn_unused_result)) | 17 | #define __must_check __attribute__((warn_unused_result)) |
17 | #define __compiler_offsetof(a,b) __builtin_offsetof(a,b) | 18 | #define __compiler_offsetof(a,b) __builtin_offsetof(a,b) |
18 | #define __always_inline inline __attribute__((always_inline)) | 19 | #define __always_inline inline __attribute__((always_inline)) |
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 3b6949b41745..498c35920762 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
@@ -108,15 +108,30 @@ extern void __chk_io_ptr(const void __iomem *); | |||
108 | * Allow us to avoid 'defined but not used' warnings on functions and data, | 108 | * Allow us to avoid 'defined but not used' warnings on functions and data, |
109 | * as well as force them to be emitted to the assembly file. | 109 | * as well as force them to be emitted to the assembly file. |
110 | * | 110 | * |
111 | * As of gcc 3.3, static functions that are not marked with attribute((used)) | 111 | * As of gcc 3.4, static functions that are not marked with attribute((used)) |
112 | * may be elided from the assembly file. As of gcc 3.3, static data not so | 112 | * may be elided from the assembly file. As of gcc 3.4, static data not so |
113 | * marked will not be elided, but this may change in a future gcc version. | 113 | * marked will not be elided, but this may change in a future gcc version. |
114 | * | 114 | * |
115 | * NOTE: Because distributions shipped with a backported unit-at-a-time | ||
116 | * compiler in gcc 3.3, we must define __used to be __attribute__((used)) | ||
117 | * for gcc >=3.3 instead of 3.4. | ||
118 | * | ||
115 | * In prior versions of gcc, such functions and data would be emitted, but | 119 | * In prior versions of gcc, such functions and data would be emitted, but |
116 | * would be warned about except with attribute((unused)). | 120 | * would be warned about except with attribute((unused)). |
121 | * | ||
122 | * Mark functions that are referenced only in inline assembly as __used so | ||
123 | * the code is emitted even though it appears to be unreferenced. | ||
117 | */ | 124 | */ |
118 | #ifndef __attribute_used__ | 125 | #ifndef __attribute_used__ |
119 | # define __attribute_used__ /* unimplemented */ | 126 | # define __attribute_used__ /* deprecated */ |
127 | #endif | ||
128 | |||
129 | #ifndef __used | ||
130 | # define __used /* unimplemented */ | ||
131 | #endif | ||
132 | |||
133 | #ifndef __maybe_unused | ||
134 | # define __maybe_unused /* unimplemented */ | ||
120 | #endif | 135 | #endif |
121 | 136 | ||
122 | /* | 137 | /* |