summaryrefslogtreecommitdiff
path: root/include/linux/compiler.h
AgeCommit message (Collapse)Author
2007-10-25Permit silencing of __deprecated warnings.Jeff Garzik
The __deprecated marker is quite useful in highlighting the remnants of old APIs that want removing. However, it is quite normal for one or more years to pass, before the (usually ancient, bitrotten) code in question is either updated or deleted. Thus, like __must_check, add a Kconfig option that permits the silencing of this compiler warning. This change mimics the ifdef-ery and Kconfig defaults of MUST_CHECK as closely as possible. Signed-off-by: Jeff Garzik <jgarzik@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-10-18Replace __attribute_pure__ with __pureRalf Baechle
To be consistent with the use of attributes in the rest of the kernel replace all use of __attribute_pure__ with __pure and delete the definition of __attribute_pure__. Signed-off-by: Ralf Baechle <ralf@linux-mips.org> Cc: Russell King <rmk@arm.linux.org.uk> Acked-by: Mauro Carvalho Chehab <mchehab@infradead.org> Cc: Bryan Wu <bryan.wu@analog.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-07-26make __chk_{user,io}_ptr() accept pointers to volatileAl Viro
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-07-21x86: Support __attribute__((__cold__)) in gcc 4.3Andi Kleen
gcc 4.3 supports a new __attribute__((__cold__)) to mark functions cold. Any path directly leading to a call of this function will be unlikely. And gcc will try to generate smaller code for the function itself. Please use with care. The code generation advantage isn't large and in most cases it is not worth uglifying code with this. This patch marks some common error functions like panic(), printk() as cold. This will longer term make many unlikely()s unnecessary, although we can keep them for now for older compilers. BUG is not marked cold because there is currently no way to tell gcc to mark a inline function told. Also all __init and __exit functions are marked cold. With a non -Os build this will tell the compiler to generate slightly smaller code for them. I think it currently only uses less alignments for labels, but that might change in the future. One disadvantage over *likely() is that they cannot be easily instrumented to verify them. Another drawback is that only the latest gcc 4.3 snapshots support this. Unfortunately we cannot detect this using the preprocessor. This means older snapshots will fail now. I don't think that's a problem because they are unreleased compilers that nobody should be using. gcc also has a __hot__ attribute, but I don't see any sense in using this in the kernel right now. But someday I hope gcc will be able to use more aggressive optimizing for hot functions even in -Os, if that happens it should be added. Includes compile fix from Thomas Gleixner. Cc: Jan Hubicka <jh@suse.cz> Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-21x86_64: Support gcc 5 properlyAndi Kleen
The ifdef tests were broken. Assume it acts like gcc 4 Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-09compiler: introduce __used and __maybe_unusedDavid Rientjes
__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>
2007-03-26[PATCH] Add const to pointer qualifiers for __chk_user_ptr and __chk_io_ptr.Russ Cox
Change prototypes for __chk_user_ptr and __chk_io_ptr to take const void* instead of void*, so that code can pass "const void *" to them. (Right now sparse does not warn about passing const void* to void* functions, but that is a separate bug that I believe Josh is working on, and once sparse does check this, the changed prototypes will be necessary.) Signed-off-by: Russ Cox <rsc@swtch.com> Signed-off-by: Josh Triplett <josh@freedesktop.org> Acked-by: Christopher Li <sparse@chrisli.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2006-12-12include/linux/compiler.h: reject gcc 3 < gcc 3.2Alistair John Strachan
The kernel doesn't compile with GCC <3.2, do not allow it to succeed if GCC 3.0.x or 3.1.x are used. Signed-off-by: Alistair John Strachan <s0348365@sms.ed.ac.uk> Signed-off-by: Adrian Bunk <bunk@stusta.de>
2006-10-01[PATCH] Pass sparse the lock expression given to lock annotationsJosh Triplett
The lock annotation macros __acquires, __releases, __acquire, and __release all currently throw away the lock expression passed as an argument. Now that sparse can parse __context__ and __attribute__((context)) with a context expression, pass the lock expression down to sparse as the context expression. This requires a version of sparse from GIT commit 37475a6c1c3e66219e68d912d5eb833f4098fd72 or later. Signed-off-by: Josh Triplett <josh@freedesktop.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-09-29[PATCH] Pass a lock expression to __cond_lock, like __acquire and __releaseJosh Triplett
Currently, __acquire and __release take a lock expression, but __cond_lock takes only a condition, not the lock acquired if the expression evaluates to true. Change __cond_lock to accept a lock expression, and change all the callers to pass in a lock expression. Signed-off-by: Josh Triplett <josh@freedesktop.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-09-25add CONFIG_ENABLE_MUST_CHECKAndrew Morton
Those 1500 warnings can be a bit of a pain. Add a config option to shut them up. Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-05-04Restore __attribute_const__ to user-visibility in linux/compiler.h...for nowDavid Woodhouse
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-05-02Guard some of linux/compiler.h with #ifdef __KERNEL__David Woodhouse
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
2006-01-08[PATCH] Abandon gcc-2.95.xAndrew Morton
There's one scsi driver which doesn't compile due to weird __VA_ARGS__ tricks and the rather useful scsi/sd.c is currently getting an ICE. None of the new SAS code compiles, due to extensive use of anonymous unions. The V4L guys are very good at exploiting the gcc-2.95.x macro expansion bug (_why_ does each driver need to implement its own debug macros?) and various people keep on sneaking in anonymous unions, which are rather nice. Plus anonymous unions are rather useful. Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-05-01[PATCH] Add deprecated_for_modulesPaul E. McKenney
Add a deprecated_for_modules macro that allows symbols to be deprecated only when used by modules, as suggested by Andrew Morton some months back. Signed-off-by: Paul E. McKenney <paulmck@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-03-27Add '__nocast' sparse annotation to allow people to mark placesLinus Torvalds
where implicit casts are not appropriate. This can be used to mark unsigned integers as being uncastable to signed, for example. Or enums as not degrading to integers and vice versa.
2005-03-13[PATCH] typo in include/linux/compiler.hOlaf Hering
small nitpick, __KERNEL__ is the inner ifdef. Signed-off-by: Olaf Hering <olh@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-03-07[PATCH] add compiler-gcc4.hAdrian Bunk
With the release of gcc 4.0 being only a few months away and people already tring compiling with it, it's time for adding a compiler-gcc4.h . This patch contains the following changes: - remove compiler-gcc+.h - compiler-gcc4.h: new file based on a corrected compiler-gcc+.h - compiler.h: include compiler-gcc4.h for gcc 4 - compiler.h: #error for gcc > 4 - compiler-gcc3.h: remove __compiler_offsetof (there will never be a gcc 3.5) small indention corrections I've tested the compilation with both gcc 3.4.4 and a recent gcc 4.0 snapshot from Debian experimental. Signed-off-by: Adrian Bunk <bunk@stusta.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2004-10-30Add sparse checker rules for conditional lock functions: trylockLinus Torvalds
and atomic_dec_and_lock. This means that we now have all of the spinlock context counting infrastructure in place, and you can check-compile the kernel with sparse -Wcontext.
2004-10-23Start supporting lock context annotations.Linus Torvalds
This just sets up the portability defines.
2004-10-18Wrap <linux/compiler.h> inside '#ifndef __ASSEMBLY__'Linus Torvalds
None of the compatibility defines make sense for assembly files, and gcc has trouble with vararg macros when using "-traditional" (which is used for asm), to the point of ICE'ing.
2004-10-18Older gcc's ICE on missing (unused) varags macro name.Linus Torvalds
2004-10-18Add fake '__builtin_warning()' for the gcc case.Linus Torvalds
Allows us to do compile-time sparse warnings of our own.
2004-09-10Add sparse "__iomem" infrastructure to check PCI address usageLinus Torvalds
There's tons of mis-use of PCI memory-mapped IO that is used as if it was regular memory. That fails disastrously on a number of architectures, and it doesn't help that it just happens to work on regular x86 boxes. This makes makes us do much stricter type-checking. Some of it visible to the regular compiler, but the bulk of it is for sparse.
2004-08-22[PATCH] gcc-3.5 fixesAndi Kleen
Trivial gcc-3.5 build fixes. Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2004-07-01[PATCH] produce a warning on unchecked inode_setattr useArjan van de Ven
The patch below uses the new-in-gcc-3.4 option to generate a warning on unchecked results of marked functions, and applies this to the inode_setattr function (which based on recent bk commits HAS to be checked for it's return value for correct operation). A warning looks like this: fs/ext2/inode.c:1279: warning: ignoring return value of 'inode_setattr', declared with attribute warn_unused_result Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2004-05-31sparse: use new generic __chk_user_ptr() macro in x86/ppc64/sparc*Linus Torvalds
Older versions of gcc were unhappy with our previous trick, and just separating out the __CHECKER__ case made it much simpler.
2004-05-30sparse: add "__force" type attribute for forcing a cast.Linus Torvalds
2004-04-16Add sparse __safe annotationLinus Torvalds
2004-03-11[PATCH] compiler.h scoping fixesAndrew Morton
From: Ville Nuorvala <vnuorval@tcs.hut.fi> There are a few kernel-only things in compiler.h which should have been placed inside __KERNEL__.
2004-02-18[PATCH] Add noinline attributeAndrew Morton
From: Andi Kleen <ak@muc.de> This patch adds the `noinline' function attribute. It can be used to explicitly tell the compiler to not inline functions. We need this due to what is, IMO, a bug present in gcc-3.4 and current gcc-3.5 CVS: the compiler is inlining init/main.c:rest_init() inside init/main.c:start_kernel(), despite the fact that thay are declared to be placed in different text sections.
2004-02-09Make <linux/compiler.h> a bit more palatable toLinus Torvalds
user program inclusion. It's still wrong to include kernel headers from user programs. Oh, well.
2004-01-18[PATCH] const vs. __attribute__((const)) confusionAndrew Morton
From: "H. Peter Anvin" <hpa@zytor.com> Declaring a function to return a const scalar value is pretty meaningless. These functions are really trying to say that they don't alter any external state. Fix that up by using __attribute__((const)), if the compiler supports that.
2003-11-18[PATCH] init.h needs to include compiler.hAndrew Morton
From: Jun Sun <jsun@mvista.com> It is needed for all those "__attribute_used__" etc to be valid. Also, it seems that when compiling a file ending in ".S", gcc-2.95.3 does not expand __GNUC__ at all. This causes the compiler version check to fail when building vsyscall.S. So add __ASSEMBLY__ wrappers in there.
2003-09-21[PATCH] ECC supportAndrew Morton
From: "Nakajima, Jun" <jun.nakajima@intel.com> Split the increasingly messy compiler.h file into per-compiler files and also add support for non-gcc compilers. With the current implementation: include/linux/compiler.h defines the compiler-dependent abstractions which can be overwritten by per-compiler definitions. include/linux/compiler-gcc.h contains the common definitions for all gcc versions. include/linux/compiler-gcc[2,3,+].h contains gcc major version specific definitions. include/linux/compiler-intel.h contains intel compiler specific definitions."
2003-08-14[PATCH] fix [un]likely(), add ptr supportAndrew Morton
From: Albert Cahalan <albert@users.sourceforge.net> 1. allows likely() and unlikely() to work for pointers 2. fixes likely() (in C, any non-zero value is true)
2003-07-08Make the gcc version checks use the preprocessor symbolsLinus Torvalds
consistently.
2003-07-08[PATCH] Fix problem introduced by do_div() patchBernardo Innocenti
- export the __div64_32 symbol for modules; - add likely() to the fast path (divisor>>32 == 0); - add __attribute__((pure)) to __div64_32() prototype so the compiler knows global memory isn't clobbered; - avoid building __div64_32() on 64bit architectures.
2003-04-08User pointers are not just in another address space, they alsoLinus Torvalds
must never be dereferenced directly. Make that clear in the attribute.
2003-04-08Add __user/__kernel address space modifiers. When notLinus Torvalds
checking, these end up being no-ops, but they get enabled by the type checker as special address_space attributes.
2003-03-10[PATCH] work around gcc-3.x inlining bugsAndrew Morton
Force inlining even when gcc-3.x is too confused to do it for us.
2003-02-18[PATCH] eliminate warnings in generated module filesRichard Henderson
The compiler.h fragment should describe the problem well enough.
2002-12-30Quoth James: "Oops, mea culpa on that one. It's missing a trailing `__'Linus Torvalds
on the end of __GNUC_MINOR"
2002-12-30[PATCH] __deprecated requires gcc 3.1Robert Love
James Bottomley confirmed the "deprecated" attribute requires gcc 3.1 and onward, not gcc 3.0. This updates the check in compiler.h accordingly.
2002-12-29[PATCH] more deprectation bitsChristoph Hellwig
Rename the deprecated attribute to __deprecated to make it obvious this is something special and to avoid namespace clashes. Mark old module interfaces deprecated.
2002-12-28[PATCH] deprecated function attributeRobert Love
This patch adds support for usage of the attribute as "deprecated" and is backward-compatible. Usage is: int deprecated foo(void) etc.. If we mark a function as deprecated, then each use of the function emits a warning like: foo.c:12: warning: `baz' is deprecated (declared at bar.c:60) Which is very informative, giving both the location of each usage and where the little bastard is declared.
2002-09-03[PATCH] Fix RELOC_HIDE miscompilationAndi Kleen
RELOC_HIDE got miscompiled on gcc3.1/x86-64 in the access to softirq.c's per cpu variables. This fixes the problem. Clearly to hide the relocation the addition needs to be done after the value obfuscation, not before. I don't know if it triggers on other architectures (x86-64 is especially stressf here because it has negative kernel addresses), but seems like the right thing to do.
2002-04-09[PATCH] per-cpu cleanupRusty Russell
As per David Mosberger's request, splits into per-arch files (solves the #include mess), and fixes my "was not an lvalue" bug.
2002-03-06Fix percpu patch breakageLinus Torvalds
2002-03-04[PATCH] per-cpu areasRusty Russell
This is the Richard Henderson-approved, cleaner, brighter per-cpu patch.