From: Christoph Lameter <clameter@sgi.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, Sam Ravnborg <sam@ravnborg.org>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: apw@shadowen.org
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: linux-mm@kvack.org
Subject: [rfc 07/10] Kbuild: Create a way to create preprocessor constants from C expressions
Date: Mon, 03 Mar 2008 16:04:59 -0800 [thread overview]
Message-ID: <20080304000733.688496611@sgi.com> (raw)
In-Reply-To: 20080304000452.514878384@sgi.com
[-- Attachment #1: kbuild_cpp_export --]
[-- Type: text/plain, Size: 3194 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.
Cc: Sam Ravnborg <sam@ravnborg.org>
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
--
WARNING: multiple messages have this Message-ID (diff)
From: Christoph Lameter <clameter@sgi.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, Sam Ravnborg <sam@ravnborg.org>,
Mel Gorman <mel@csn.ul.ie>,
apw@shadowen.org,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Rik van Riel <riel@redhat.com>,
linux-mm@kvack.org
Subject: [rfc 07/10] Kbuild: Create a way to create preprocessor constants from C expressions
Date: Mon, 03 Mar 2008 16:04:59 -0800 [thread overview]
Message-ID: <20080304000733.688496611@sgi.com> (raw)
In-Reply-To: 20080304000452.514878384@sgi.com
[-- Attachment #1: kbuild_cpp_export --]
[-- Type: text/plain, Size: 3194 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.
Cc: Sam Ravnborg <sam@ravnborg.org>
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
--
next prev parent reply other threads:[~2008-03-04 0:11 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-04 0:04 [rfc 00/10] [Patch] Page flags: Cleanup, reorg and introduce 5 new flags Christoph Lameter
2008-03-04 0:04 ` Christoph Lameter
2008-03-04 0:04 ` [rfc 01/10] Pageflags: Use an enum for the flags Christoph Lameter
2008-03-04 0:04 ` Christoph Lameter
2008-03-04 0:04 ` [rfc 02/10] Pageflags: Introduce macros to generate page flag functions Christoph Lameter
2008-03-04 0:04 ` Christoph Lameter
2008-03-04 0:04 ` [rfc 03/10] Pageflags: Convert to the use of new macros Christoph Lameter
2008-03-04 0:04 ` Christoph Lameter
2008-03-04 0:04 ` [rfc 04/10] Pageflags: Use proper page flag functions in Xen Christoph Lameter
2008-03-04 0:04 ` Christoph Lameter
2008-03-04 0:04 ` [rfc 05/10] Pageflags: Eliminate PG_xxx aliases Christoph Lameter
2008-03-04 0:04 ` Christoph Lameter
2008-03-04 0:04 ` [rfc 06/10] Sparsemem: Vmemmap does not need section bits Christoph Lameter
2008-03-04 0:04 ` Christoph Lameter
2008-03-04 0:04 ` Christoph Lameter [this message]
2008-03-04 0:04 ` [rfc 07/10] Kbuild: Create a way to create preprocessor constants from C expressions Christoph Lameter
2008-03-04 0:05 ` [rfc 08/10] Pageflags: Get rid of FLAGS_RESERVED Christoph Lameter
2008-03-04 0:05 ` Christoph Lameter
2008-03-04 0:05 ` [rfc 09/10] Get rid of __ZONE_COUNT Christoph Lameter
2008-03-04 0:05 ` Christoph Lameter
2008-03-04 0:05 ` [rfc 10/10] Pageflags: Land grab Christoph Lameter
2008-03-04 0:05 ` Christoph Lameter
2008-03-04 1:27 ` Andi Kleen
2008-03-04 5:38 ` 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=20080304000733.688496611@sgi.com \
--to=clameter@sgi.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sam@ravnborg.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.