comparison etc/tune.c @ 190:d8254fc979e9 libtommath-orig LTM_0.35

Initial import of libtommath 0.35
author Matt Johnston <matt@ucc.asn.au>
date Fri, 06 May 2005 08:59:30 +0000
parents d29b64170cf0
children
comparison
equal deleted inserted replaced
142:d29b64170cf0 190:d8254fc979e9
8 /* how many times todo each size mult. Depends on your computer. For slow computers 8 /* how many times todo each size mult. Depends on your computer. For slow computers
9 * this can be low like 5 or 10. For fast [re: Athlon] should be 25 - 50 or so 9 * this can be low like 5 or 10. For fast [re: Athlon] should be 25 - 50 or so
10 */ 10 */
11 #define TIMES (1UL<<14UL) 11 #define TIMES (1UL<<14UL)
12 12
13 /* RDTSC from Scott Duplichan */
14 static ulong64 TIMFUNC (void)
15 {
16 #if defined __GNUC__
17 #if defined(__i386__) || defined(__x86_64__)
18 unsigned long long a;
19 __asm__ __volatile__ ("rdtsc\nmovl %%eax,%0\nmovl %%edx,4+%0\n"::"m"(a):"%eax","%edx");
20 return a;
21 #else /* gcc-IA64 version */
22 unsigned long result;
23 __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory");
24 while (__builtin_expect ((int) result == -1, 0))
25 __asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory");
26 return result;
27 #endif
28
29 // Microsoft and Intel Windows compilers
30 #elif defined _M_IX86
31 __asm rdtsc
32 #elif defined _M_AMD64
33 return __rdtsc ();
34 #elif defined _M_IA64
35 #if defined __INTEL_COMPILER
36 #include <ia64intrin.h>
37 #endif
38 return __getReg (3116);
39 #else
40 #error need rdtsc function for this build
41 #endif
42 }
43
13 44
14 #ifndef X86_TIMER 45 #ifndef X86_TIMER
15 46
16 /* generic ISO C timer */ 47 /* generic ISO C timer */
17 ulong64 __T; 48 ulong64 LBL_T;
18 void t_start(void) { __T = clock(); } 49 void t_start(void) { LBL_T = TIMFUNC(); }
19 ulong64 t_read(void) { return clock() - __T; } 50 ulong64 t_read(void) { return TIMFUNC() - LBL_T; }
20 51
21 #else 52 #else
22 extern void t_start(void); 53 extern void t_start(void);
23 extern ulong64 t_read(void); 54 extern ulong64 t_read(void);
24 #endif 55 #endif