summaryrefslogtreecommitdiffstats
path: root/src/x86_64/tsc-x86_64.s
diff options
context:
space:
mode:
Diffstat (limited to 'src/x86_64/tsc-x86_64.s')
-rw-r--r--src/x86_64/tsc-x86_64.s17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/x86_64/tsc-x86_64.s b/src/x86_64/tsc-x86_64.s
index c585719..52f02c2 100644
--- a/src/x86_64/tsc-x86_64.s
+++ b/src/x86_64/tsc-x86_64.s
@@ -38,3 +38,20 @@ sandglass_get_tsc:
movq %rdi, %rbx
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