Parent Directory
|
Revision Log
Revision 42 - (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 : | Isibaar | 42 | #define CACHE_LINE 16 |
35 : | #define CACHE_ALIGN __declspec(align(CACHE_LINE)) | ||
36 : | |||
37 : | Isibaar | 3 | // needed for bitstream.h |
38 : | #define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax | ||
39 : | |||
40 : | // needed for timer.c | ||
41 : | static __inline int64_t read_counter() { | ||
42 : | int64_t ts; | ||
43 : | uint32_t ts1, ts2; | ||
44 : | |||
45 : | __asm { | ||
46 : | rdtsc | ||
47 : | mov ts1, eax | ||
48 : | mov ts2, edx | ||
49 : | } | ||
50 : | |||
51 : | ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); | ||
52 : | |||
53 : | return ts; | ||
54 : | } | ||
55 : | |||
56 : | #elif defined(LINUX) || defined(DJGPP) | ||
57 : | |||
58 : | chl | 37 | |
59 : | #ifdef _DEBUG | ||
60 : | |||
61 : | Isibaar | 3 | #include <stdio.h> |
62 : | #define DEBUG_WHERE stdout | ||
63 : | #define DEBUG(S) fprintf(DEBUG_WHERE, "%s\n", (S)); | ||
64 : | #define DEBUG1(S,I) fprintf(DEBUG_WHERE, "%s %i\n", (S), (I)) | ||
65 : | #define DEBUG2(S,A,B) fprintf(DEBUG_WHERE, "%s%i=%i\n", (S), (A), (B)) | ||
66 : | #define DEBUG3(S,A,B,C) fprintf(DEBUG_WHERE, "%s %i %x %x\n", (S), (A), (B), (C)) | ||
67 : | #define DEBUG8(S,A,B,C,D,E,F,G,H) | ||
68 : | chl | 37 | #else |
69 : | #define DEBUG(S) | ||
70 : | #define DEBUG1(S,I) | ||
71 : | #define DEBUG2(X,A,B) | ||
72 : | #define DEBUG3(X,A,B,C) | ||
73 : | #define DEBUG8(X,A,B,C,D,E,F,G,H) | ||
74 : | #endif | ||
75 : | Isibaar | 3 | |
76 : | Isibaar | 42 | #define CACHE_LINE 16 |
77 : | #define CACHE_ALIGN | ||
78 : | |||
79 : | Isibaar | 3 | #if defined(LINUX) |
80 : | |||
81 : | #include <stdint.h> | ||
82 : | |||
83 : | #else | ||
84 : | |||
85 : | #define int8_t char | ||
86 : | #define uint8_t unsigned char | ||
87 : | #define int16_t short | ||
88 : | #define uint16_t unsigned short | ||
89 : | #define int32_t int | ||
90 : | #define uint32_t unsigned int | ||
91 : | #define int64_t long long | ||
92 : | #define uint64_t unsigned long long | ||
93 : | |||
94 : | #endif | ||
95 : | |||
96 : | #define EMMS() __asm__("emms\n\t") | ||
97 : | |||
98 : | // needed for bitstream.h | ||
99 : | #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ) | ||
100 : | |||
101 : | // needed for timer.c | ||
102 : | static __inline int64_t read_counter() { | ||
103 : | int64_t ts; | ||
104 : | uint32_t ts1, ts2; | ||
105 : | |||
106 : | __asm__ __volatile__("rdtsc\n\t":"=a"(ts1), "=d"(ts2)); | ||
107 : | |||
108 : | ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); | ||
109 : | |||
110 : | return ts; | ||
111 : | } | ||
112 : | |||
113 : | #else // OTHER OS | ||
114 : | |||
115 : | #define DEBUG(S) | ||
116 : | #define DEBUG1(S,I) | ||
117 : | #define DEBUG2(X,A,B) | ||
118 : | #define DEBUG3(X,A,B,C) | ||
119 : | #define DEBUG8(X,A,B,C,D,E,F,G,H) | ||
120 : | |||
121 : | #include <inttypes.h> | ||
122 : | |||
123 : | #define EMMS() | ||
124 : | |||
125 : | // needed for bitstream.h | ||
126 : | #define BSWAP(a) \ | ||
127 : | ((a) = ( ((a)&0xff)<<24) | (((a)&0xff00)<<8) | (((a)>>8)&0xff00) | (((a)>>24)&0xff)) | ||
128 : | |||
129 : | // rdtsc command most likely not supported, | ||
130 : | // so just dummy code here | ||
131 : | static __inline int64_t read_counter() { | ||
132 : | return 0; | ||
133 : | } | ||
134 : | |||
135 : | Isibaar | 42 | #define CACHE_LINE 16 |
136 : | #define CACHE_ALIGN | ||
137 : | |||
138 : | Isibaar | 3 | #endif |
139 : | |||
140 : | #endif // _PORTAB_H_ | ||
141 : |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |