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