Parent Directory
|
Revision Log
Revision 34 - (view) (download)
1 : | Isibaar | 3 | #ifndef _PORTAB_H_ |
2 : | #define _PORTAB_H_ | ||
3 : | |||
4 : | #if defined(WIN32) | ||
5 : | |||
6 : | #include <windows.h> | ||
7 : | |||
8 : | h | 34 | #ifdef _DEBUG |
9 : | Isibaar | 3 | #define DEBUG(S) OutputDebugString((S)); |
10 : | #define DEBUG1(S,I) { char tmp[100]; wsprintf(tmp, "%s %i\n", (S), (I)); OutputDebugString(tmp); } | ||
11 : | #define DEBUG2(X,A,B) { char tmp[100]; wsprintf(tmp, "%s %i %i\n", (X), (A), (B)); OutputDebugString(tmp); } | ||
12 : | #define DEBUG3(X,A,B,C){ char tmp[1000]; wsprintf(tmp,"%s %i %i %i",(X),(A), (B), (C)); OutputDebugString(tmp); } | ||
13 : | #define DEBUG8(X,A,B,C,D,E,F,G,H){ char tmp[1000]; wsprintf(tmp,"%s %i %i %i %i %i %i %i %i",(X),(A),(B),(C),(D),(E),(F),(G),(H)); OutputDebugString(tmp); } | ||
14 : | h | 34 | #else |
15 : | #define DEBUG(S) | ||
16 : | #define DEBUG1(S,I) | ||
17 : | #define DEBUG2(X,A,B) | ||
18 : | #define DEBUG3(X,A,B,C) | ||
19 : | #define DEBUG8(X,A,B,C,D,E,F,G,H) | ||
20 : | #endif | ||
21 : | Isibaar | 3 | |
22 : | |||
23 : | #define int8_t char | ||
24 : | #define uint8_t unsigned char | ||
25 : | #define int16_t short | ||
26 : | #define uint16_t unsigned short | ||
27 : | #define int32_t int | ||
28 : | #define uint32_t unsigned int | ||
29 : | #define int64_t __int64 | ||
30 : | #define uint64_t unsigned __int64 | ||
31 : | |||
32 : | #define EMMS() __asm {emms} | ||
33 : | |||
34 : | // needed for bitstream.h | ||
35 : | #define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax | ||
36 : | |||
37 : | // needed for timer.c | ||
38 : | static __inline int64_t read_counter() { | ||
39 : | int64_t ts; | ||
40 : | uint32_t ts1, ts2; | ||
41 : | |||
42 : | __asm { | ||
43 : | rdtsc | ||
44 : | mov ts1, eax | ||
45 : | mov ts2, edx | ||
46 : | } | ||
47 : | |||
48 : | ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); | ||
49 : | |||
50 : | return ts; | ||
51 : | } | ||
52 : | |||
53 : | #elif defined(LINUX) || defined(DJGPP) | ||
54 : | |||
55 : | #include <stdio.h> | ||
56 : | #define DEBUG_WHERE stdout | ||
57 : | #define DEBUG(S) fprintf(DEBUG_WHERE, "%s\n", (S)); | ||
58 : | #define DEBUG1(S,I) fprintf(DEBUG_WHERE, "%s %i\n", (S), (I)) | ||
59 : | #define DEBUG2(S,A,B) fprintf(DEBUG_WHERE, "%s%i=%i\n", (S), (A), (B)) | ||
60 : | #define DEBUG3(S,A,B,C) fprintf(DEBUG_WHERE, "%s %i %x %x\n", (S), (A), (B), (C)) | ||
61 : | #define DEBUG8(S,A,B,C,D,E,F,G,H) | ||
62 : | |||
63 : | #if defined(LINUX) | ||
64 : | |||
65 : | #include <stdint.h> | ||
66 : | |||
67 : | #else | ||
68 : | |||
69 : | #define int8_t char | ||
70 : | #define uint8_t unsigned char | ||
71 : | #define int16_t short | ||
72 : | #define uint16_t unsigned short | ||
73 : | #define int32_t int | ||
74 : | #define uint32_t unsigned int | ||
75 : | #define int64_t long long | ||
76 : | #define uint64_t unsigned long long | ||
77 : | |||
78 : | #endif | ||
79 : | |||
80 : | #define EMMS() __asm__("emms\n\t") | ||
81 : | |||
82 : | // needed for bitstream.h | ||
83 : | #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ) | ||
84 : | |||
85 : | // needed for timer.c | ||
86 : | static __inline int64_t read_counter() { | ||
87 : | int64_t ts; | ||
88 : | uint32_t ts1, ts2; | ||
89 : | |||
90 : | __asm__ __volatile__("rdtsc\n\t":"=a"(ts1), "=d"(ts2)); | ||
91 : | |||
92 : | ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); | ||
93 : | |||
94 : | return ts; | ||
95 : | } | ||
96 : | |||
97 : | #else // OTHER OS | ||
98 : | |||
99 : | #define DEBUG(S) | ||
100 : | #define DEBUG1(S,I) | ||
101 : | #define DEBUG2(X,A,B) | ||
102 : | #define DEBUG3(X,A,B,C) | ||
103 : | #define DEBUG8(X,A,B,C,D,E,F,G,H) | ||
104 : | |||
105 : | #include <inttypes.h> | ||
106 : | |||
107 : | #define EMMS() | ||
108 : | |||
109 : | // needed for bitstream.h | ||
110 : | #define BSWAP(a) \ | ||
111 : | ((a) = ( ((a)&0xff)<<24) | (((a)&0xff00)<<8) | (((a)>>8)&0xff00) | (((a)>>24)&0xff)) | ||
112 : | |||
113 : | // rdtsc command most likely not supported, | ||
114 : | // so just dummy code here | ||
115 : | static __inline int64_t read_counter() { | ||
116 : | return 0; | ||
117 : | } | ||
118 : | |||
119 : | #endif | ||
120 : | |||
121 : | #endif // _PORTAB_H_ | ||
122 : |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |