All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 0/3] Use POSIX "$((..))" instead of bashism "$[...]"
Date: Thu, 13 Jun 2013 13:10:49 +0000	[thread overview]
Message-ID: <1371129052-31506-1-git-send-email-geert@linux-m68k.org> (raw)

This patch series replaces the bash-specific "$[...]" by POSIX "$((..))"
for arithmetic expansion, and gets rid of some dependencies on bash.

  [1/3] h8300/boot: Use POSIX "$((..))" instead of bashism "$[...]"
  [2/3] ARM: shmobile: Use POSIX "$((..))" instead of bashism "$[...]"
  [3/3] sh/boot: Use POSIX "$((..))" instead of bashism "$[...]"

The first one is a build fix on systems where /bin/sh is not bash, as it
uses the bashism without forcing bash.

This series was tested using the patch at the bottom, and running

    make ARCH=h8300 clean
    make ARCH=arm clean
    make ARCH=sh clean

with an optional "SHELL=/bin/..." appended, to test difference shells,
on Ubuntu 10.04.4 LTS.

It works fine with bash (4.1-2ubuntu3) and dash (0.5.5.1-3ubuntu2).

With mksh (39.3-1ubuntu3), 32-bit integers seem to be sign-extended to
64-bit integers, e.g.

arch/sh/boot/Makefile: KERNEL_MEMORY = 0x0c000000
arch/sh/boot/Makefile: KERNEL_LOAD = 0xffffffff8c001000
arch/sh/boot/Makefile: KERNEL_ENTRY = 0xffffffff8c002000
arch/sh/boot/compressed/Makefile: IMAGE_OFFSET = 0xffffffff8c800000

Should these be truncated to 32-bit explicitly, or is this a bug in mksh?

Thanks for your comments!

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 1ba358b..5029108 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -319,3 +319,5 @@ define archhelp
   echo  '                  (distribution) /sbin/$(INSTALLKERNEL) or'
   echo  '                  install to $$(INSTALL_PATH) and run lilo'
 endef
+
+include arch/arm/mach-shmobile/Makefile.boot
diff --git a/arch/arm/mach-shmobile/Makefile.boot b/arch/arm/mach-shmobile/Makefile.boot
index 498efd9..95ebc7c 100644
--- a/arch/arm/mach-shmobile/Makefile.boot
+++ b/arch/arm/mach-shmobile/Makefile.boot
@@ -7,3 +7,5 @@ __ZRELADDR	:= $(shell /bin/bash -c 'printf "0x%08x" \
 #
 #params_phys-y (Instead: Pass atags pointer in r2)
 #initrd_phys-y (Instead: Use compiled-in initramfs)
+
+XXX := $(shell echo arch/arm/mach-shmobile/Makefile.boot: __ZRELADDR = $(__ZRELADDR) >> /tmp/loggy)
diff --git a/arch/h8300/boot/compressed/Makefile b/arch/h8300/boot/compressed/Makefile
index 6745cb1..94faad1 100644
--- a/arch/h8300/boot/compressed/Makefile
+++ b/arch/h8300/boot/compressed/Makefile
@@ -35,3 +35,5 @@ OBJCOPYFLAGS := -O binary
 
 $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
 	$(call if_changed,ld)
+
+XXX := $(shell echo arch/h8300/boot/compressed/Makefile: IMAGE_OFFSET = $(IMAGE_OFFSET) >> /tmp/loggy)
diff --git a/arch/sh/boot/Makefile b/arch/sh/boot/Makefile
index 58592df..4ab2ba5 100644
--- a/arch/sh/boot/Makefile
+++ b/arch/sh/boot/Makefile
@@ -113,3 +113,7 @@ $(obj)/uImage: $(obj)/uImage.$(suffix-y)
 export CONFIG_PAGE_OFFSET CONFIG_MEMORY_START CONFIG_BOOT_LINK_OFFSET \
        CONFIG_PHYSICAL_START CONFIG_ZERO_PAGE_OFFSET CONFIG_ENTRY_OFFSET \
        KERNEL_MEMORY suffix-y
+
+XXX := $(shell echo arch/sh/boot/Makefile: KERNEL_MEMORY = $(KERNEL_MEMORY) >> /tmp/loggy)
+XXX := $(shell echo arch/sh/boot/Makefile: KERNEL_LOAD = $(KERNEL_LOAD) >> /tmp/loggy)
+XXX := $(shell echo arch/sh/boot/Makefile: KERNEL_ENTRY = $(KERNEL_ENTRY) >> /tmp/loggy)
diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile
index 23bc849..43d1b9a 100644
--- a/arch/sh/boot/compressed/Makefile
+++ b/arch/sh/boot/compressed/Makefile
@@ -79,3 +79,5 @@ LDFLAGS_piggy.o := -r --format binary --oformat $(ld-bfd) -T
 
 $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) FORCE
 	$(call if_changed,ld)
