Re: [pp] kbuild: asm-offsets generalized

2007-04-01 Thread Sam Ravnborg
On Sun, Apr 01, 2007 at 11:08:03PM +0200, Oleg Verych wrote:
> On Sun, Apr 01, 2007 at 10:42:03PM +0200, Sam Ravnborg wrote:
> > On Fri, Feb 16, 2007 at 04:59:29PM +0100, Oleg Verych wrote:
> []
> > > [patch proposition] kbuild: asm-offsets generalized
> []
> > >  * (hopefully) more readable sed scripts,
> > > 
> > >  * top Kbuild may be updated...
> []
> > 
> > Can I ask you to provide a complete patch that replaces the current
> > asm-offset stuff with your more readable script version.
>  
> OK, unless this is 1st April joke ;)
> 
> > >  * scripts/mkCconstants:
> > >- asm-offsets magic demystified, generalized,
> 
> > Name the script: mkasm-offset.sh to make a direct connection to 
> > the resulting .h file name.
>  
> OK, nice name.
> 
> > > 
> > >  * file needs `chmod u+x`, i don't know, how it's done in patch(1).
> 
> BTW, i'll look at git-diff/git-apply for doing that, as was noted by Linus.
When patch passes me I can take care - so do not worry.
But tell me to do so if I should forget in the meantime.

PS. On vacation for a week from tomorrow so take your time.

Sam
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [pp] kbuild: asm-offsets generalized

2007-04-01 Thread Oleg Verych
On Sun, Apr 01, 2007 at 10:42:03PM +0200, Sam Ravnborg wrote:
> On Fri, Feb 16, 2007 at 04:59:29PM +0100, Oleg Verych wrote:
[]
> > [patch proposition] kbuild: asm-offsets generalized
[]
> >  * (hopefully) more readable sed scripts,
> > 
> >  * top Kbuild may be updated...
[]
> 
> Can I ask you to provide a complete patch that replaces the current
> asm-offset stuff with your more readable script version.
 
OK, unless this is 1st April joke ;)

> >  * scripts/mkCconstants:
> >- asm-offsets magic demystified, generalized,

> Name the script: mkasm-offset.sh to make a direct connection to 
> the resulting .h file name.
 
OK, nice name.

> > 
> >  * file needs `chmod u+x`, i don't know, how it's done in patch(1).

BTW, i'll look at git-diff/git-apply for doing that, as was noted by Linus.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [pp] kbuild: asm-offsets generalized

2007-04-01 Thread Sam Ravnborg
On Fri, Feb 16, 2007 at 04:59:29PM +0100, Oleg Verych wrote:
> > > 
> > > Proposition will follow.
> > > 
> > []
> > 
> > [patch proposition] kbuild: lguest with private asm-offsets
> [] 
> >  * needs "asm-offsets magic demystified, generalized".
> [] 
> 
> [patch proposition] kbuild: asm-offsets generalized
> 
>  * scripts/mkCconstants:
>- asm-offsets magic demystified, generalized,
> 
>  * (hopefully) more readable sed scripts,
> 
>  * top Kbuild may be updated...
> 
>  * file needs `chmod u+x`, i don't know, how it's done in patch(1).

Can I ask you to provide a complete patch that replaces the current
asm-offset stuff with your more readable script version.

Name the script: mkasm-offset.sh to make a direct connection to 
the resulting .h file name.

Thanks,

Sam


