* + kbuild-simpler-generation-of-assembly-constants.patch added to -mm tree
@ 2016-07-08 21:05 akpm
2016-07-13 17:36 ` [PATCH v3] kbuild: simpler generation of assembly constants Alexey Dobriyan
0 siblings, 1 reply; 3+ messages in thread
From: akpm @ 2016-07-08 21:05 UTC (permalink / raw)
To: adobriyan, mmarek, tony.luck, mm-commits
The patch titled
Subject: kbuild: simpler generation of assembly constants
has been added to the -mm tree. Its filename is
kbuild-simpler-generation-of-assembly-constants.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/kbuild-simpler-generation-of-assembly-constants.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/kbuild-simpler-generation-of-assembly-constants.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Alexey Dobriyan <adobriyan@gmail.com>
Subject: kbuild: simpler generation of assembly constants
gcc doesn't really look inside "asm" statements and more or less directly
emits it into assembly. So pretend "#define" is CPU instruction.
Also, use C++ comment to block whatever garbage is put at the end of
the line by compiler.
Link: http://lkml.kernel.org/r/20160707213941.GA31678@p183.telecom.by
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: "Luck, Tony" <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
Kbuild | 12 +-----------
arch/ia64/kernel/Makefile | 8 +-------
include/linux/kbuild.h | 2 +-
scripts/mod/Makefile | 11 +----------
4 files changed, 4 insertions(+), 29 deletions(-)
diff -puN Kbuild~kbuild-simpler-generation-of-assembly-constants Kbuild
--- a/Kbuild~kbuild-simpler-generation-of-assembly-constants
+++ a/Kbuild
@@ -7,14 +7,6 @@
# 4) Check for missing system calls
# 5) Generate constants.py (may need bounds.h)
-# Default sed regexp - multiline due to syntax constraints
-define sed-y
- "/^->/{s:->#\(.*\):/* \1 */:; \
- s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
- s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
- s:->::; p;}"
-endef
-
# Use filechk to avoid rebuilds when a header changes, but the resulting file
# does not
define filechk_offsets
@@ -26,9 +18,7 @@ define filechk_offsets
echo " *"; \
echo " * This file was generated by Kbuild"; \
echo " */"; \
- echo ""; \
- sed -ne $(sed-y); \
- echo ""; \
+ sed -ne '/#define/{s/\$$//;s/#//2;p;}'; \
echo "#endif" )
endef
diff -puN arch/ia64/kernel/Makefile~kbuild-simpler-generation-of-assembly-constants arch/ia64/kernel/Makefile
--- a/arch/ia64/kernel/Makefile~kbuild-simpler-generation-of-assembly-constants
+++ a/arch/ia64/kernel/Makefile
@@ -50,10 +50,6 @@ CFLAGS_traps.o += -mfixed-range=f2-f5,f
# The gate DSO image is built using a special linker script.
include $(src)/Makefile.gate
-# Calculate NR_IRQ = max(IA64_NATIVE_NR_IRQS, XEN_NR_IRQS, ...) based on config
-define sed-y
- "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"
-endef
quiet_cmd_nr_irqs = GEN $@
define cmd_nr_irqs
(set -e; \
@@ -65,9 +61,7 @@ define cmd_nr_irqs
echo " * This file was generated by Kbuild"; \
echo " *"; \
echo " */"; \
- echo ""; \
- sed -ne $(sed-y) $<; \
- echo ""; \
+ sed -ne '/#define/{s/\$$//;s/#//2;p;}' $<; \
echo "#endif" ) > $@
endef
diff -puN include/linux/kbuild.h~kbuild-simpler-generation-of-assembly-constants include/linux/kbuild.h
--- a/include/linux/kbuild.h~kbuild-simpler-generation-of-assembly-constants
+++ a/include/linux/kbuild.h
@@ -2,7 +2,7 @@
#define __LINUX_KBUILD_H
#define DEFINE(sym, val) \
- asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+ asm volatile ("#define " #sym " %0 //" #val :: "i" (val))
#define BLANK() asm volatile("\n->" : : )
diff -puN scripts/mod/Makefile~kbuild-simpler-generation-of-assembly-constants scripts/mod/Makefile
--- a/scripts/mod/Makefile~kbuild-simpler-generation-of-assembly-constants
+++ a/scripts/mod/Makefile
@@ -7,13 +7,6 @@ modpost-objs := modpost.o file2alias.o s
devicetable-offsets-file := devicetable-offsets.h
-define sed-y
- "/^->/{s:->#\(.*\):/* \1 */:; \
- s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
- s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
- s:->::; p;}"
-endef
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v3] kbuild: simpler generation of assembly constants
2016-07-08 21:05 + kbuild-simpler-generation-of-assembly-constants.patch added to -mm tree akpm
@ 2016-07-13 17:36 ` Alexey Dobriyan
0 siblings, 0 replies; 3+ messages in thread
From: Alexey Dobriyan @ 2016-07-13 17:36 UTC (permalink / raw)
To: akpm; +Cc: mmarek, tony.luck, linux-kernel
gcc doesn't really look inside "asm" statements and more or less
directly emits it into assembly. So pretend "#define" is CPU
instruction.
C++ comment can't be used because sparc assembler doesn't understand it.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
This one compiles on Sparc and UML.
Kbuild | 12 +-----------
arch/ia64/kernel/Makefile | 8 +-------
arch/um/Makefile | 2 +-
arch/x86/um/shared/sysdep/kernel-offsets.h | 2 +-
arch/x86/um/user-offsets.c | 4 ++--
include/linux/kbuild.h | 2 +-
scripts/mod/Makefile | 11 +----------
7 files changed, 8 insertions(+), 33 deletions(-)
--- a/Kbuild
+++ b/Kbuild
@@ -7,14 +7,6 @@
# 4) Check for missing system calls
# 5) Generate constants.py (may need bounds.h)
-# Default sed regexp - multiline due to syntax constraints
-define sed-y
- "/^->/{s:->#\(.*\):/* \1 */:; \
- s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
- s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
- s:->::; p;}"
-endef
-
# Use filechk to avoid rebuilds when a header changes, but the resulting file
# does not
define filechk_offsets
@@ -26,9 +18,7 @@ define filechk_offsets
echo " *"; \
echo " * This file was generated by Kbuild"; \
echo " */"; \
- echo ""; \
- sed -ne $(sed-y); \
- echo ""; \
+ sed -ne '/#define/{s/\$$//;s/#//2;s/$$/*\//;p;}'; \
echo "#endif" )
endef
--- a/arch/ia64/kernel/Makefile
+++ b/arch/ia64/kernel/Makefile
@@ -50,10 +50,6 @@ CFLAGS_traps.o += -mfixed-range=f2-f5,f16-f31
# The gate DSO image is built using a special linker script.
include $(src)/Makefile.gate
-# Calculate NR_IRQ = max(IA64_NATIVE_NR_IRQS, XEN_NR_IRQS, ...) based on config
-define sed-y
- "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"
-endef
quiet_cmd_nr_irqs = GEN $@
define cmd_nr_irqs
(set -e; \
@@ -65,9 +61,7 @@ define cmd_nr_irqs
echo " * This file was generated by Kbuild"; \
echo " *"; \
echo " */"; \
- echo ""; \
- sed -ne $(sed-y) $<; \
- echo ""; \
+ sed -ne '/#define/{s/\$$//;s/#//2;s/$$/*\//p;}' $<; \
echo "#endif" ) > $@
endef
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -158,7 +158,7 @@ define filechk_gen-asm-offsets
echo " *"; \
echo " */"; \
echo ""; \
- sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
+ sed -ne '/#define/{s/\$$//;s/#//2;s/$$/*\//p;}'; \
echo ""; )
endef
--- a/arch/x86/um/shared/sysdep/kernel-offsets.h
+++ b/arch/x86/um/shared/sysdep/kernel-offsets.h
@@ -5,7 +5,7 @@
#include <asm/mman.h>
#define DEFINE(sym, val) \
- asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+ asm volatile ("#define " #sym " %0 /*" #val :: "i" (val))
#define BLANK() asm volatile("\n->" : : )
--- a/arch/x86/um/user-offsets.c
+++ b/arch/x86/um/user-offsets.c
@@ -21,10 +21,10 @@ static char syscalls[] = {
#endif
#define DEFINE(sym, val) \
- asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+ asm volatile ("#define " #sym " %0 /*" #val :: "i" (val))
#define DEFINE_LONGS(sym, val) \
- asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long)))
+ asm volatile ("#define " #sym " %0 /*" #val :: "i" (val / sizeof(unsigned long)))
void foo(void)
{
--- a/include/linux/kbuild.h
+++ b/include/linux/kbuild.h
@@ -2,7 +2,7 @@
#define __LINUX_KBUILD_H
#define DEFINE(sym, val) \
- asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+ asm volatile ("#define " #sym " %0 /*" #val :: "i" (val))
#define BLANK() asm volatile("\n->" : : )
--- a/scripts/mod/Makefile
+++ b/scripts/mod/Makefile
@@ -7,13 +7,6 @@ modpost-objs := modpost.o file2alias.o sumversion.o
devicetable-offsets-file := devicetable-offsets.h
-define sed-y
- "/^->/{s:->#\(.*\):/* \1 */:; \
- s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
- s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
- s:->::; p;}"
-endef
-
quiet_cmd_offsets = GEN $@
define cmd_offsets
(set -e; \
@@ -25,9 +18,7 @@ define cmd_offsets
echo " * This file was generated by Kbuild"; \
echo " *"; \
echo " */"; \
- echo ""; \
- sed -ne $(sed-y) $<; \
- echo ""; \
+ sed -ne '/#define/{s/\$$//;s/#//2;s/$$/*\//;p;}' $<; \
echo "#endif" ) > $@
endef
^ permalink raw reply [flat|nested] 3+ messages in thread
* + kbuild-simpler-generation-of-assembly-constants.patch added to -mm tree
@ 2016-07-13 20:22 akpm
0 siblings, 0 replies; 3+ messages in thread
From: akpm @ 2016-07-13 20:22 UTC (permalink / raw)
To: adobriyan, mmarek, tony.luck, mm-commits
The patch titled
Subject: kbuild: simpler generation of assembly constants
has been added to the -mm tree. Its filename is
kbuild-simpler-generation-of-assembly-constants.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/kbuild-simpler-generation-of-assembly-constants.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/kbuild-simpler-generation-of-assembly-constants.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Alexey Dobriyan <adobriyan@gmail.com>
Subject: kbuild: simpler generation of assembly constants
gcc doesn't really look inside "asm" statements and more or less
directly emits it into assembly. So pretend "#define" is CPU
instruction.
C++ comment can't be used because sparc assembler doesn't understand it.
Link: http://lkml.kernel.org/r/20160713173646.GA1910@p183.telecom.by
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: "Luck, Tony" <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
Kbuild | 12 +-----------
arch/ia64/kernel/Makefile | 8 +-------
arch/um/Makefile | 2 +-
arch/x86/um/shared/sysdep/kernel-offsets.h | 2 +-
arch/x86/um/user-offsets.c | 4 ++--
include/linux/kbuild.h | 2 +-
scripts/mod/Makefile | 11 +----------
7 files changed, 8 insertions(+), 33 deletions(-)
diff -puN Kbuild~kbuild-simpler-generation-of-assembly-constants Kbuild
--- a/Kbuild~kbuild-simpler-generation-of-assembly-constants
+++ a/Kbuild
@@ -7,14 +7,6 @@
# 4) Check for missing system calls
# 5) Generate constants.py (may need bounds.h)
-# Default sed regexp - multiline due to syntax constraints
-define sed-y
- "/^->/{s:->#\(.*\):/* \1 */:; \
- s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
- s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
- s:->::; p;}"
-endef
-
# Use filechk to avoid rebuilds when a header changes, but the resulting file
# does not
define filechk_offsets
@@ -26,9 +18,7 @@ define filechk_offsets
echo " *"; \
echo " * This file was generated by Kbuild"; \
echo " */"; \
- echo ""; \
- sed -ne $(sed-y); \
- echo ""; \
+ sed -ne '/#define/{s/\$$//;s/#//2;s/$$/*\//;p;}'; \
echo "#endif" )
endef
diff -puN arch/ia64/kernel/Makefile~kbuild-simpler-generation-of-assembly-constants arch/ia64/kernel/Makefile
--- a/arch/ia64/kernel/Makefile~kbuild-simpler-generation-of-assembly-constants
+++ a/arch/ia64/kernel/Makefile
@@ -50,10 +50,6 @@ CFLAGS_traps.o += -mfixed-range=f2-f5,f
# The gate DSO image is built using a special linker script.
include $(src)/Makefile.gate
-# Calculate NR_IRQ = max(IA64_NATIVE_NR_IRQS, XEN_NR_IRQS, ...) based on config
-define sed-y
- "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"
-endef
quiet_cmd_nr_irqs = GEN $@
define cmd_nr_irqs
(set -e; \
@@ -65,9 +61,7 @@ define cmd_nr_irqs
echo " * This file was generated by Kbuild"; \
echo " *"; \
echo " */"; \
- echo ""; \
- sed -ne $(sed-y) $<; \
- echo ""; \
+ sed -ne '/#define/{s/\$$//;s/#//2;s/$$/*\//p;}' $<; \
echo "#endif" ) > $@
endef
diff -puN arch/um/Makefile~kbuild-simpler-generation-of-assembly-constants arch/um/Makefile
--- a/arch/um/Makefile~kbuild-simpler-generation-of-assembly-constants
+++ a/arch/um/Makefile
@@ -158,7 +158,7 @@ define filechk_gen-asm-offsets
echo " *"; \
echo " */"; \
echo ""; \
- sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
+ sed -ne '/#define/{s/\$$//;s/#//2;s/$$/*\//p;}'; \
echo ""; )
endef
diff -puN arch/x86/um/shared/sysdep/kernel-offsets.h~kbuild-simpler-generation-of-assembly-constants arch/x86/um/shared/sysdep/kernel-offsets.h
--- a/arch/x86/um/shared/sysdep/kernel-offsets.h~kbuild-simpler-generation-of-assembly-constants
+++ a/arch/x86/um/shared/sysdep/kernel-offsets.h
@@ -5,7 +5,7 @@
#include <asm/mman.h>
#define DEFINE(sym, val) \
- asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+ asm volatile ("#define " #sym " %0 /*" #val :: "i" (val))
#define BLANK() asm volatile("\n->" : : )
diff -puN arch/x86/um/user-offsets.c~kbuild-simpler-generation-of-assembly-constants arch/x86/um/user-offsets.c
--- a/arch/x86/um/user-offsets.c~kbuild-simpler-generation-of-assembly-constants
+++ a/arch/x86/um/user-offsets.c
@@ -21,10 +21,10 @@ static char syscalls[] = {
#endif
#define DEFINE(sym, val) \
- asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+ asm volatile ("#define " #sym " %0 /*" #val :: "i" (val))
#define DEFINE_LONGS(sym, val) \
- asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long)))
+ asm volatile ("#define " #sym " %0 /*" #val :: "i" (val / sizeof(unsigned long)))
void foo(void)
{
diff -puN include/linux/kbuild.h~kbuild-simpler-generation-of-assembly-constants include/linux/kbuild.h
--- a/include/linux/kbuild.h~kbuild-simpler-generation-of-assembly-constants
+++ a/include/linux/kbuild.h
@@ -2,7 +2,7 @@
#define __LINUX_KBUILD_H
#define DEFINE(sym, val) \
- asm volatile("\n->" #sym " %0 " #val : : "i" (val))
+ asm volatile ("#define " #sym " %0 /*" #val :: "i" (val))
#define BLANK() asm volatile("\n->" : : )
diff -puN scripts/mod/Makefile~kbuild-simpler-generation-of-assembly-constants scripts/mod/Makefile
--- a/scripts/mod/Makefile~kbuild-simpler-generation-of-assembly-constants
+++ a/scripts/mod/Makefile
@@ -7,13 +7,6 @@ modpost-objs := modpost.o file2alias.o s
devicetable-offsets-file := devicetable-offsets.h
-define sed-y
- "/^->/{s:->#\(.*\):/* \1 */:; \
- s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
- s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
- s:->::; p;}"
-endef
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-07-13 20:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-08 21:05 + kbuild-simpler-generation-of-assembly-constants.patch added to -mm tree akpm
2016-07-13 17:36 ` [PATCH v3] kbuild: simpler generation of assembly constants Alexey Dobriyan
2016-07-13 20:22 + kbuild-simpler-generation-of-assembly-constants.patch added to -mm tree akpm
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.