[Xenomai-git] Gilles Chanteperdrix : arith: avoid ARM Linux do_div compile-time optimizations.

2009-12-22 Thread GIT version control
Module: xenomai-head
Branch: master
Commit: 3c17098157e16830d101411508310dd326214deb
URL:
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=3c17098157e16830d101411508310dd326214deb

Author: Gilles Chanteperdrix 
Date:   Mon Dec 21 23:45:03 2009 +0100

arith: avoid ARM Linux do_div compile-time optimizations.

They are not critical for xnarch_init_u32frac and xnarch_init_llmulshft,
and they cause the compiler register allocation to fail.

---

 include/asm-generic/arith.h |   14 +++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/include/asm-generic/arith.h b/include/asm-generic/arith.h
index dac9ccb..416e742 100644
--- a/include/asm-generic/arith.h
+++ b/include/asm-generic/arith.h
@@ -275,9 +275,13 @@ static inline void xnarch_init_u32frac(rthal_u32frac_t 
*const f,
   const unsigned m,
   const unsigned d)
 {
+   /* Avoid clever compiler optimizations to occur when d is
+  known at compile-time. The performance of this function is
+  not critical since it is only called at init time. */
+   volatile unsigned vol_d = d;
f->integ = m / d;
-   f->frac = __rthal_generic_div96by32(__rthal_u64fromu32(m % d, 0),
-   0, d, NULL);
+   f->frac = __rthal_generic_div96by32
+   (__rthal_u64fromu32(m % d, 0), 0, vol_d, NULL);
 }
 
 #ifndef rthal_nodiv_imuldiv
@@ -354,12 +358,16 @@ static inline void xnarch_init_llmulshft(const unsigned 
m_in,
 unsigned *m_out,
 unsigned *s_out)
 {
+   /* Avoid clever compiler optimizations to occur when d is
+  known at compile-time. The performance of this function is
+  not critical since it is only called at init time. */
+   volatile unsigned vol_d = d_in;
unsigned long long mult;
 
*s_out = 31;
while (1) {
mult = ((unsigned long long)m_in) << *s_out;
-   do_div(mult, d_in);
+   do_div(mult, vol_d);
if (mult <= 0x7FFF)
break;
(*s_out)--;


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git


[Xenomai-git] Gilles Chanteperdrix : arith: avoid ARM Linux do_div compile-time optimizations.

2009-12-21 Thread GIT version control
Module: xenomai-gch
Branch: for-head
Commit: 3c17098157e16830d101411508310dd326214deb
URL:
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=3c17098157e16830d101411508310dd326214deb

Author: Gilles Chanteperdrix 
Date:   Mon Dec 21 23:45:03 2009 +0100

arith: avoid ARM Linux do_div compile-time optimizations.

They are not critical for xnarch_init_u32frac and xnarch_init_llmulshft,
and they cause the compiler register allocation to fail.

---

 include/asm-generic/arith.h |   14 +++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/include/asm-generic/arith.h b/include/asm-generic/arith.h
index dac9ccb..416e742 100644
--- a/include/asm-generic/arith.h
+++ b/include/asm-generic/arith.h
@@ -275,9 +275,13 @@ static inline void xnarch_init_u32frac(rthal_u32frac_t 
*const f,
   const unsigned m,
   const unsigned d)
 {
+   /* Avoid clever compiler optimizations to occur when d is
+  known at compile-time. The performance of this function is
+  not critical since it is only called at init time. */
+   volatile unsigned vol_d = d;
f->integ = m / d;
-   f->frac = __rthal_generic_div96by32(__rthal_u64fromu32(m % d, 0),
-   0, d, NULL);
+   f->frac = __rthal_generic_div96by32
+   (__rthal_u64fromu32(m % d, 0), 0, vol_d, NULL);
 }
 
 #ifndef rthal_nodiv_imuldiv
@@ -354,12 +358,16 @@ static inline void xnarch_init_llmulshft(const unsigned 
m_in,
 unsigned *m_out,
 unsigned *s_out)
 {
+   /* Avoid clever compiler optimizations to occur when d is
+  known at compile-time. The performance of this function is
+  not critical since it is only called at init time. */
+   volatile unsigned vol_d = d_in;
unsigned long long mult;
 
*s_out = 31;
while (1) {
mult = ((unsigned long long)m_in) << *s_out;
-   do_div(mult, d_in);
+   do_div(mult, vol_d);
if (mult <= 0x7FFF)
break;
(*s_out)--;


___
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git