From: "Jan Beulich" Subject: [PATCH] compiler.h adjustments Date: Thu, 25 Oct 2012 12:51:59 +0100 Message-ID: <508943FF02000078000A46FE@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part59688DCF.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part59688DCF.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline - replace __attribute_used__ with just __used - add __maybe_unused and explain the difference between the two - remove gcc 3.x specifics (as we don't support building with it anymore; really for quite some time we didn't even support building with the checked for minor versions) - remove left over __setup() from init.h (rather than adjusting it) Signed-off-by: Jan Beulich --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -41,7 +41,7 @@ #include #include "gic.h" =20 -static __attribute_used__ void init_done(void) +static __used void init_done(void) { free_init_memory(); startup_cpu_idle_loop(); --- a/xen/include/xen/compiler.h +++ b/xen/include/xen/compiler.h @@ -1,7 +1,7 @@ #ifndef __LINUX_COMPILER_H #define __LINUX_COMPILER_H =20 -#if !defined(__GNUC__) || (__GNUC__ < 3) +#if !defined(__GNUC__) || (__GNUC__ < 4) #error Sorry, your compiler is too old/not recognized. #endif =20 @@ -17,11 +17,11 @@ #ifdef __clang__ /* Clang can replace some vars with new automatic ones that go in .data; * mark all explicit-segment vars 'used' to prevent that. */ -#define __section(s) __attribute_used__ __attribute__((__section__(s)= )) +#define __section(s) __used __attribute__((__section__(s))) #else #define __section(s) __attribute__((__section__(s))) #endif -#define __used_section(s) __attribute_used__ __attribute__((__section__(s)= )) +#define __used_section(s) __used __attribute__((__section__(s))) #define __text_section(s) __attribute__((__section__(s))) =20 #ifdef INIT_SECTIONS_ONLY @@ -36,23 +36,23 @@ #define __attribute_pure__ __attribute__((pure)) #define __attribute_const__ __attribute__((__const__)) =20 -#if __GNUC__ > 3 || (__GNUC__ =3D=3D 3 && __GNUC_MINOR__ >=3D 3) -#define __attribute_used__ __attribute__((__used__)) -#else -#define __attribute_used__ __attribute__((__unused__)) -#endif +/* + * The difference between the following two attributes is that __used is + * intended to be used in cases where a reference to an identifier may be + * invisible to the compiler (e.g. an inline assembly operand not listed + * in the asm()'s operands), preventing the compiler from eliminating the + * variable or function. + * __maybe_unused otoh is to be used to merely prevent warnings (e.g. = when + * an identifier is used only inside a preprocessor conditional, yet = putting + * its declaration/definition inside another conditional would harm code + * readability). + */ +#define __used __attribute__((__used__)) +#define __maybe_unused __attribute__((__unused__)) =20 -#if __GNUC__ > 3 || (__GNUC__ =3D=3D 3 && __GNUC_MINOR__ >=3D 4) #define __must_check __attribute__((warn_unused_result)) -#else -#define __must_check -#endif =20 -#if __GNUC__ > 3 #define offsetof(a,b) __builtin_offsetof(a,b) -#else -#define offsetof(a,b) ((unsigned long)&(((a *)0)->b)) -#endif =20 /* &a[0] degrades to a pointer: a different type from an array */ #define __must_be_array(a) \ --- a/xen/include/xen/init.h +++ b/xen/include/xen/init.h @@ -114,9 +114,6 @@ extern struct kernel_param __setup_start __kparam __setup_##_var =3D \ { __setup_str_##_var, OPT_STR, &_var, sizeof(_var) } =20 -/* Make sure obsolete cmdline params don't break the build. */ -#define __setup(_name, _fn) static void * __attribute_used__ _dummy_##_fn = =3D _fn - =20 #endif /* __ASSEMBLY__ */ =20 #ifdef CONFIG_HOTPLUG --=__Part59688DCF.0__= Content-Type: text/plain; name="attrib-used-unused.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="attrib-used-unused.patch" compiler.h adjustments=0A=0A- replace __attribute_used__ with just = __used=0A- add __maybe_unused and explain the difference between the = two=0A- remove gcc 3.x specifics (as we don't support building with it=0A = anymore; really for quite some time we didn't even support building=0A = with the checked for minor versions)=0A- remove left over __setup() from = init.h (rather than adjusting it)=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- a/xen/arch/arm/setup.c=0A+++ b/xen/arch/arm/se= tup.c=0A@@ -41,7 +41,7 @@=0A #include =0A #include = "gic.h"=0A =0A-static __attribute_used__ void init_done(void)=0A+static = __used void init_done(void)=0A {=0A free_init_memory();=0A = startup_cpu_idle_loop();=0A--- a/xen/include/xen/compiler.h=0A+++ = b/xen/include/xen/compiler.h=0A@@ -1,7 +1,7 @@=0A #ifndef __LINUX_COMPILER_= H=0A #define __LINUX_COMPILER_H=0A =0A-#if !defined(__GNUC__) || (__GNUC__ = < 3)=0A+#if !defined(__GNUC__) || (__GNUC__ < 4)=0A #error Sorry, your = compiler is too old/not recognized.=0A #endif=0A =0A@@ -17,11 +17,11 @@=0A = #ifdef __clang__=0A /* Clang can replace some vars with new automatic ones = that go in .data;=0A * mark all explicit-segment vars 'used' to prevent = that. */=0A-#define __section(s) __attribute_used__ __attribute__((__s= ection__(s)))=0A+#define __section(s) __used __attribute__((__section_= _(s)))=0A #else=0A #define __section(s) __attribute__((__section__(s))= )=0A #endif=0A-#define __used_section(s) __attribute_used__ __attribute__((= __section__(s)))=0A+#define __used_section(s) __used __attribute__((__secti= on__(s)))=0A #define __text_section(s) __attribute__((__section__(s)))=0A = =0A #ifdef INIT_SECTIONS_ONLY=0A@@ -36,23 +36,23 @@=0A #define __attribute_= pure__ __attribute__((pure))=0A #define __attribute_const__ __attribute__(= (__const__))=0A =0A-#if __GNUC__ > 3 || (__GNUC__ =3D=3D 3 && __GNUC_MINOR_= _ >=3D 3)=0A-#define __attribute_used__ __attribute__((__used__))=0A-#else= =0A-#define __attribute_used__ __attribute__((__unused__))=0A-#endif=0A+/*= =0A+ * The difference between the following two attributes is that __used = is=0A+ * intended to be used in cases where a reference to an identifier = may be=0A+ * invisible to the compiler (e.g. an inline assembly operand = not listed=0A+ * in the asm()'s operands), preventing the compiler from = eliminating the=0A+ * variable or function.=0A+ * __maybe_unused otoh is = to be used to merely prevent warnings (e.g. when=0A+ * an identifier is = used only inside a preprocessor conditional, yet putting=0A+ * its = declaration/definition inside another conditional would harm code=0A+ * = readability).=0A+ */=0A+#define __used __attribute__((__used__))=0A= +#define __maybe_unused __attribute__((__unused__))=0A =0A-#if __GNUC__ > = 3 || (__GNUC__ =3D=3D 3 && __GNUC_MINOR__ >=3D 4)=0A #define __must_check = __attribute__((warn_unused_result))=0A-#else=0A-#define __must_check=0A-#en= dif=0A =0A-#if __GNUC__ > 3=0A #define offsetof(a,b) __builtin_offsetof(a,b= )=0A-#else=0A-#define offsetof(a,b) ((unsigned long)&(((a *)0)->b))=0A-#end= if=0A =0A /* &a[0] degrades to a pointer: a different type from an array = */=0A #define __must_be_array(a) \=0A--- a/xen/include/xen/init.h=0A+++ = b/xen/include/xen/init.h=0A@@ -114,9 +114,6 @@ extern struct kernel_param = __setup_start=0A __kparam __setup_##_var =3D \=0A { __setup_str= _##_var, OPT_STR, &_var, sizeof(_var) }=0A =0A-/* Make sure obsolete = cmdline params don't break the build. */=0A-#define __setup(_name, _fn) = static void * __attribute_used__ _dummy_##_fn =3D _fn=0A- =0A #endif /* = __ASSEMBLY__ */=0A =0A #ifdef CONFIG_HOTPLUG=0A --=__Part59688DCF.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part59688DCF.0__=--