From: Stefan Agner <stefan@agner.ch>
To: linux-rt-users@vger.kernel.org
Subject: Re: [PATCH RESEND] cyclictest: calcdiff calculated wrong seconds if the difference was bigger than 2147s
Date: Wed, 27 May 2009 23:53:07 +0200 [thread overview]
Message-ID: <4A1DB643.60302@agner.ch> (raw)
In-Reply-To: <826434.45900.qm@web59805.mail.ac4.yahoo.com>
Hello,
My first fix didn't took into account that long is 4 byte long on ARM. Therefor
I changed it to long long now, which works on my ARM board...
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
src/cyclictest/cyclictest.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index be9a3f9..3035a0a 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -287,18 +287,18 @@ static inline void tsnorm(struct timespec *ts)
}
}
-static inline long calcdiff(struct timespec t1, struct timespec t2)
+static inline long long calcdiff(struct timespec t1, struct timespec t2)
{
- long diff;
- diff = USEC_PER_SEC * ((int) t1.tv_sec - (int) t2.tv_sec);
+ long long diff;
+ diff = USEC_PER_SEC * (long long)((int) t1.tv_sec - (int) t2.tv_sec);
diff += ((int) t1.tv_nsec - (int) t2.tv_nsec) / 1000;
return diff;
}
-static inline long calcdiff_ns(struct timespec t1, struct timespec t2)
+static inline long long calcdiff_ns(struct timespec t1, struct timespec t2)
{
- long diff;
- diff = NSEC_PER_SEC * ((int) t1.tv_sec - (int) t2.tv_sec);
+ long long diff;
+ diff = NSEC_PER_SEC * (long long)((int) t1.tv_sec - (int) t2.tv_sec);
diff += ((int) t1.tv_nsec - (int) t2.tv_nsec);
return diff;
}
-- 1.6.0.4
next prev parent reply other threads:[~2009-05-27 21:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-27 21:22 [PATCH] cyclictest: calcdiff calculated wrong seconds if the difference was bigger than 2147s Stefan Agner
[not found] ` <826434.45900.qm@web59805.mail.ac4.yahoo.com>
2009-05-27 21:53 ` Stefan Agner [this message]
2009-05-28 19:52 ` [PATCH RESEND] " Clark Williams
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=4A1DB643.60302@agner.ch \
--to=stefan@agner.ch \
--cc=linux-rt-users@vger.kernel.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.