Hi,
On 21/03/07, Todd T. Fries <address@hidden> wrote:
> This is relative to the 20070319 snapshot.
>
> --- cpu-all.h.orig Fri Mar 16 18:58:11 2007
> +++ cpu-all.h Tue Mar 20 21:14:10 2007
> @@ -1012,13 +1012,22 @@ static inline int64_t cpu_get_real_ticks
> #endif
> }
> #else
> -/* The host CPU doesn't have an easily accessible cycle counter.
> - Just return a monotonically increasing vlue. This will be totally wrong,
> - but hopefully better than nothing. */
> +# warning non-optimized CPU
> +#include <sys/time.h>
> +#include <time.h>
> +
> static inline int64_t cpu_get_real_ticks (void)
> {
> - static int64_t ticks = 0;
> - return ticks++;
> + struct timeval tv;
> + static int64_t i = 0;
> + int64_t j;
> +
> + gettimeofday(&tv, NULL);
> + do {
> + j = (tv.tv_sec * (uint64_t) 1000000) + tv.tv_usec;
> + } while (i == j);
> + i = j;
> + return j;
Isn't this an infinite loop? gettimeofday() was left out of the loop.
How about "return j + (ticks++)" instead of the loop? If I understand
correctly it may slow things down to below 1Hz.