xen: define __section() and friends and use them for section annotations.
authorTim Deegan <tim@xen.org>
Wed, 11 Apr 2012 12:10:33 +0000 (13:10 +0100)
committerTim Deegan <tim@xen.org>
Wed, 11 Apr 2012 12:10:33 +0000 (13:10 +0100)
By itself this is just code-tidying, but it's also useful for the
following patch, which will adjust __section() for clang compiles.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
xen/include/asm-arm/cache.h
xen/include/asm-arm/percpu.h
xen/include/asm-x86/cache.h
xen/include/asm-x86/percpu.h
xen/include/xen/compiler.h
xen/include/xen/init.h
xen/include/xen/spinlock.h
xen/include/xsm/xsm.h

index 41b62910e774de13e1f274bef07d0d28ca3448e2..9f331784c54f5d845bb737af475491faba477d63 100644 (file)
@@ -7,7 +7,7 @@
 #define L1_CACHE_SHIFT  (CONFIG_ARM_L1_CACHE_SHIFT)
 #define L1_CACHE_BYTES  (1 << L1_CACHE_SHIFT)
 
-#define __read_mostly __attribute__((__section__(".data.read_mostly")))
+#define __read_mostly __section(".data.read_mostly")
 
 #endif
 /*
index 1c1f6159adeb6f6c531cdceb3ba170c9bd5dbe76..ab272921674e85c257646706258036a0ffd8282a 100644 (file)
@@ -8,7 +8,7 @@ void percpu_init_areas(void);
 
 /* Separate out the type, so (int[3], foo) works. */
 #define __DEFINE_PER_CPU(type, name, suffix)                    \
-    __attribute__((__section__(".bss.percpu" #suffix)))         \
+    __section(".bss.percpu" #suffix)                            \
     __typeof__(type) per_cpu_##name
 
 
index f5667a14fa89e2e414bcb970046a449708f42bd0..f4a08e786f079d2e16884e248fe859ea5e6e4aea 100644 (file)
@@ -10,6 +10,6 @@
 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
 #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
 
-#define __read_mostly __attribute__((__section__(".data.read_mostly")))
+#define __read_mostly __section(".data.read_mostly")
 
 #endif
index e6faa8ce0772a5b2ad1800b705eb2f810a2b6d30..604ff0d7b0ce4be8026a4a6f8863c7cab0ecbf9b 100644 (file)
@@ -9,7 +9,7 @@ void percpu_init_areas(void);
 
 /* Separate out the type, so (int[3], foo) works. */
 #define __DEFINE_PER_CPU(type, name, suffix)                    \
-    __attribute__((__section__(".bss.percpu" #suffix)))         \
+    __section(".bss.percpu" #suffix)                            \
     __typeof__(type) per_cpu_##name
 
 /* var is in discarded region: offset to particular copy we want */
index ec26dded6e1fea25074d883535925d65c2e2c815..04f84ec393e0481143dc5217fac73e86167f87c1 100644 (file)
 #define always_inline __inline__ __attribute__ ((always_inline))
 #define noinline      __attribute__((noinline))
 
+#define __section(s)      __attribute__((__section__(s)))
+#define __used_section(s) __attribute_used__ __attribute__((__section__(s)))
+#define __text_section(s) __attribute__((__section__(s)))
+
 #ifdef INIT_SECTIONS_ONLY
 /*
  * For sources indicated to have only init code, make sure even
index f7a7dc4d9d57da43b2dc4f0f54f6181fd3271b01..995bbac44537e52aa5317b9692b28a4700a95549 100644 (file)
@@ -7,20 +7,13 @@
  * Mark functions and data as being only used at initialization
  * or exit time.
  */
-#define __init       \
-    __attribute__ ((__section__ (".init.text")))
-#define __exit       \
-    __attribute_used__ __attribute__ ((__section__(".exit.text")))
-#define __initdata   \
-    __attribute__ ((__section__ (".init.data")))
-#define __exitdata   \
-    __attribute_used__ __attribute__ ((__section__ (".exit.data")))
-#define __initsetup  \
-    __attribute_used__ __attribute__ ((__section__ (".init.setup")))
-#define __init_call(lvl)  \
-    __attribute_used__ __attribute__ ((__section__ (".initcall" lvl ".init")))
-#define __exit_call  \
-    __attribute_used__ __attribute__ ((__section__ (".exitcall.exit")))
+#define __init            __text_section(".init.text")
+#define __exit            __text_section(".exit.text")
+#define __initdata        __section(".init.data")
+#define __exitdata        __used_section(".exit.data")
+#define __initsetup       __used_section(".init.setup")
+#define __init_call(lvl)  __used_section(".initcall" lvl ".init")
+#define __exit_call       __used_section(".exitcall.exit")
 
 /* These macros are used to mark some functions or 
  * initialized data (doesn't apply to uninitialized data)
@@ -95,7 +88,7 @@ struct kernel_param {
 extern struct kernel_param __setup_start, __setup_end;
 
 #define __setup_str static __initdata __attribute__((__aligned__(1))) char
-#define __kparam static __attribute_used__ __initsetup struct kernel_param
+#define __kparam static __initsetup struct kernel_param
 
 #define custom_param(_name, _var) \
     __setup_str __setup_str_##_var[] = _name; \
index 2df44527096ce8613c6918dd33e87b437ff825ac..8133fe0934e8d461dc0ef15860f5e61f33e18319 100644 (file)
@@ -77,8 +77,8 @@ struct lock_profile_qhead {
 
 #define _LOCK_PROFILE(name) { 0, #name, &name, 0, 0, 0, 0, 0 }
 #define _LOCK_PROFILE_PTR(name)                                               \
-    static struct lock_profile *__lock_profile_##name __attribute_used__      \
-    __attribute__ ((__section__(".lockprofile.data"))) =                      \
+    static struct lock_profile *__lock_profile_##name                         \
+    __used_section(".lockprofile.data") =                                     \
     &__lock_profile_data_##name
 #define _SPIN_LOCK_UNLOCKED(x) { _RAW_SPIN_LOCK_UNLOCKED, 0xfffu, 0,          \
                                  _LOCK_DEBUG, x }
index f081d5b7887acf3f3386c9e64b110229dae47f2a..bef79df8cd826f383c2338d3bd571c6fc948862c 100644 (file)
@@ -44,7 +44,7 @@ extern xsm_initcall_t __xsm_initcall_start[], __xsm_initcall_end[];
 
 #define xsm_initcall(fn) \
     static xsm_initcall_t __initcall_##fn \
-    __attribute_used__ __attribute__((__section__(".xsm_initcall.init"))) = fn
+    __used_section(".xsm_initcall.init") = fn
 
 struct xsm_operations {
     void (*security_domaininfo) (struct domain *d,