4 // gives access to the Pentium's (secret) cycle counter
6 // This software was written by Leonard Janke (janke@unixg.ubc.ca)
7 // in 1996-7 and is entered, by him, into the public domain.
9 #if defined(__WATCOMC__)
10 void GetTSC(unsigned long&);
11 #pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax];
12 #elif defined(__GNUC__)
14 void GetTSC(unsigned long& tsc
)
16 asm volatile(".byte 15, 49\n\t"
21 #elif defined(_MSC_VER)
23 void GetTSC(unsigned long& tsc
)
35 #include <openssl/cast.h>
37 void main(int argc
,char *argv
[])
40 unsigned long s1
,s2
,e1
,e2
;
41 unsigned long data
[2];
43 static unsigned char d
[16]={0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF};
45 CAST_set_key(&key
, 16,d
);
49 for (i
=0; i
<1000; i
++) /**/
51 CAST_encrypt(&data
[0],&key
);
53 CAST_encrypt(&data
[0],&key
);
54 CAST_encrypt(&data
[0],&key
);
55 CAST_encrypt(&data
[0],&key
);
58 CAST_encrypt(&data
[0],&key
);
59 CAST_encrypt(&data
[0],&key
);
60 CAST_encrypt(&data
[0],&key
);
61 CAST_encrypt(&data
[0],&key
);
63 CAST_encrypt(&data
[0],&key
);
66 printf("cast %d %d (%d)\n",
67 e1
-s1
,e2
-s2
,((e2
-s2
)-(e1
-s1
)));