From: Christoph Lameter <clameter@sgi.com>
To: linux-mm@kvack.org
Subject: [rfc 06/10] Kbuild: Create a way to create preprocessor constants from C expressions
Date: Fri, 29 Feb 2008 20:08:01 -0800 [thread overview]
Message-ID: <20080301040814.998128520@sgi.com> (raw)
In-Reply-To: 20080301040755.268426038@sgi.com
[-- Attachment #1: kbuild_cpp_export --]
[-- Type: text/plain, Size: 3384 bytes --]
The use of enums create constants that are not available to the preprocessor
when building the kernel (f.e. MAX_NR_ZONES).
Arch code already has a way to export constants calculated to the
preprocessor through the asm-offsets.c file. Generate something
similar for the core kernel through kbuild.
Signed-off-by: Christoph Lameter <clameter@sgi.com>
---
Kbuild | 31 +++++++++++++++++++++++++++++--
include/linux/bounds.h | 10 ++++++++++
kernel/bounds.c | 16 ++++++++++++++++
3 files changed, 55 insertions(+), 2 deletions(-)
Index: linux-2.6/Kbuild
===================================================================
--- linux-2.6.orig/Kbuild 2008-02-29 19:27:40.000000000 -0800
+++ linux-2.6/Kbuild 2008-02-29 19:29:38.000000000 -0800
@@ -9,9 +9,10 @@
#
offsets-file := include/asm-$(SRCARCH)/asm-offsets.h
+bounds := include/linux/bounds.h
-always := $(offsets-file)
-targets := $(offsets-file)
+always := $(offsets-file) $(bounds)
+targets := $(offsets-file) $(bounds)
targets += arch/$(SRCARCH)/kernel/asm-offsets.s
clean-files := $(addprefix $(objtree)/,$(targets))
@@ -39,6 +40,23 @@ define cmd_offsets
echo "#endif" ) > $@
endef
+quiet_cmd_bounds = GEN $@
+define cmd_bounds
+ (set -e; \
+ echo "#ifndef __LINUX_BOUNDS_H__"; \
+ echo "#define __LINUX_BOUNDS_H__"; \
+ echo "/*"; \
+ echo " * DO NOT MODIFY."; \
+ echo " *"; \
+ echo " * This file was generated by Kbuild"; \
+ echo " *"; \
+ echo " */"; \
+ echo ""; \
+ sed -ne $(sed-y) $<; \
+ echo ""; \
+ echo "#endif" ) > $@
+endef
+
# We use internal kbuild rules to avoid the "is up to date" message from make
arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c FORCE
$(Q)mkdir -p $(dir $@)
@@ -48,6 +66,15 @@ $(obj)/$(offsets-file): arch/$(SRCARCH)/
$(Q)mkdir -p $(dir $@)
$(call cmd,offsets)
+# We use internal kbuild rules to avoid the "is up to date" message from make
+kernel/bounds.s: kernel/bounds.c FORCE
+ $(Q)mkdir -p $(dir $@)
+ $(call if_changed_dep,cc_s_c)
+
+$(obj)/$(bounds): kernel/bounds.s Kbuild
+ $(Q)mkdir -p $(dir $@)
+ $(call cmd,bounds)
+
#####
# 2) Check for missing system calls
#
Index: linux-2.6/kernel/bounds.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6/kernel/bounds.c 2008-02-29 19:29:38.000000000 -0800
@@ -0,0 +1,16 @@
+/*
+ * Generate definitions needed by the preprocessor.
+ * This code generates raw asm output which is post-processed
+ * to extract and format the required data.
+ */
+
+#include <linux/mm.h>
+
+#define DEFINE(sym, val) \
+ asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+
+#define BLANK() asm volatile("\n->" : : )
+
+void foo(void)
+{
+}
Index: linux-2.6/include/linux/bounds.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux-2.6/include/linux/bounds.h 2008-02-29 19:29:50.000000000 -0800
@@ -0,0 +1,10 @@
+#ifndef __LINUX_BOUNDS_H__
+#define __LINUX_BOUNDS_H__
+/*
+ * DO NOT MODIFY.
+ *
+ * This file was generated by Kbuild
+ *
+ */
+
+#endif
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2008-03-01 4:08 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-01 4:07 [rfc 00/10] [RFC] Page flags: Saving some, making handling easier etc Christoph Lameter
2008-03-01 4:07 ` [rfc 01/10] Pageflags: Use an enum for the flags Christoph Lameter
2008-03-01 4:07 ` [rfc 02/10] Pageflags: Introduce macros to generate page flag functions Christoph Lameter
2008-03-01 8:22 ` KOSAKI Motohiro
2008-03-03 20:08 ` Christoph Lameter
2008-03-01 4:07 ` [rfc 03/10] Pageflags: Convert to the use of new macros Christoph Lameter
2008-03-01 4:07 ` [rfc 04/10] Pageflags: Eliminate PG_readahead Christoph Lameter
2008-03-01 4:08 ` [rfc 05/10] Sparsemem: Vmemmap does not need section bits Christoph Lameter
2008-03-01 4:33 ` KAMEZAWA Hiroyuki
2008-03-03 20:06 ` Christoph Lameter
2008-03-04 0:18 ` KAMEZAWA Hiroyuki
2008-03-04 0:15 ` Christoph Lameter
2008-03-04 0:20 ` Christoph Lameter
2008-03-04 0:46 ` KAMEZAWA Hiroyuki
2008-03-01 4:08 ` Christoph Lameter [this message]
2008-03-01 4:08 ` [rfc 07/10] Pageflags: Get rid of FLAGS_RESERVED Christoph Lameter
2008-03-01 4:08 ` [rfc 08/10] Export NR_MAX_ZONES to the preprocessor Christoph Lameter
2008-03-01 4:08 ` [rfc 09/10] Get rid of __ZONE_COUNT Christoph Lameter
2008-03-01 4:08 ` [rfc 10/10] Pageflags land grab Christoph Lameter
-- strict thread matches above, loose matches on Subject: below --
2008-03-01 4:05 [rfc 00/10] [RFC] Page flags: Saving some, making handling easier etc Christoph Lameter
2008-03-01 4:05 ` [rfc 06/10] Kbuild: Create a way to create preprocessor constants from C expressions Christoph Lameter
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=20080301040814.998128520@sgi.com \
--to=clameter@sgi.com \
--cc=linux-mm@kvack.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.