diff options
| author | Mark Murray <markm@FreeBSD.org> | 2000-11-21 19:55:21 +0000 |
|---|---|---|
| committer | Mark Murray <markm@FreeBSD.org> | 2000-11-21 19:55:21 +0000 |
| commit | 58550067673ef1af57be0eb5f9565d6007e8acda (patch) | |
| tree | dc95ee4c03b1b27bb867b5b969b4037f426bc316 /sys/amd64/include | |
| parent | c6fa9f78d2ffa31f403b2d8830b53cf10d1384c0 (diff) | |
Notes
Diffstat (limited to 'sys/amd64/include')
| -rw-r--r-- | sys/amd64/include/cpu.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sys/amd64/include/cpu.h b/sys/amd64/include/cpu.h index 7b090b66c81c..669af64c1b47 100644 --- a/sys/amd64/include/cpu.h +++ b/sys/amd64/include/cpu.h @@ -47,6 +47,8 @@ #include <machine/frame.h> #include <machine/segments.h> #include <machine/globals.h> +#include <machine/md_var.h> +#include <machine/specialreg.h> /* * definitions of cpu-dependent requirements @@ -133,6 +135,25 @@ extern char etext[]; void fork_trampoline __P((void)); void fork_return __P((struct proc *, struct trapframe)); + +/* + * Return contents of in-cpu fast counter as a sort of "bogo-time" + * for non-critical timing. + */ +static __inline u_int64_t +get_cyclecount(void) +{ +#if defined(I386_CPU) || defined(I486_CPU) + struct timespec tv; + + if ((cpu_feature & CPUID_TSC) == 0) { + nanotime(&tv); + return (tv.tv_sec * (u_int64_t)1000000000 + tv.tv_nsec); + } +#endif + return (rdtsc()); +} + #endif #endif /* !_MACHINE_CPU_H_ */ |
