diff options
author | Kevin B Kenny <kennykb@acm.org> | 2005-04-10 23:54:55 (GMT) |
---|---|---|
committer | Kevin B Kenny <kennykb@acm.org> | 2005-04-10 23:54:55 (GMT) |
commit | 9c989aeec930a9251ba5eddc6a81898a5c91ee0e (patch) | |
tree | 8809a65920a763a8894572aee81a71eeff4b2c82 /libtommath/etc/tune.c | |
parent | 2168824a1ddf134001dd68311befeb7d58dddd38 (diff) | |
download | tcl-9c989aeec930a9251ba5eddc6a81898a5c91ee0e.zip tcl-9c989aeec930a9251ba5eddc6a81898a5c91ee0e.tar.gz tcl-9c989aeec930a9251ba5eddc6a81898a5c91ee0e.tar.bz2 |
Import of tommath 0.35
Diffstat (limited to 'libtommath/etc/tune.c')
-rw-r--r-- | libtommath/etc/tune.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/libtommath/etc/tune.c b/libtommath/etc/tune.c index 14aace2..d054d10 100644 --- a/libtommath/etc/tune.c +++ b/libtommath/etc/tune.c @@ -10,13 +10,44 @@ */ #define TIMES (1UL<<14UL) +/* RDTSC from Scott Duplichan */ +static ulong64 TIMFUNC (void) + { + #if defined __GNUC__ + #if defined(__i386__) || defined(__x86_64__) + unsigned long long a; + __asm__ __volatile__ ("rdtsc\nmovl %%eax,%0\nmovl %%edx,4+%0\n"::"m"(a):"%eax","%edx"); + return a; + #else /* gcc-IA64 version */ + unsigned long result; + __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory"); + while (__builtin_expect ((int) result == -1, 0)) + __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory"); + return result; + #endif + + // Microsoft and Intel Windows compilers + #elif defined _M_IX86 + __asm rdtsc + #elif defined _M_AMD64 + return __rdtsc (); + #elif defined _M_IA64 + #if defined __INTEL_COMPILER + #include <ia64intrin.h> + #endif + return __getReg (3116); + #else + #error need rdtsc function for this build + #endif + } + #ifndef X86_TIMER /* generic ISO C timer */ ulong64 LBL_T; -void t_start(void) { LBL_T = clock(); } -ulong64 t_read(void) { return clock() - LBL_T; } +void t_start(void) { LBL_T = TIMFUNC(); } +ulong64 t_read(void) { return TIMFUNC() - LBL_T; } #else extern void t_start(void); |