+
+XXX := $(shell echo arch/sh/boot/compressed/Makefile: IMAGE_OFFSET = $(IMAGE_OFFSET) >> /tmp/loggy)

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
In-Reply-To: 


WARNING: multiple messages have this Message-ID (diff)
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Yoshinori Sato <ysato@users.sourceforge.jp>,
	Simon Horman <horms@verge.net.au>,
	Magnus Damm <magnus.damm@gmail.com>,
	Russell King <linux@arm.linux.org.uk>,
	Paul Mundt <lethal@linux-sh.org>
Cc: David McCullough <david_mccullough@au.securecomputing.com>,
	Thorsten Glaser <tg@mirbsd.org>,
	linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org
Subject: [PATCH 0/3] Use POSIX "$((..))" instead of bashism "$[...]"
Date: Thu, 13 Jun 2013 15:10:49 +0200	[thread overview]
Message-ID: <1371129052-31506-1-git-send-email-geert@linux-m68k.org> (raw)

This patch series replaces the bash-specific "$[...]" by POSIX "$((..))"
for arithmetic expansion, and gets rid of some dependencies on bash.

  [1/3] h8300/boot: Use POSIX "$((..))" instead of bashism "$[...]"
  [2/3] ARM: shmobile: Use POSIX "$((..))" instead of bashism "$[...]"
  [3/3] sh/boot: Use POSIX "$((..))" instead of bashism "$[...]"

The first one is a build fix on systems where /bin/sh is not bash, as it
uses the bashism without forcing bash.

This series was tested using the patch at the bottom, and running

    make ARCH=h8300 clean
    make ARCH=arm clean
    make ARCH=sh clean

with an optional "SHELL=/bin/..." appended, to test difference shells,
on Ubuntu 10.04.4 LTS.

It works fine with bash (4.1-2ubuntu3) and dash (0.5.5.1-3ubuntu2).

With mksh (39.3-1ubuntu3), 32-bit integers seem to be sign-extended to
64-bit integers, e.g.

arch/sh/boot/Makefile: KERNEL_MEMORY = 0x0c000000
arch/sh/boot/Makefile: KERNEL_LOAD = 0xffffffff8c001000
arch/sh/boot/Makefile: KERNEL_ENTRY = 0xffffffff8c002000
arch/sh/boot/compressed/Makefile: IMAGE_OFFSET = 0xffffffff8c800000

Should these be truncated to 32-bit explicitly, or is this a bug in mksh?

Thanks for your comments!

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 1ba358b..5029108 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -319,3 +319,5 @@ define archhelp
   echo  '                  (distribution) /sbin/$(INSTALLKERNEL) or'
   echo  '                  install to $$(INSTALL_PATH) and run lilo'
 endef
