All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Steve <sbxenomai@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] Xenomai 2.5-rc2 clock_gettime bad tv_nsec value
Date: Thu, 20 Aug 2009 12:45:48 +0200	[thread overview]
Message-ID: <4A8D295C.2080402@domain.hid> (raw)
In-Reply-To: <abaf774b0908190246j61f0e841s60a1b284ab1bb86@domain.hid>

Steve wrote:
> On 19/08/2009, Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org> wrote:
>> Steve wrote:
>>> Were you going to delay handling this until later, or were you hoping
>>> it wouldn't be a problem?  If it's the former then this is not my
>>> number one priority at the moment, so from my perspective I can wait
>>> until the next release candidate / release.
>> To be completely frank, I was not really worried about this issue, since
>> you had not answered, I thought that maybe the issue was in your test
>> program.
>>
>>> Linux kernel: 2.6.29.4
>>> Xenomai: 2.5-rc2
>>> Adeos: adeos-ipipe-2.6.29.4-x86-2.4-01
>>>
>>> OS: Ubuntu (8.04 with updates)
>>> Hardware:
>>> Intel Core 2 CPU, kernel compiled using processor family 'Pentium-4/etc'
>> compiled for 32 or 64 bits?
>>
>> --
>>                                           Gilles
>>
>>
> 
> 32 bit,

Ok. It turns out that the error is portable, and there is no other way
than to fix the result after the multiplication (trying to round
differently leads to the converse error). So, could you try the
following patch:

diff --git a/include/asm-generic/bits/timeconv.h
b/include/asm-generic/bits/time
index 79060b3..aa595fe 100644
--- a/include/asm-generic/bits/timeconv.h
+++ b/include/asm-generic/bits/timeconv.h
@@ -60,10 +60,17 @@ long long xnarch_ns_to_tsc(long long ns)
 unsigned long long xnarch_divrem_billion(unsigned long long value,
                                         unsigned long *rem)
 {
-       unsigned long long r;
-       r = xnarch_nodiv_ullimd(value, bln_frac.frac, bln_frac.integ);
-       *rem = value - r * 1000000000;
-       return r;
+       unsigned long long q;
+       unsigned r;
+
+       q = xnarch_nodiv_ullimd(value, bln_frac.frac, bln_frac.integ);
+       r = value - q * 1000000000;
+       if (r >= 1000000000) {
+               ++q;
+               r -= 1000000000;
+       }
+       *rem = r;
+       return q;
 }
 #else /* !XNARCH_HAVE_NODIV_LLIMD */
 long long xnarch_ns_to_tsc(long long ns)


-- 
					    Gilles.


  parent reply	other threads:[~2009-08-20 10:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-04 13:23 [Xenomai-help] Xenomai 2.5-rc2 clock_gettime bad tv_nsec value Steve
2009-08-07  6:08 ` Gilles Chanteperdrix
2009-08-19  8:27   ` Steve
2009-08-19  8:40     ` Gilles Chanteperdrix
2009-08-19  9:29       ` Steve
2009-08-19  9:37         ` Gilles Chanteperdrix
2009-08-19  9:46           ` Steve
2009-08-19 12:42             ` Gilles Chanteperdrix
2009-08-20 10:45             ` Gilles Chanteperdrix [this message]
2009-08-26 15:18               ` Steve
2009-08-26 15:24                 ` Gilles Chanteperdrix

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=4A8D295C.2080402@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=sbxenomai@domain.hid \
    --cc=xenomai@xenomai.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.