cyclictest: calcdiff calculated wrong seconds if the difference was bigger than 2147s
PATCH 1/1 cyclictest: calcdiff calculated wrong seconds if the difference was bigger than 2147s
--- src/cyclictest/cyclictest.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
src/cyclictest/cyclictest.c +2 -2
@@ -290,7 +290,7 @@ static inline void tsnorm(struct timespec *ts)static inline long calcdiff (struct timespec t1,struct timespec t2) {long diff; - diff =USEC_PER_SEC * ((int ) t1.tv_sec - (int ) t2.tv_sec); + diff =USEC_PER_SEC * (long )((int ) t1.tv_sec - (int ) t2.tv_sec); diff += ((int ) t1.tv_nsec - (int ) t2.tv_nsec) /1000 ;return diff; }
@@ -298,7 +298,7 @@ static inline long calcdiff(struct timespec t1, struct timespec t2)static inline long calcdiff_ns (struct timespec t1,struct timespec t2) {long diff; - diff =NSEC_PER_SEC * ((int ) t1.tv_sec - (int ) t2.tv_sec); + diff =NSEC_PER_SEC * (long )((int ) t1.tv_sec - (int ) t2.tv_sec); diff += ((int ) t1.tv_nsec - (int ) t2.tv_nsec);return diff; }
A message that is not in the archive (sent off-list or not yet received): [email protected]
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...
--- src/cyclictest/cyclictest.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
src/cyclictest/cyclictest.c +6 -6
@@ -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
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 6 lines · On Wed, 27 May 2009 23:53:07 +0200 Stefan Agner <[email protected]> wrote:
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...
Thanks Stefan, applied.
Clark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (GNU/Linux)
iEYEARECAAYFAkoe63cACgkQHyuj/+TTEp0T8ACfTMRPJYfY3gb+RKZ4iWKMHytV qDUAoNhorhydnzIOD8TfDoNYyQA2McVl
=LXAh
-----END PGP SIGNATURE-----