+
+include arch/arm/mach-shmobile/Makefile.boot
diff --git a/arch/arm/mach-shmobile/Makefile.boot b/arch/arm/mach-shmobile/Makefile.boot
index 498efd9..95ebc7c 100644
--- a/arch/arm/mach-shmobile/Makefile.boot
+++ b/arch/arm/mach-shmobile/Makefile.boot
@@ -7,3 +7,5 @@ __ZRELADDR	:= $(shell /bin/bash -c 'printf "0x%08x" \
 #
 #params_phys-y (Instead: Pass atags pointer in r2)
 #initrd_phys-y (Instead: Use compiled-in initramfs)
+
+XXX := $(shell echo arch/arm/mach-shmobile/Makefile.boot: __ZRELADDR = $(__ZRELADDR) >> /tmp/loggy)
diff --git a/arch/h8300/boot/compressed/Makefile b/arch/h8300/boot/compressed/Makefile
index 6745cb1..94faad1 100644
--- a/arch/h8300/boot/compressed/Makefile
+++ b/arch/h8300/boot/compressed/Makefile
@@ -35,3 +35,5 @@ OBJCOPYFLAGS := -O binary
 
 $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
 	$(call if_changed,ld)
+
+XXX := $(shell echo arch/h8300/boot/compressed/Makefile: IMAGE_OFFSET = $(IMAGE_OFFSET) >> /tmp/loggy)
diff --git a/arch/sh/boot/Makefile b/arch/sh/boot/Makefile
index 58592df..4ab2ba5 100644
--- a/arch/sh/boot/Makefile
+++ b/arch/sh/boot/Makefile
@@ -113,3 +113,7 @@ $(obj)/uImage: $(obj)/uImage.$(suffix-y)
 export CONFIG_PAGE_OFFSET CONFIG_MEMORY_START CONFIG_BOOT_LINK_OFFSET \
        CONFIG_PHYSICAL_START CONFIG_ZERO_PAGE_OFFSET CONFIG_ENTRY_OFFSET \
        KERNEL_MEMORY suffix-y
+
+XXX := $(shell echo arch/sh/boot/Makefile: KERNEL_MEMORY = $(KERNEL_MEMORY) >> /tmp/loggy)
+XXX := $(shell echo arch/sh/boot/Makefile: KERNEL_LOAD = $(KERNEL_LOAD) >> /tmp/loggy)
+XXX := $(shell echo arch/sh/boot/Makefile: KERNEL_ENTRY = $(KERNEL_ENTRY) >> /tmp/loggy)
diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile
index 23bc849..43d1b9a 100644
--- a/arch/sh/boot/compressed/Makefile
+++ b/arch/sh/boot/compressed/Makefile
@@ -79,3 +79,5 @@ LDFLAGS_piggy.o := -r --format binary --oformat $(ld-bfd) -T
 
 $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) FORCE
 	$(call if_changed,ld)
+
+XXX := $(shell echo arch/sh/boot/compressed/Makefile: IMAGE_OFFSET = $(IMAGE_OFFSET) >> /tmp/loggy)

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
In-Reply-To: 


WARNING: multiple messages have this Message-ID (diff)
From: geert@linux-m68k.org (Geert Uytterhoeven)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 0/3] Use POSIX "$((..))" instead of bashism "$[...]"
Date: Thu, 13 Jun 2013 15:10:49 +0200	[thread overview]
Message-ID: <1371129052-31506-1-git-send-email-geert@linux-m68k.org> (raw)

This patch series replaces the bash-specific "$[...]" by POSIX "$((..))"
for arithmetic expansion, and gets rid of some dependencies on bash.

  [1/3] h8300/boot: Use POSIX "$((..))" instead of bashism "$[...]"
  [2/3] ARM: shmobile: Use POSIX "$((..))" instead of bashism "$[...]"
  [3/3] sh/boot: Use POSIX "$((..))" instead of bashism "$[...]"

The first one is a build fix on systems where /bin/sh is not bash, as it
uses the bashism without forcing bash.

This series was tested using the patch at the bottom, and running

    make ARCH=h8300 clean
    make ARCH=arm clean
    make ARCH=sh clean

with an optional "SHELL=/bin/..." appended, to test difference shells,
on Ubuntu 10.04.4 LTS.

It works fine with bash (4.1-2ubuntu3) and dash (0.5.5.1-3ubuntu2).

With mksh (39.3-1ubuntu3), 32-bit integers seem to be sign-extended to
64-bit integers, e.g.

arch/sh/boot/Makefile: KERNEL_MEMORY = 0x0c000000
arch/sh/boot/Makefile: KERNEL_LOAD = 0xffffffff8c001000
arch/sh/boot/Makefile: KERNEL_ENTRY = 0xffffffff8c002000
arch/sh/boot/compressed/Makefile: IMAGE_OFFSET = 0xffffffff8c800000

Should these be truncated to 32-bit explicitly, or is this a bug in mksh?

Thanks for your comments!

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 1ba358b..5029108 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -319,3 +319,5 @@ define archhelp
   echo  '                  (distribution) /sbin/$(INSTALLKERNEL) or'
   echo  '                  install to $$(INSTALL_PATH) and run lilo'
 endef
