~ubuntu-branches/ubuntu/utopic/dropbear/utopic-proposed

« back to all changes in this revision

Viewing changes to libtommath/etc/tune.c

  • Committer: Bazaar Package Importer
  • Author(s): Matt Johnston
  • Date: 2005-12-08 19:20:21 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051208192021-nyp9rwnt77nsg6ty
Tags: 0.47-1
* New upstream release.
* SECURITY: Fix incorrect buffer sizing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 */
11
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
45
#ifndef X86_TIMER
15
46
 
16
47
/* generic ISO C timer */
17
 
ulong64 __T;
18
 
void t_start(void) { __T = clock(); }
19
 
ulong64 t_read(void) { return clock() - __T; }
 
48
ulong64 LBL_T;
 
49
void t_start(void) { LBL_T = TIMFUNC(); }
 
50
ulong64 t_read(void) { return TIMFUNC() - LBL_T; }
20
51
 
21
52
#else
22
53
extern void t_start(void);