From: Sam Ravnborg <sam@ravnborg.org>
To: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org,
linux-arch@vger.kernel.org
Cc: Sam Ravnborg <sam@ravnborg.org>
Subject: [PATCH] compiler.h: introduce __section()
Date: Sun, 20 Jan 2008 21:09:02 +0100 [thread overview]
Message-ID: <1200859743-24037-7-git-send-email-sam@ravnborg.org> (raw)
In-Reply-To: <1200859743-24037-6-git-send-email-sam@ravnborg.org>
Add a new helper: __section() that makes a section definition
much shorter and more readable.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
include/linux/compiler.h | 5 +++++
include/linux/init.h | 26 +++++++++++++-------------
2 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index c68b67b..e0114a6 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -175,4 +175,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
#define __cold
#endif
+/* Simple shorthand for a section definition */
+#ifndef __section
+# define __section(S) __attribute__ ((__section__(#S)))
+#endif
+
#endif /* __LINUX_COMPILER_H */
diff --git a/include/linux/init.h b/include/linux/init.h
index 5141381..9980768 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -40,10 +40,10 @@
/* These are for everybody (although not all archs will actually
discard it in modules) */
-#define __init __attribute__ ((__section__ (".init.text"))) __cold
-#define __initdata __attribute__ ((__section__ (".init.data")))
-#define __exitdata __attribute__ ((__section__(".exit.data")))
-#define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit")))
+#define __init __section(.init.text) __cold
+#define __initdata __section(.init.data)
+#define __exitdata __section(.exit.data)
+#define __exit_call __attribute_used__ __section(.exitcall.exit)
/* modpost check for section mismatches during the kernel build.
* A section mismatch happens when there are references from a
@@ -55,14 +55,14 @@
* the init/exit section (code or data) is valid and will teach modpost
* not to issue a warning.
* The markers follow same syntax rules as __init / __initdata. */
-#define __init_refok noinline __attribute__ ((__section__ (".text.init.refok")))
-#define __initdata_refok __attribute__ ((__section__ (".data.init.refok")))
-#define __exit_refok noinline __attribute__ ((__section__ (".exit.text.refok")))
+#define __init_refok noinline __section(.text.init.refok)
+#define __initdata_refok __section(.data.init.refok)
+#define __exit_refok noinline __section(.exit.text.refok)
#ifdef MODULE
-#define __exit __attribute__ ((__section__(".exit.text"))) __cold
+#define __exit __section(.exit.text) __cold
#else
-#define __exit __attribute_used__ __attribute__ ((__section__(".exit.text"))) __cold
+#define __exit __attribute_used__ __section(.exit.text) __cold
#endif
/* For assembly routines */
@@ -142,11 +142,11 @@ void prepare_namespace(void);
#define console_initcall(fn) \
static initcall_t __initcall_##fn \
- __attribute_used__ __attribute__((__section__(".con_initcall.init")))=fn
+ __attribute_used__ __section(.con_initcall.init)=fn
#define security_initcall(fn) \
static initcall_t __initcall_##fn \
- __attribute_used__ __attribute__((__section__(".security_initcall.init"))) = fn
+ __attribute_used__ __section(.security_initcall.init) = fn
struct obs_kernel_param {
const char *str;
@@ -164,7 +164,7 @@ struct obs_kernel_param {
static char __setup_str_##unique_id[] __initdata __aligned(1) = str; \
static struct obs_kernel_param __setup_##unique_id \
__attribute_used__ \
- __attribute__((__section__(".init.setup"))) \
+ __section(.init.setup) \
__attribute__((aligned((sizeof(long))))) \
= { __setup_str_##unique_id, fn, early }
@@ -242,7 +242,7 @@ void __init parse_early_param(void);
#endif
/* Data marked not to be saved by software suspend */
-#define __nosavedata __attribute__ ((__section__ (".data.nosave")))
+#define __nosavedata __section(.data.nosave)
/* This means "can be init if no module support, otherwise module load
may call it." */
--
1.5.4.rc3.14.g44397
next prev parent reply other threads:[~2008-01-20 20:11 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-20 20:05 kbuild: improved Section mismatch detection Sam Ravnborg
2008-01-20 20:08 ` [PATCH] kbuild: fix so modpost can now check any .o file Sam Ravnborg
2008-01-20 20:08 ` [PATCH] kbuild: try harder to find symbol names in modpost Sam Ravnborg
2008-01-20 20:08 ` [PATCH] kbuild: code refactoring " Sam Ravnborg
2008-01-20 20:08 ` [PATCH] kbuild: introduce blacklisting " Sam Ravnborg
2008-01-20 20:09 ` [PATCH] kbuild: check section names consistently " Sam Ravnborg
2008-01-20 20:09 ` [PATCH] all archs: consolidate init and exit sections in vmlinux.lds.h Sam Ravnborg
2008-01-20 20:09 ` Sam Ravnborg [this message]
2008-01-20 20:09 ` [PATCH] Use separate sections for __dev/__cpu/__mem code/data Sam Ravnborg
2008-01-21 7:33 ` Paul Mundt
2008-01-21 9:57 ` Sam Ravnborg
2008-01-21 10:29 ` Andreas Schwab
2008-01-21 10:45 ` Sam Ravnborg
2008-01-21 10:47 ` Sam Ravnborg
2008-01-21 10:52 ` Paul Mundt
2008-01-21 12:06 ` Sam Ravnborg
2008-01-22 0:56 ` Paul Mundt
2008-01-22 3:25 ` Sam Ravnborg
2008-01-22 21:17 ` Greg KH
2008-01-22 21:25 ` Russell King
2008-01-21 1:00 ` [PATCH] kbuild: introduce blacklisting in modpost Rusty Russell
2008-01-21 0:56 ` [PATCH] kbuild: fix so modpost can now check any .o file Rusty Russell
2008-01-21 6:11 ` Sam Ravnborg
2008-01-20 21:33 ` kbuild: improved Section mismatch detection Sam Ravnborg
2008-01-20 22:27 ` Adrian Bunk
2008-01-21 2:51 ` Sam Ravnborg
2008-01-21 20:31 ` Sam Ravnborg
2008-01-21 20:56 ` Adrian Bunk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1200859743-24037-7-git-send-email-sam@ravnborg.org \
--to=sam@ravnborg.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®