Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86, cmpxchg: Use __compiletime_error() to make usage messages a bit nicer

Use __compiletime_error() to produce a compile-time error rather than
link-time, where available.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Link: http://lkml.kernel.org/r/4E5BCC40.3030501@goop.org
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>

authored by

Jeremy Fitzhardinge and committed by
H. Peter Anvin
61e2cd0a 229855d6

+11 -4
+11 -4
arch/x86/include/asm/cmpxchg.h
··· 1 1 #ifndef ASM_X86_CMPXCHG_H 2 2 #define ASM_X86_CMPXCHG_H 3 3 4 + #include <linux/compiler.h> 4 5 #include <asm/alternative.h> /* Provides LOCK_PREFIX */ 5 6 6 - /* Non-existant functions to indicate usage errors at link time. */ 7 - extern void __xchg_wrong_size(void); 8 - extern void __cmpxchg_wrong_size(void); 9 - extern void __xadd_wrong_size(void); 7 + /* 8 + * Non-existant functions to indicate usage errors at link time 9 + * (or compile-time if the compiler implements __compiletime_error(). 10 + */ 11 + extern void __xchg_wrong_size(void) 12 + __compiletime_error("Bad argument size for xchg"); 13 + extern void __cmpxchg_wrong_size(void) 14 + __compiletime_error("Bad argument size for cmpxchg"); 15 + extern void __xadd_wrong_size(void) 16 + __compiletime_error("Bad argument size for xadd"); 10 17 11 18 /* 12 19 * Constants for operation sizes. On 32-bit, the 64-bit size it set to