Module: xenomai-head
Branch: master
Commit: 917b56b99687beede07728d4eddf16c506de5bf9
URL:    
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=917b56b99687beede07728d4eddf16c506de5bf9

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Tue Jun  2 22:17:04 2009 +0200

Fix the POSIX skin to use the common time conversion.

Do not use the arithmetic routines directly.

---

 ksrc/skins/posix/internal.h |    9 ++++-----
 src/skins/posix/clock.c     |   15 ++++++---------
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/ksrc/skins/posix/internal.h b/ksrc/skins/posix/internal.h
index 6b704eb..dcc71e9 100644
--- a/ksrc/skins/posix/internal.h
+++ b/ksrc/skins/posix/internal.h
@@ -129,8 +129,8 @@ static inline pse51_kqueues_t *pse51_kqueues(int pshared)
 
 static inline void ticks2ts(struct timespec *ts, xnticks_t ticks)
 {
-       ts->tv_sec = xnarch_uldivrem(xntbase_ticks2ns(pse51_tbase, ticks),
-                                    ONE_BILLION, &ts->tv_nsec);
+       ts->tv_sec = xnarch_divrem_billion(xntbase_ticks2ns(pse51_tbase, ticks),
+                                          &ts->tv_nsec);
 }
 
 static inline xnticks_t ts2ticks_floor(const struct timespec *ts)
@@ -166,9 +166,8 @@ static inline xnticks_t tv2ticks_ceil(const struct timeval 
*tv)
 static inline void ticks2tv(struct timeval *tv, xnticks_t ticks)
 {
        unsigned long nsecs;
-       tv->tv_sec = xnarch_uldivrem(xntbase_ticks2ns(pse51_tbase, ticks),
-                                    ONE_BILLION,
-                                    &nsecs);
+       tv->tv_sec = xnarch_divrem_billion(xntbase_ticks2ns(pse51_tbase, ticks),
+                                          &nsecs);
        tv->tv_usec = nsecs / 1000;
 }
 
diff --git a/src/skins/posix/clock.c b/src/skins/posix/clock.c
index dc9a793..48d9aad 100644
--- a/src/skins/posix/clock.c
+++ b/src/skins/posix/clock.c
@@ -23,7 +23,7 @@
 #include <pthread.h>           /* For pthread_setcanceltype. */
 #include <posix/syscall.h>
 #include <time.h>
-#include <asm/xenomai/arith.h>
+#include <asm-generic/xenomai/bits/timeconv.h>
 
 extern int __pse51_muxid;
 
@@ -38,6 +38,7 @@ void pse51_clock_init(int muxid)
                        "sys_info: %s\n", strerror(err));
                exit(EXIT_FAILURE);
        }
+       xnarch_init_timeconv(sysinfo.cpufreq);
 }
 #endif /* XNARCH_HAVE_NONPRIV_TSC */
 
@@ -60,14 +61,10 @@ int __wrap_clock_gettime(clockid_t clock_id, struct 
timespec *tp)
        int err;
 #ifdef XNARCH_HAVE_NONPRIV_TSC
        if (clock_id == CLOCK_MONOTONIC && sysinfo.tickval == 1) {
-               unsigned long long tsc;
-               unsigned long rem;
-
-               tsc = __xn_rdtsc();
-               tp->tv_sec = xnarch_ulldiv(tsc, sysinfo.cpufreq, &rem);
-               /* Next line is 64 bits safe, since rem is less than
-                  sysinfo.cpufreq hence fits on 32 bits. */
-               tp->tv_nsec = xnarch_imuldiv(rem, 1000000000, sysinfo.cpufreq);
+               unsigned long long ns;
+
+               ns = xnarch_tsc_to_ns(__xn_rdtsc());
+               tp->tv_sec = xnarch_divrem_billion(ns, &tp->tv_nsec);
                return 0;
        }
 #endif /* XNARCH_HAVE_NONPRIV_TSC */


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

Reply via email to