+
+include arch/arm/mach-shmobile/Makefile.boot
diff --git a/arch/arm/mach-shmobile/Makefile.boot b/arch/arm/mach-shmobile/Makefile.boot
index 498efd9..95ebc7c 100644
--- a/arch/arm/mach-shmobile/Makefile.boot
+++ b/arch/arm/mach-shmobile/Makefile.boot
@@ -7,3 +7,5 @@ __ZRELADDR	:= $(shell /bin/bash -c 'printf "0x%08x" \
 #
 #params_phys-y (Instead: Pass atags pointer in r2)
 #initrd_phys-y (Instead: Use compiled-in initramfs)
+
+XXX := $(shell echo arch/arm/mach-shmobile/Makefile.boot: __ZRELADDR = $(__ZRELADDR) >> /tmp/loggy)
diff --git a/arch/h8300/boot/compressed/Makefile b/arch/h8300/boot/compressed/Makefile
index 6745cb1..94faad1 100644
--- a/arch/h8300/boot/compressed/Makefile
+++ b/arch/h8300/boot/compressed/Makefile
@@ -35,3 +35,5 @@ OBJCOPYFLAGS := -O binary
 
 $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
 	$(call if_changed,ld)
+
+XXX := $(shell echo arch/h8300/boot/compressed/Makefile: IMAGE_OFFSET = $(IMAGE_OFFSET) >> /tmp/loggy)
diff --git a/arch/sh/boot/Makefile b/arch/sh/boot/Makefile
index 58592df..4ab2ba5 100644
--- a/arch/sh/boot/Makefile
+++ b/arch/sh/boot/Makefile
@@ -113,3 +113,7 @@ $(obj)/uImage: $(obj)/uImage.$(suffix-y)
 export CONFIG_PAGE_OFFSET CONFIG_MEMORY_START CONFIG_BOOT_LINK_OFFSET \
        CONFIG_PHYSICAL_START CONFIG_ZERO_PAGE_OFFSET CONFIG_ENTRY_OFFSET \
        KERNEL_MEMORY suffix-y
+
+XXX := $(shell echo arch/sh/boot/Makefile: KERNEL_MEMORY = $(KERNEL_MEMORY) >> /tmp/loggy)
+XXX := $(shell echo arch/sh/boot/Makefile: KERNEL_LOAD = $(KERNEL_LOAD) >> /tmp/loggy)
+XXX := $(shell echo arch/sh/boot/Makefile: KERNEL_ENTRY = $(KERNEL_ENTRY) >> /tmp/loggy)
diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile
index 23bc849..43d1b9a 100644
--- a/arch/sh/boot/compressed/Makefile
+++ b/arch/sh/boot/compressed/Makefile
@@ -79,3 +79,5 @@ LDFLAGS_piggy.o := -r --format binary --oformat $(ld-bfd) -T
 
 $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) FORCE
 	$(call if_changed,ld)
+
+XXX := $(shell echo arch/sh/boot/compressed/Makefile: IMAGE_OFFSET = $(IMAGE_OFFSET) >> /tmp/loggy)

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
In-Reply-To: 

             reply	other threads:[~2013-06-13 13:10 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-13 13:10 Geert Uytterhoeven [this message]
2013-06-13 13:10 ` [PATCH 0/3] Use POSIX "$((..))" instead of bashism "$[...]" Geert Uytterhoeven
2013-06-13 13:10 ` Geert Uytterhoeven
2013-06-13 13:10 ` [PATCH 1/3] h8300/boot: " Geert Uytterhoeven
2013-06-13 13:10   ` Geert Uytterhoeven
2013-06-13 13:10   ` Geert Uytterhoeven
2013-06-13 13:10 ` [PATCH 2/3] ARM: shmobile: " Geert Uytterhoeven
2013-06-13 13:10   ` Geert Uytterhoeven
2013-06-13 13:10   ` Geert Uytterhoeven
2013-06-13 13:29   ` Simon Horman
2013-06-13 13:29     ` Simon Horman
2013-06-13 13:29     ` Simon Horman
2013-06-13 13:10 ` [PATCH 3/3] sh/boot: " Geert Uytterhoeven
2013-06-13 13:10   ` Geert Uytterhoeven
2013-06-13 13:10   ` Geert Uytterhoeven
2013-06-13 19:16 ` [PATCH 0/3] " Thorsten Glaser
2013-06-13 19:16   ` Thorsten Glaser
2013-06-13 19:16   ` Thorsten Glaser

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=1371129052-31506-1-git-send-email-geert@linux-m68k.org \
    --to=geert@linux-m68k.org \
    --cc=linux-arm-kernel@lists.infradead.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.