summaryrefslogtreecommitdiffstats
path: root/src/x86/tsc-x86.s
diff options
context:
space:
mode:
Diffstat (limited to 'src/x86/tsc-x86.s')
-rw-r--r--src/x86/tsc-x86.s17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/x86/tsc-x86.s b/src/x86/tsc-x86.s
index 570b8af..46013bb 100644
--- a/src/x86/tsc-x86.s
+++ b/src/x86/tsc-x86.s
@@ -38,3 +38,20 @@ sandglass_get_tsc:
popl %ebx
ret
.size sandglass_get_tsc, .-sandglass_get_tsc
+
+/*
+ * Return the granularity of the TSC
+ */
+
+/* unsigned int sandglass_tsc_loops(); */
+.globl sandglass_tsc_loops
+ .type sandglass_tsc_loops, @function
+sandglass_tsc_loops:
+ rdtsc /* Read time stamp counter */
+ movl %eax, %ecx
+.Lrdtsc:
+ rdtsc /* Read counter again */
+ subl %ecx, %eax
+ jz .Lrdtsc /* If we got the same value, try again */
+ ret
+ .size sandglass_tsc_loops, .-sandglass_tsc_loops