ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/devel.h
(Generate patch)

Comparing deliantra/server/include/devel.h (file contents):
Revision 1.2 by root, Tue Dec 30 07:24:16 2008 UTC vs.
Revision 1.3 by root, Wed Dec 31 17:35:37 2008 UTC

25 25
26#ifndef DEVEL_H 26#ifndef DEVEL_H
27#define DEVEL_H 27#define DEVEL_H
28 28
29// used for benchmarking (x86/amd64-specific) 29// used for benchmarking (x86/amd64-specific)
30#ifdef DEVEL64
30typedef unsigned int cstamp; 31typedef uint64_t cstamp;
32#else
33typedef uint32_t cstamp;
34#endif
35
36#if defined(__i386__) || defined(__x86_64__)
31 37
32static inline cstamp 38static inline cstamp
33stamp (void) 39stamp (void)
34{ 40{
35 cstamp tsc; 41 uint32_t l, h;
42
36 asm volatile ("rdtsc" : "=a" (tsc) : : "edx"); 43 asm volatile ("rdtsc" : "=a" (l), "=d" (h));
44
45#ifdef DEVEL64
46 return ((cstamp)h << 32) | l;
47#else
37 return tsc; 48 return l;
49#endif
38} 50}
51
52#elif defined(__powerpc__)
53static inline cstamp
54stamp (void)
55{
56 unsigned uint32_t u, l, tmp;
57
58 asm volatile (
59 "0: \n"
60 "\tmftbu %0 \n"
61 "\tmftb %1 \n"
62 "\tmftbu %2 \n"
63 "\tcmpw %2,%0\n"
64 "\tbne 0b \n"
65 : "=r" (h), "=r" (l), "=r" (tmp)
66 );
67
68#ifdef DEVEL64
69 return ((cstamp)h << 32) | l;
70#else
71 return l;
72#endif
73}
74
75#endif
39 76
40static inline cstamp 77static inline cstamp
41measure (cstamp t) 78measure (cstamp t)
42{ 79{
43 return stamp () - t; 80 return stamp () - t;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines