Module: xenomai-abe
Branch: analogy
Commit: 9431818fd4f0641e8176137c0b44cdc3efcb4109
URL:    
http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=9431818fd4f0641e8176137c0b44cdc3efcb4109

Author: Alexis Berlemont <alexis.berlem...@gmail.com>
Date:   Wed Dec 23 00:21:18 2009 +0100

analogy: fix wrong use of the type unsigned long long in time retrieval

---

 include/analogy/os_facilities.h      |    4 ++--
 ksrc/drivers/analogy/instruction.c   |   14 +++++++++-----
 ksrc/drivers/analogy/os_facilities.c |   10 +++++-----
 3 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/include/analogy/os_facilities.h b/include/analogy/os_facilities.h
index 2d882e2..efaacbd 100644
--- a/include/analogy/os_facilities.h
+++ b/include/analogy/os_facilities.h
@@ -123,13 +123,13 @@ static inline void a4l_udelay(unsigned int us)
        rtdm_task_busy_sleep(((nanosecs_rel_t) us) * 1000);
 }
 
-static inline unsigned long long a4l_get_rawtime(void)
+static inline nanosecs_abs_t a4l_get_rawtime(void)
 {
        return rtdm_clock_read();
 }
 
 /* Function which gives absolute time */
-unsigned long long a4l_get_time(void);
+nanosecs_abs_t a4l_get_time(void);
 
 /* Function for setting up the absolute time recovery */
 void a4l_init_time(void);
diff --git a/ksrc/drivers/analogy/instruction.c 
b/ksrc/drivers/analogy/instruction.c
index 5ecb366..a2fb4ce 100644
--- a/ksrc/drivers/analogy/instruction.c
+++ b/ksrc/drivers/analogy/instruction.c
@@ -35,20 +35,24 @@
 
 int a4l_do_insn_gettime(a4l_kinsn_t * dsc)
 {
-       unsigned long long ns;
-       unsigned long ns2;
+       nanosecs_abs_t ns;
+       uint32_t ns2;
+
+       uint32_t *data = (uint32_t *)dsc->data;
 
        /* Basic checkings */
-       if (dsc->data_size != 2) {
+       if (dsc->data_size != 2 * sizeof(uint32_t)) {
                __a4l_err("a4l_do_insn_gettime: data size should be 2\n");
                return -EINVAL;
        }
 
+       /* Get a timestamp */
        ns = a4l_get_time();
 
+       /* Perform the conversion */
        ns2 = do_div(ns, 1000000000);
-       dsc->data[0] = (lsampl_t) ns;
-       dsc->data[1] = (lsampl_t) ns2 / 1000;
+       data[0] = (uint32_t) ns;
+       data[1] = (uint32_t) ns2 / 1000;
 
        return 0;
 }
diff --git a/ksrc/drivers/analogy/os_facilities.c 
b/ksrc/drivers/analogy/os_facilities.c
index 1b6c554..620906e 100644
--- a/ksrc/drivers/analogy/os_facilities.c
+++ b/ksrc/drivers/analogy/os_facilities.c
@@ -31,20 +31,20 @@
 
 /* --- Time section --- */
 
-static unsigned long long a4l_clkofs;
+static nanosecs_abs_t a4l_clkofs;
 
 void a4l_init_time(void)
 {
-       unsigned long long t1, t2;
+       nanosecs_abs_t t1, t2;
        struct timeval tv;
        t1 = a4l_get_rawtime();
        do_gettimeofday(&tv);
-       t2 = 1000000000 * ((unsigned long long)tv.tv_sec) +
-               1000000 * ((unsigned long long)tv.tv_usec);
+       t2 = 1000000000 * ((nanosecs_abs_t)tv.tv_sec) +
+               1000000 * ((nanosecs_abs_t)tv.tv_usec);
        a4l_clkofs = t2 - t1;
 }
 
-unsigned long long a4l_get_time(void)
+nanosecs_abs_t a4l_get_time(void)
 {
        return a4l_clkofs + a4l_get_rawtime();
 }


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

Reply via email to