Skip to contentSkip to conversation

Use lldiv from div64.h for 64-bit divisions

PATCH New Christian Riesch 2 participants 5 messages Dec 9, 2011 – Dec 10, 2011 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

cover Use lldiv from div64.h for 64-bit divisions

Hi,
During the review of my patchset

[PATCH v5 0/6] Add an SPL to boot the da850evm from SPI
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/119249/

a linker problem was discovered by Tom Rini and Wolfgang Denk that occured only with certain toolchains:

Quoted 2 lines

arm-linux-gnueabi-ld: error: no memory region specified for loadable section `.ARM.exidx'

This section .ARM.exidx is only present when the 64-bit division from libgcc is used.

The two patches in this patchset replace the 64-bit divisions in arch/arm/cpu/arm926ejs/davinci/timer.c and post/post.c by the lldiv function from div64.h and thus fix the linker problem.

Regards, Christian

Cc Tom Rini <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Wolfgang Denk <[email protected]>

Christian Riesch (2):
arm, davinci: Use lldiv for the 64-bit divisions in timer.c post/post.c: Use lldiv for 64-bit divisions

 arch/arm/cpu/arm926ejs/davinci/timer.c |    6 ++++--
 post/post.c                            |    3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH 1/2 arm, davinci: Use lldiv for the 64-bit divisions in timer.c

Cc Tom Rini <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 arch/arm/cpu/arm926ejs/davinci/timer.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
arch/arm/cpu/arm926ejs/davinci/timer.c +4 -2
index c7bf7a5..a06d449 100644
@@ -40,6 +40,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/arch/timer_defs.h>
+#include <div64.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -86,14 +87,15 @@ ulong get_timer(ulong base)
 
 	timer_diff = get_ticks() - gd->timer_reset_value;
 
-	return (timer_diff / (gd->timer_rate_hz / CONFIG_SYS_HZ)) - base;
+	return lldiv(timer_diff, (gd->timer_rate_hz / CONFIG_SYS_HZ)) - base;
 }
 
 void __udelay(unsigned long usec)
 {
 	unsigned long long endtime;
 
-	endtime = ((unsigned long long)usec * gd->timer_rate_hz) / 1000000UL;
+	endtime = lldiv((unsigned long long)usec * gd->timer_rate_hz,
+			1000000UL);
 	endtime += get_ticks();
 
 	while (get_ticks() < endtime)
Signature · 1 line
1.7.4.1
#2 lore raw

PATCH 1/2 arm, davinci: Use lldiv for the 64-bit divisions in timer.c

Dear Christian Riesch,

Quoted 7 lines · In message <[email protected]> you…
Cc Tom Rini <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 arch/arm/cpu/arm926ejs/davinci/timer.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Anyone who isn't confused here doesn't really know what's going on.
#3 lore raw

PATCH 2/2 post/post.c: Use lldiv for 64-bit divisions

In reply to Christian Riesch
Cc Tom Rini <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 post/post.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
post/post.c +2 -1
index 0e67ad7..45e08f8 100644
@@ -24,6 +24,7 @@
 #include <common.h>
 #include <stdio_dev.h>
 #include <watchdog.h>
+#include <div64.h>
 #include <post.h>
 
 #ifdef CONFIG_SYS_POST_HOTKEYS_GPIO
@@ -495,7 +496,7 @@ void post_reloc(void)
 unsigned long post_time_ms(unsigned long base)
 {
 #if defined(CONFIG_PPC) || defined(CONFIG_ARM)
-	return (unsigned long)(get_ticks() / (get_tbclk() / CONFIG_SYS_HZ))
+	return (unsigned long)lldiv(get_ticks(), get_tbclk() / CONFIG_SYS_HZ)
 		- base;
 #else
 #warning "Not implemented yet"
Signature · 1 line
1.7.4.1
#4 lore raw

PATCH 2/2 post/post.c: Use lldiv for 64-bit divisions

Dear Christian Riesch,

Quoted 7 lines · In message <[email protected]> you…
Cc Tom Rini <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 post/post.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 7 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Obviously, a major malfunction has occurred."
              -- Steve Nesbitt, voice of Mission Control, January 28,
                 1986, as the shuttle Challenger exploded within view
                 of the grandstands.