From 66084b816dd25a41f774240328a31d57efd276e4 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 17 Sep 2009 03:18:51 +0000 Subject: Begin libsandglass implementation. --- src/x86/tsc-x86.s | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/x86') 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 -- cgit v1.2.3