This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
clock() problem?
- To: ecos-discuss at sourceware dot cygnus dot com
- Subject: [ECOS] clock() problem?
- From: Chris Houston <chouston at logikos dot com>
- Date: Wed, 15 Nov 2000 08:23:38 -0500
- Organization: Logikos
- Reply-To: chouston at logikos dot com
Has anyone else encountered strange behaviour when using the "clock()"
function? When I use it, the result seems to roll over int 16 bits.
In packages/language/c/libc/time/v1_x_x/src/clock.cxx, in the clock()
function, if I change
clocks = ((clock_t)curr_clock * resolution.dividend) /
(resolution.divisor * (1000000000 / CLOCKS_PER_SEC));
to
clocks = (clock_t)((curr_clock * resolution.dividend) /
(resolution.divisor * (1000000000 / CLOCKS_PER_SEC)));
then the function seems to behave correctly. It seems that in
the first case, the multiplication in the numerator gets truncated to
32 bits.