The patch titled compiler: introduce __used and __maybe_unused has been added to the -mm tree. Its filename is compiler-introduce-__used-and-__maybe_unused.patch *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: compiler: introduce __used and __maybe_unused From: David Rientjes <rientjes@xxxxxxxxxx> __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@xxxxxxxxxxxxxxx> Cc: Adrian Bunk <bunk@xxxxxxxxx> Signed-off-by: David Rientjes <rientjes@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/compiler-gcc.h | 1 + include/linux/compiler-gcc3.h | 6 ++++-- include/linux/compiler-gcc4.h | 3 ++- include/linux/compiler.h | 21 ++++++++++++++++++--- 4 files changed, 25 insertions(+), 6 deletions(-) diff -puN include/linux/compiler-gcc.h~compiler-introduce-__used-and-__maybe_unused include/linux/compiler-gcc.h --- a/include/linux/compiler-gcc.h~compiler-introduce-__used-and-__maybe_unused +++ a/include/linux/compiler-gcc.h @@ -40,3 +40,4 @@ #define noinline __attribute__((noinline)) #define __attribute_pure__ __attribute__((pure)) #define __attribute_const__ __attribute__((__const__)) +#define __maybe_unused __attribute__((unused)) diff -puN include/linux/compiler-gcc3.h~compiler-introduce-__used-and-__maybe_unused include/linux/compiler-gcc3.h --- a/include/linux/compiler-gcc3.h~compiler-introduce-__used-and-__maybe_unused +++ a/include/linux/compiler-gcc3.h @@ -4,9 +4,11 @@ #include <linux/compiler-gcc.h> #if __GNUC_MINOR__ >= 3 -# define __attribute_used__ __attribute__((__used__)) +# define __used __attribute__((__used__)) +# define __attribute_used__ __used /* deprecated */ #else -# define __attribute_used__ __attribute__((__unused__)) +# define __used __attribute__((__unused__)) +# define __attribute_used__ __used /* deprecated */ #endif #if __GNUC_MINOR__ >= 4 diff -puN include/linux/compiler-gcc4.h~compiler-introduce-__used-and-__maybe_unused include/linux/compiler-gcc4.h --- a/include/linux/compiler-gcc4.h~compiler-introduce-__used-and-__maybe_unused +++ a/include/linux/compiler-gcc4.h @@ -12,7 +12,8 @@ # define __inline __inline __attribute__((always_inline)) #endif -#define __attribute_used__ __attribute__((__used__)) +#define __used __attribute__((__used__)) +#define __attribute_used__ __used /* deprecated */ #define __must_check __attribute__((warn_unused_result)) #define __compiler_offsetof(a,b) __builtin_offsetof(a,b) #define __always_inline inline __attribute__((always_inline)) diff -puN include/linux/compiler.h~compiler-introduce-__used-and-__maybe_unused include/linux/compiler.h --- a/include/linux/compiler.h~compiler-introduce-__used-and-__maybe_unused +++ a/include/linux/compiler.h @@ -108,15 +108,30 @@ extern void __chk_io_ptr(const void __io * Allow us to avoid 'defined but not used' warnings on functions and data, * as well as force them to be emitted to the assembly file. * - * As of gcc 3.3, static functions that are not marked with attribute((used)) - * may be elided from the assembly file. As of gcc 3.3, static data not so + * As of gcc 3.4, static functions that are not marked with attribute((used)) + * may be elided from the assembly file. As of gcc 3.4, static data not so * marked will not be elided, but this may change in a future gcc version. * + * NOTE: Because distributions shipped with a backported unit-at-a-time + * compiler in gcc 3.3, we must define __used to be __attribute__((used)) + * for gcc >=3.3 instead of 3.4. + * * In prior versions of gcc, such functions and data would be emitted, but * would be warned about except with attribute((unused)). + * + * Mark functions that are referenced only in inline assembly as __used so + * the code is emitted even though it appears to be unreferenced. */ #ifndef __attribute_used__ -# define __attribute_used__ /* unimplemented */ +# define __attribute_used__ /* deprecated */ +#endif + +#ifndef __used +# define __used /* unimplemented */ +#endif + +#ifndef __maybe_unused +# define __maybe_unused /* unimplemented */ #endif /* _ Patches currently in -mm which might be from rientjes@xxxxxxxxxx are origin.patch i386-add-ptep_test_and_clear_dirtyyoung.patch i386-use-pte_update_defer-in-ptep_test_and_clear_dirtyyoung.patch smaps-extract-pmd-walker-from-smaps-code.patch smaps-add-pages-referenced-count-to-smaps.patch smaps-add-clear_refs-file-to-clear-reference.patch cpusets-allow-tif_memdie-threads-to-allocate-anywhere.patch mm-fix-handling-of-panic_on_oom-when-cpusets-are-in-use.patch oom-fix-constraint-deadlock.patch wavefront-only-declare-isapnp-on-config_pnp.patch git-cpufreq.patch maps2-uninline-some-functions-in-the-page-walker.patch maps2-eliminate-the-pmd_walker-struct-in-the-page-walker.patch maps2-remove-vma-from-args-in-the-page-walker.patch maps2-propagate-errors-from-callback-in-page-walker.patch maps2-add-callbacks-for-each-level-to-page-walker.patch maps2-move-the-page-walker-code-to-lib.patch maps2-simplify-interdependence-of-proc-pid-maps-and-smaps.patch maps2-move-clear_refs-code-to-task_mmuc.patch maps2-regroup-task_mmu-by-interface.patch maps2-make-proc-pid-smaps-optional-under-config_embedded.patch maps2-make-proc-pid-clear_refs-option-under-config_embedded.patch maps2-add-proc-pid-pagemap-interface.patch maps2-add-proc-kpagemap-interface.patch cpusets-allow-empty-cpusmems_allowed-to-be-set-for.patch cpusets-allow-empty-cpusmems_allowed-to-be-set-for-fix.patch compiler-introduce-__used-and-__maybe_unused.patch i386-pci-type-may-be-unused.patch sh-dma-use-__attribute_unused__.patch scsi-fix-ambiguous-gdthtable-definition.patch frv-gdb-use-__attribute_unused__.patch i386-voyager-use-__attribute_unused__.patch mips-excite-use-__attribute_unused__.patch mips-tlbex-use-__attribute_unused__.patch powerpc-ps3-use-__attribute_unused__.patch i386-mmzone-use-__attribute_unused__.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html