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 Signed-off-by: Christoph Lameter --- 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 + +#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 from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/