On 2006-05-15 15:57:30 +0200 David Chisnall <[EMAIL PROTECTED]> wrote:
[...]
I have tested the FreeBSD and Darwin back ends (the FreeBSD code
works on
FreeBSD 4.11 and 6.1), and the Linux code should have been tested
already.
[...]
Since you apparently have FreeBSD4.x available, try something like the
following.
You will have to come up with a definition for the #if statements,
theoretically #if (__FreeBSD_version < 5) should work.
#if ... (FreeBSD < 5)
static int64_t rdtsc(void)
{
unsigned int i, j;
#define RDTSC ".byte 0x0f, 0x31; "
asm(RDTSC : "=a"(i), "=d"(j) : );
return ((int64_t) j << 32) + (int64_t) i;
}
#endif
+ (unsigned int) cpuMHzSpeed
{
unsigned int speed = 0;
speed = (unsigned int)performIntegerSysctlNamed("hw.clockrate");
#if ... (FreeBSD < 5 )
if( 0 == speed )
{
int64_t tsc_start, tsc_end;
struct timeval tv_start, tv_end;
int usec_delay;
tsc_start = rdtsc();
gettimeofday(&tv_start, NULL);
usleep(100000);
tsc_end = rdtsc();
gettimeofday(&tv_end, NULL);
usec_delay = 1000000 * (tv_end.tv_sec - tv_start.tv_sec) +
(tv_end.tv_usec - tv_start.tv_usec);
speed = ((tsc_end - tsc_start) / usec_delay);
}
#endif
return speed;
}
--
Chris
_______________________________________________
Etoile-dev mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-dev