> 
> pp-by: Oleg Verych
> ---
>  scripts/mkCconstants   |  50 
> +
>  1 files changed, 50 insertions(+), 0 deletions(-)
> 
> Index: linux-2.6.20/scripts/mkCconstants
> ===
> --- /dev/null 1970-01-01 00:00:00.0 +
> +++ linux-2.6.20/scripts/mkCconstants 2007-02-16 15:33:51.696900750 +0100
> @@ -0,0 +1,50 @@
> +#!/bin/sh
> +
> +# Input file, where values of interest are stored is produced by
> +# `cmd_cc_s_c'. It yields calculation of constants, needed in
> +# assembler modules. Output is a suitable header file.
> +#
> +# $1 - input filename;
> +# $2 - output filename;
> +# $3 - header file format: "normal" (default), "mips".
> +
> +set -e
> +
> +[ -z "$1" ] || [ -z "$2" ] && exit 1
> +
> +case $3 in
> +mips)
> + SED_SCRIPT='
> +/^@@@/{
> +s/^@@@//;
> +s/ \#.*\$//;
> +p;
> +}'
> + ;;
> +normal | *)
> + SED_SCRIPT='
> +/^->/{
> +s:^->\([^ ]*\) [\$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:;
> +s:->::;
> +p;
> +}'
> + ;;
> +esac
> +
> +cat << "EOF"  > $2
> +#ifndef __ASM_OFFSETS_H__
> +#define __ASM_OFFSETS_H__
> +
> +/*
> + * This file was generated by scripts/mkCconstants
> + */
> +
> +EOF
> +
> +sed -ne "$SED_SCRIPT" $1 >> $2
> +
> +cat << "EOF" >> $2
> +
> +#endif
> +
> +EOF
> 
> --
> -o--=O`C  info emacs : not found
>  #oo'L O  info make  : not found
> <___=E M  man gcc: not found
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [pp] kbuild: asm-offsets generalized

2007-04-01 Thread Sam Ravnborg
On Fri, Feb 16, 2007 at 04:59:29PM +0100, Oleg Verych wrote:
   
   Proposition will follow.
   
  []
  
  [patch proposition] kbuild: lguest with private asm-offsets
 [] 
   * needs asm-offsets magic demystified, generalized.
 [] 
 
 [patch proposition] kbuild: asm-offsets generalized
 
  * scripts/mkCconstants:
- asm-offsets magic demystified, generalized,
 
  * (hopefully) more readable sed scripts,
 
  * top Kbuild may be updated...
 
  * file needs `chmod u+x`, i don't know, how it's done in patch(1).

Can I ask you to provide a complete patch that replaces the current
asm-offset stuff with your more readable script version.

Name the script: mkasm-offset.sh to make a direct connection to 
the resulting .h file name.

Thanks,

Sam


 
 pp-by: Oleg Verych
 ---
  scripts/mkCconstants   |  50 
 +
  1 files changed, 50 insertions(+), 0 deletions(-)
 
 Index: linux-2.6.20/scripts/mkCconstants
 ===
 --- /dev/null 1970-01-01 00:00:00.0 +
 +++ linux-2.6.20/scripts/mkCconstants 2007-02-16 15:33:51.696900750 +0100
 @@ -0,0 +1,50 @@
 +#!/bin/sh
 +
 +# Input file, where values of interest are stored is produced by
 +# `cmd_cc_s_c'. It yields calculation of constants, needed in
 +# assembler modules. Output is a suitable header file.
 +#
 +# $1 - input filename;
 +# $2 - output filename;
 +# $3 - header file format: normal (default), mips.
 +
 +set -e
 +
 +[ -z $1 ] || [ -z $2 ]  exit 1
 +
 +case $3 in
 +mips)
 + SED_SCRIPT='
 +/^@@@/{
 +s/^@@@//;
 +s/ \#.*\$//;
 +p;
 +}'
 + ;;
 +normal | *)
 + SED_SCRIPT='
 +/^-/{
 +s:^-\([^ ]*\) [\$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:;
 +s:-::;
 +p;
 +}'
 + ;;
 +esac
 +
 +cat  EOF   $2
 +#ifndef __ASM_OFFSETS_H__
 +#define __ASM_OFFSETS_H__
 +
 +/*
 + * This file was generated by scripts/mkCconstants
 + */
 +
 +EOF
 +
 +sed -ne $SED_SCRIPT $1  $2
 +
 +cat  EOF  $2
 +
 +#endif
 +
 +EOF
 
 --
 -o--=O`C  info emacs : not found
  #oo'L O  info make  : not found
 ___=E M  man gcc: not found
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [pp] kbuild: asm-offsets generalized

2007-04-01 Thread Oleg Verych
On Sun, Apr 01, 2007 at 10:42:03PM +0200, Sam Ravnborg wrote:
 On Fri, Feb 16, 2007 at 04:59:29PM +0100, Oleg Verych wrote:
[]
  [patch proposition] kbuild: asm-offsets generalized
[]
   * (hopefully) more readable sed scripts,
  
   * top Kbuild may be updated...
[]
 
 Can I ask you to provide a complete patch that replaces the current
 asm-offset stuff with your more readable script version.
 
OK, unless this is 1st April joke ;)

   * scripts/mkCconstants:
 - asm-offsets magic demystified, generalized,

 Name the script: mkasm-offset.sh to make a direct connection to 
 the resulting .h file name.
 
OK, nice name.

  
   * file needs `chmod u+x`, i don't know, how it's done in patch(1).

BTW, i'll look at git-diff/git-apply for doing that, as was noted by Linus.

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [pp] kbuild: asm-offsets generalized

2007-04-01 Thread Sam Ravnborg
On Sun, Apr 01, 2007 at 11:08:03PM +0200, Oleg Verych wrote:
 On Sun, Apr 01, 2007 at 10:42:03PM +0200, Sam Ravnborg wrote:
  On Fri, Feb 16, 2007 at 04:59:29PM +0100, Oleg Verych wrote:
 []
   [patch proposition] kbuild: asm-offsets generalized
 []
* (hopefully) more readable sed scripts,
   
* top Kbuild may be updated...
 []
  
  Can I ask you to provide a complete patch that replaces the current
  asm-offset stuff with your more readable script version.
  
 OK, unless this is 1st April joke ;)
 
* scripts/mkCconstants:
  - asm-offsets magic demystified, generalized,
 
  Name the script: mkasm-offset.sh to make a direct connection to 
  the resulting .h file name.
  
 OK, nice name.
 
   
* file needs `chmod u+x`, i don't know, how it's done in patch(1).
 
 BTW, i'll look at git-diff/git-apply for doing that, as was noted by Linus.
When patch passes me I can take care - so do not worry.
But tell me to do so if I should forget in the meantime.

PS. On vacation for a week from tomorrow so take your time.

Sam
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [pp] kbuild: asm-offsets generalized

2007-02-16 Thread Oleg Verych
On Sat, Feb 17, 2007 at 03:43:49PM +1100, Rusty Russell wrote:
> On Fri, 2007-02-16 at 22:56 +0100, Oleg Verych wrote:
> > Hallo.
> 
> lguest parts look good though!

Thanks.

Well, then what about my way of doing generalization?

I.e. one-file shell script-let, rather many indistinguishable GNU make
files throughout source tree?

Sam's approach also offers using of CONGIG* options. But this has two
issues (for me, of course):

* lguest is in i386 arch, *top* Kbuild doing this for specific ARCH
(include/asm/);

* lguest wants to have private for-asm constants generated, unless CONFIG
is set, kbuild never will reach that directory.

Finally (my favorite). While i was told, that i'm doing more obfusticated
solutions, i doubt i did now: script-let makes magic more readable, and
GNU make's complications, like `$$' and various whitespace issues, do not
influence.

One thing is, that

+quiet_cmd_offsets = GEN $@
+  cmd_offsets = $(srctree)/scripts/mkCconstants $< $@
+

can be moved in Kbuild.include with CONFIG* upgrade:

sed-$(CONFIG_MIPS) = mips

  cmd_offsets = $(srctree)/scripts/mkCconstants $< $@ $(sed-y)


Kind regards!
--
-o--=O`C  info emacs : not found
 #oo'L O  info make  : not found
<___=E M  man gcc: not found
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [pp] kbuild: asm-offsets generalized

2007-02-16 Thread Rusty Russell
On Fri, 2007-02-16 at 22:56 +0100, Oleg Verych wrote:
> Hallo.

lguest parts look good though!

Rusty.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [pp] kbuild: asm-offsets generalized

2007-02-16 Thread Oleg Verych
Hallo.

On Fri, Feb 16, 2007 at 07:56:35PM +0100, Sam Ravnborg wrote:
> On Fri, Feb 16, 2007 at 04:59:29PM +0100, Oleg Verych wrote:
> > > > 
> > > > Proposition will follow.
> > > > 
> > > []
> > > 
> > > [patch proposition] kbuild: lguest with private asm-offsets
> > [] 
> > >  * needs "asm-offsets magic demystified, generalized".
> > [] 
> 
> To make asm-offset generic I had in mind something like the
> following.

Then i misunderstood, what you mean, sorry.

> It uses the currect functionality, and allows for architecture override
> as needed - but default not used. And architecture override is kept in a
> architecture specific location.
> 
>   Sam
> 
> commit df95bb04b04ff2f64805dfa8459099ffe469c8a5
> Author: Sam Ravnborg <[EMAIL PROTECTED]>
> Date:   Fri Feb 16 19:51:29 2007 +0100
> 
> kbuild: Make asm-offset generic
> 
> Signed-off-by: Sam Ravnborg <[EMAIL PROTECTED]>
> 
> diff --git a/include/asm-generic/asm-offset b/include/asm-generic/asm-offset
> new file mode 100644
> index 000..5e5629e
> --- /dev/null
> +++ b/include/asm-generic/asm-offset
> @@ -0,0 +1,30 @@
> +#
> +# Support generating constant useable from assembler but defined on C-level
> +#
> +# See usage in top-level Kbuild file
> +
> +# Default sed regexp - multiline due to syntax constraints
> +define sed-y
> + "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; 
> s:->::; p;}"
> +endef
> +
> +# let architectures override the sed expression as needed
> +-include include/asm/asm-offset
> +
> +quiet_cmd_offsets = GEN $@
> +define cmd_offsets
> + (set -e; \
> +  echo "#ifndef __ASM_OFFSETS_H__"; \
> +  echo "#define __ASM_OFFSETS_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
> +
> diff --git a/include/asm-mips/asm-offset b/include/asm-mips/asm-offset
> new file mode 100644
> index 000..b2eb959
> --- /dev/null
> +++ b/include/asm-mips/asm-offset
> @@ -0,0 +1,4 @@
> +# Override default sed for MIPS when generating asm-offset
> +sed-$(CONFIG_MIPS) := "/^@@@/{s/^@@@//; s/ \#.*\$$//; p;}"
> +
> +
> diff --git a/Kbuild b/Kbuild
> index 0451f69..0a32f5f 100644
> --- a/Kbuild
> +++ b/Kbuild
> @@ -1,5 +1,8 @@
>  #
>  # Kbuild for top-level directory of the kernel
> +
> +
> +
>  # This file takes care of the following:
>  # 1) Generate asm-offsets.h
>  
> @@ -7,36 +10,14 @@ #
>  # 1) Generate asm-offsets.h
>  #
>  
> +include include/asm-generic/asm-offset
> +
>  offsets-file := include/asm-$(ARCH)/asm-offsets.h
>  
>  always  := $(offsets-file)
>  targets := $(offsets-file)
>  targets += arch/$(ARCH)/kernel/asm-offsets.s
>  
> -# Default sed regexp - multiline due to syntax constraints
> -define sed-y
> - "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; 
> s:->::; p;}"
> -endef
> -# Override default regexp for specific architectures
> -sed-$(CONFIG_MIPS) := "/^@@@/{s/^@@@//; s/ \#.*\$$//; p;}"
> -
> -quiet_cmd_offsets = GEN $@
> -define cmd_offsets
> - (set -e; \
> -  echo "#ifndef __ASM_OFFSETS_H__"; \
> -  echo "#define __ASM_OFFSETS_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/$(ARCH)/kernel/asm-offsets.s: arch/$(ARCH)/kernel/asm-offsets.c FORCE
>   $(Q)mkdir -p $(dir $@)

Thanks.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [pp] kbuild: asm-offsets generalized

2007-02-16 Thread Sam Ravnborg
On Fri, Feb 16, 2007 at 04:59:29PM +0100, Oleg Verych wrote:
> > > 
> > > Proposition will follow.
> > > 
> > []
> > 
> > [patch proposition] kbuild: lguest with private asm-offsets
> [] 
> >  * needs "asm-offsets magic demystified, generalized".
> [] 

To make asm-offset generic I had in mind something like the
following.
It uses the currect functionality, and allows for architecture override
as needed - but default not used. And architecture override is kept in a
architecture specific location.

Sam

commit df95bb04b04ff2f64805dfa8459099ffe469c8a5
Author: Sam Ravnborg <[EMAIL PROTECTED]>
Date:   Fri Feb 16 19:51:29 2007 +0100

kbuild: Make asm-offset generic

Signed-off-by: Sam Ravnborg <[EMAIL PROTECTED]>

diff --git a/include/asm-generic/asm-offset b/include/asm-generic/asm-offset
new file mode 100644
index 000..5e5629e
--- /dev/null
+++ b/include/asm-generic/asm-offset
@@ -0,0 +1,30 @@
+#
+# Support generating constant useable from assembler but defined on C-level
+#
+# See usage in top-level Kbuild file
+
+# Default sed regexp - multiline due to syntax constraints
+define sed-y
+   "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; 
s:->::; p;}"
+endef
+
+# let architectures override the sed expression as needed
+-include include/asm/asm-offset
+
+quiet_cmd_offsets = GEN $@
+define cmd_offsets
+   (set -e; \
+echo "#ifndef __ASM_OFFSETS_H__"; \
+echo "#define __ASM_OFFSETS_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
+
diff --git a/include/asm-mips/asm-offset b/include/asm-mips/asm-offset
new file mode 100644
index 000..b2eb959
--- /dev/null
+++ b/include/asm-mips/asm-offset
@@ -0,0 +1,4 @@
+# Override default sed for MIPS when generating asm-offset
+sed-$(CONFIG_MIPS) := "/^@@@/{s/^@@@//; s/ \#.*\$$//; p;}"
+
+
diff --git a/Kbuild b/Kbuild
index 0451f69..0a32f5f 100644
--- a/Kbuild
+++ b/Kbuild
@@ -1,5 +1,8 @@
 #
 # Kbuild for top-level directory of the kernel
+
+
+
 # This file takes care of the following:
 # 1) Generate asm-offsets.h
 
@@ -7,36 +10,14 @@ #
 # 1) Generate asm-offsets.h
 #
 
+include include/asm-generic/asm-offset
+
 offsets-file := include/asm-$(ARCH)/asm-offsets.h
 
 always  := $(offsets-file)
 targets := $(offsets-file)
 targets += arch/$(ARCH)/kernel/asm-offsets.s
 
-# Default sed regexp - multiline due to syntax constraints
-define sed-y
-   "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; 
s:->::; p;}"
-endef
-# Override default regexp for specific architectures
-sed-$(CONFIG_MIPS) := "/^@@@/{s/^@@@//; s/ \#.*\$$//; p;}"
-
-quiet_cmd_offsets = GEN $@
-define cmd_offsets
-   (set -e; \
-echo "#ifndef __ASM_OFFSETS_H__"; \
-echo "#define __ASM_OFFSETS_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/$(ARCH)/kernel/asm-offsets.s: arch/$(ARCH)/kernel/asm-offsets.c FORCE
$(Q)mkdir -p $(dir $@)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[pp] kbuild: asm-offsets generalized

2007-02-16 Thread Oleg Verych
> > 
> > Proposition will follow.
> > 
> []
> 
> [patch proposition] kbuild: lguest with private asm-offsets
[] 
>  * needs "asm-offsets magic demystified, generalized".
[] 

[patch proposition] kbuild: asm-offsets generalized

 * scripts/mkCconstants:
   - asm-offsets magic demystified, generalized,

 * (hopefully) more readable sed scripts,

 * top Kbuild may be updated...

 * file needs `chmod u+x`, i don't know, how it's done in patch(1).

pp-by: Oleg Verych
---
 scripts/mkCconstants   |  50 +
 1 files changed, 50 insertions(+), 0 deletions(-)

Index: linux-2.6.20/scripts/mkCconstants
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ linux-2.6.20/scripts/mkCconstants   2007-02-16 15:33:51.696900750 +0100
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# Input file, where values of interest are stored is produced by
+# `cmd_cc_s_c'. It yields calculation of constants, needed in
+# assembler modules. Output is a suitable header file.
+#
+# $1 - input filename;
+# $2 - output filename;
+# $3 - header file format: "normal" (default), "mips".
+
+set -e
+
+[ -z "$1" ] || [ -z "$2" ] && exit 1
+
+case $3 in
+mips)
+   SED_SCRIPT='
+/^@@@/{
+s/^@@@//;
+s/ \#.*\$//;
+p;
+}'
+   ;;
+normal | *)
+   SED_SCRIPT='
+/^->/{
+s:^->\([^ ]*\) [\$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:;
+s:->::;
+p;
+}'
+   ;;
+esac
+
+cat << "EOF"  > $2
+#ifndef __ASM_OFFSETS_H__
+#define __ASM_OFFSETS_H__
+
+/*
+ * This file was generated by scripts/mkCconstants
+ */
+
+EOF
+
+sed -ne "$SED_SCRIPT" $1 >> $2
+
+cat << "EOF" >> $2
+
+#endif
+
+EOF

--
-o--=O`C  info emacs : not found
 #oo'L O  info make  : not found
<___=E M  man gcc: not found
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[pp] kbuild: asm-offsets generalized

2007-02-16 Thread Oleg Verych
  
  Proposition will follow.
  
 []
 
 [patch proposition] kbuild: lguest with private asm-offsets
[] 
  * needs asm-offsets magic demystified, generalized.
[] 

[patch proposition] kbuild: asm-offsets generalized

 * scripts/mkCconstants:
   - asm-offsets magic demystified, generalized,

 * (hopefully) more readable sed scripts,

 * top Kbuild may be updated...

 * file needs `chmod u+x`, i don't know, how it's done in patch(1).

pp-by: Oleg Verych
---
 scripts/mkCconstants   |  50 +
 1 files changed, 50 insertions(+), 0 deletions(-)

Index: linux-2.6.20/scripts/mkCconstants
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ linux-2.6.20/scripts/mkCconstants   2007-02-16 15:33:51.696900750 +0100
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# Input file, where values of interest are stored is produced by
+# `cmd_cc_s_c'. It yields calculation of constants, needed in
+# assembler modules. Output is a suitable header file.
+#
+# $1 - input filename;
+# $2 - output filename;
+# $3 - header file format: normal (default), mips.
+
+set -e
+
+[ -z $1 ] || [ -z $2 ]  exit 1
+
+case $3 in
+mips)
+   SED_SCRIPT='
+/^@@@/{
+s/^@@@//;
+s/ \#.*\$//;
+p;
+}'
+   ;;
+normal | *)
+   SED_SCRIPT='
+/^-/{
+s:^-\([^ ]*\) [\$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:;
+s:-::;
+p;
+}'
+   ;;
+esac
+
+cat  EOF   $2
+#ifndef __ASM_OFFSETS_H__
+#define __ASM_OFFSETS_H__
+
+/*
+ * This file was generated by scripts/mkCconstants
+ */
+
+EOF
+
+sed -ne $SED_SCRIPT $1  $2
+
+cat  EOF  $2
+
+#endif
+
+EOF

--
-o--=O`C  info emacs : not found
 #oo'L O  info make  : not found
___=E M  man gcc: not found
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [pp] kbuild: asm-offsets generalized

2007-02-16 Thread Sam Ravnborg
On Fri, Feb 16, 2007 at 04:59:29PM +0100, Oleg Verych wrote:
   
   Proposition will follow.
   
  []
  
  [patch proposition] kbuild: lguest with private asm-offsets
 [] 
   * needs asm-offsets magic demystified, generalized.
 [] 

To make asm-offset generic I had in mind something like the
following.
It uses the currect functionality, and allows for architecture override
as needed - but default not used. And architecture override is kept in a
architecture specific location.

Sam

commit df95bb04b04ff2f64805dfa8459099ffe469c8a5
Author: Sam Ravnborg [EMAIL PROTECTED]
Date:   Fri Feb 16 19:51:29 2007 +0100

kbuild: Make asm-offset generic

Signed-off-by: Sam Ravnborg [EMAIL PROTECTED]

diff --git a/include/asm-generic/asm-offset b/include/asm-generic/asm-offset
new file mode 100644
index 000..5e5629e
--- /dev/null
+++ b/include/asm-generic/asm-offset
@@ -0,0 +1,30 @@
+#
+# Support generating constant useable from assembler but defined on C-level
+#
+# See usage in top-level Kbuild file
+
+# Default sed regexp - multiline due to syntax constraints
+define sed-y
+   /^-/{s:^-\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; 
s:-::; p;}
+endef
+
+# let architectures override the sed expression as needed
+-include include/asm/asm-offset
+
+quiet_cmd_offsets = GEN $@
+define cmd_offsets
+   (set -e; \
+echo #ifndef __ASM_OFFSETS_H__; \
+echo #define __ASM_OFFSETS_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
+
diff --git a/include/asm-mips/asm-offset b/include/asm-mips/asm-offset
new file mode 100644
index 000..b2eb959
--- /dev/null
+++ b/include/asm-mips/asm-offset
@@ -0,0 +1,4 @@
+# Override default sed for MIPS when generating asm-offset
+sed-$(CONFIG_MIPS) := /^@@@/{s/^@@@//; s/ \#.*\$$//; p;}
+
+
diff --git a/Kbuild b/Kbuild
index 0451f69..0a32f5f 100644
--- a/Kbuild
+++ b/Kbuild
@@ -1,5 +1,8 @@
 #
 # Kbuild for top-level directory of the kernel
+
+
+
 # This file takes care of the following:
 # 1) Generate asm-offsets.h
 
@@ -7,36 +10,14 @@ #
 # 1) Generate asm-offsets.h
 #
 
+include include/asm-generic/asm-offset
+
 offsets-file := include/asm-$(ARCH)/asm-offsets.h
 
 always  := $(offsets-file)
 targets := $(offsets-file)
 targets += arch/$(ARCH)/kernel/asm-offsets.s
 
-# Default sed regexp - multiline due to syntax constraints
-define sed-y
-   /^-/{s:^-\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; 
s:-::; p;}
-endef
-# Override default regexp for specific architectures
-sed-$(CONFIG_MIPS) := /^@@@/{s/^@@@//; s/ \#.*\$$//; p;}
-
-quiet_cmd_offsets = GEN $@
-define cmd_offsets
-   (set -e; \
-echo #ifndef __ASM_OFFSETS_H__; \
-echo #define __ASM_OFFSETS_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/$(ARCH)/kernel/asm-offsets.s: arch/$(ARCH)/kernel/asm-offsets.c FORCE
$(Q)mkdir -p $(dir $@)
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [pp] kbuild: asm-offsets generalized

2007-02-16 Thread Oleg Verych
Hallo.

On Fri, Feb 16, 2007 at 07:56:35PM +0100, Sam Ravnborg wrote:
 On Fri, Feb 16, 2007 at 04:59:29PM +0100, Oleg Verych wrote:

Proposition will follow.

   []
   
   [patch proposition] kbuild: lguest with private asm-offsets
  [] 
* needs asm-offsets magic demystified, generalized.
  [] 
 
 To make asm-offset generic I had in mind something like the
 following.

Then i misunderstood, what you mean, sorry.

 It uses the currect functionality, and allows for architecture override
 as needed - but default not used. And architecture override is kept in a
 architecture specific location.
 
   Sam
 
 commit df95bb04b04ff2f64805dfa8459099ffe469c8a5
 Author: Sam Ravnborg [EMAIL PROTECTED]
 Date:   Fri Feb 16 19:51:29 2007 +0100
 
 kbuild: Make asm-offset generic
 
 Signed-off-by: Sam Ravnborg [EMAIL PROTECTED]
 
 diff --git a/include/asm-generic/asm-offset b/include/asm-generic/asm-offset
 new file mode 100644
 index 000..5e5629e
 --- /dev/null
 +++ b/include/asm-generic/asm-offset
 @@ -0,0 +1,30 @@
 +#
 +# Support generating constant useable from assembler but defined on C-level
 +#
 +# See usage in top-level Kbuild file
 +
 +# Default sed regexp - multiline due to syntax constraints
 +define sed-y
 + /^-/{s:^-\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; 
 s:-::; p;}
 +endef
 +
 +# let architectures override the sed expression as needed
 +-include include/asm/asm-offset
 +
 +quiet_cmd_offsets = GEN $@
 +define cmd_offsets
 + (set -e; \
 +  echo #ifndef __ASM_OFFSETS_H__; \
 +  echo #define __ASM_OFFSETS_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
 +
 diff --git a/include/asm-mips/asm-offset b/include/asm-mips/asm-offset
 new file mode 100644
 index 000..b2eb959
 --- /dev/null
 +++ b/include/asm-mips/asm-offset
 @@ -0,0 +1,4 @@
 +# Override default sed for MIPS when generating asm-offset
 +sed-$(CONFIG_MIPS) := /^@@@/{s/^@@@//; s/ \#.*\$$//; p;}
 +
 +
 diff --git a/Kbuild b/Kbuild
 index 0451f69..0a32f5f 100644
 --- a/Kbuild
 +++ b/Kbuild
 @@ -1,5 +1,8 @@
  #
  # Kbuild for top-level directory of the kernel
 +
 +
 +
  # This file takes care of the following:
  # 1) Generate asm-offsets.h
  
 @@ -7,36 +10,14 @@ #
  # 1) Generate asm-offsets.h
  #
  
 +include include/asm-generic/asm-offset
 +
  offsets-file := include/asm-$(ARCH)/asm-offsets.h
  
  always  := $(offsets-file)
  targets := $(offsets-file)
  targets += arch/$(ARCH)/kernel/asm-offsets.s
  
 -# Default sed regexp - multiline due to syntax constraints
 -define sed-y
 - /^-/{s:^-\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; 
 s:-::; p;}
 -endef
 -# Override default regexp for specific architectures
 -sed-$(CONFIG_MIPS) := /^@@@/{s/^@@@//; s/ \#.*\$$//; p;}
 -
 -quiet_cmd_offsets = GEN $@
 -define cmd_offsets
 - (set -e; \
 -  echo #ifndef __ASM_OFFSETS_H__; \
 -  echo #define __ASM_OFFSETS_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/$(ARCH)/kernel/asm-offsets.s: arch/$(ARCH)/kernel/asm-offsets.c FORCE
   $(Q)mkdir -p $(dir $@)

Thanks.


-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [pp] kbuild: asm-offsets generalized

2007-02-16 Thread Rusty Russell
On Fri, 2007-02-16 at 22:56 +0100, Oleg Verych wrote:
 Hallo.

lguest parts look good though!

Rusty.

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [pp] kbuild: asm-offsets generalized

2007-02-16 Thread Oleg Verych
On Sat, Feb 17, 2007 at 03:43:49PM +1100, Rusty Russell wrote:
 On Fri, 2007-02-16 at 22:56 +0100, Oleg Verych wrote:
  Hallo.
 
 lguest parts look good though!

Thanks.

Well, then what about my way of doing generalization?

I.e. one-file shell script-let, rather many indistinguishable GNU make
files throughout source tree?

Sam's approach also offers using of CONGIG* options. But this has two
issues (for me, of course):

* lguest is in i386 arch, *top* Kbuild doing this for specific ARCH
(include/asm/);

* lguest wants to have private for-asm constants generated, unless CONFIG
is set, kbuild never will reach that directory.

Finally (my favorite). While i was told, that i'm doing more obfusticated
solutions, i doubt i did now: script-let makes magic more readable, and
GNU make's complications, like `$$' and various whitespace issues, do not
influence.

One thing is, that

+quiet_cmd_offsets = GEN $@
+  cmd_offsets = $(srctree)/scripts/mkCconstants $ $@
+

can be moved in Kbuild.include with CONFIG* upgrade:

sed-$(CONFIG_MIPS) = mips

  cmd_offsets = $(srctree)/scripts/mkCconstants $ $@ $(sed-y)


Kind regards!
--
-o--=O`C  info emacs : not found
 #oo'L O  info make  : not found
___=E M  man gcc: not found
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/