Parent Directory | Revision Log
Revision 195 - (view) (download)
1 : | Isibaar | 3 | #ifndef _PORTAB_H_ |
2 : | #define _PORTAB_H_ | ||
3 : | |||
4 : | #if defined(WIN32) | ||
5 : | |||
6 : | #include <windows.h> | ||
7 : | suxen_drol | 136 | #include <stdio.h> |
8 : | Isibaar | 3 | |
9 : | suxen_drol | 136 | |
10 : | #define DPRINTF_BUF_SZ 1024 | ||
11 : | edgomez | 195 | static void |
12 : | dprintf(char *fmt, | ||
13 : | ...) | ||
14 : | suxen_drol | 136 | { |
15 : | va_list args; | ||
16 : | char buf[DPRINTF_BUF_SZ]; | ||
17 : | |||
18 : | va_start(args, fmt); | ||
19 : | vsprintf(buf, fmt, args); | ||
20 : | OutputDebugString(buf); | ||
21 : | fprintf(stdout, "%s\n", buf); | ||
22 : | } | ||
23 : | |||
24 : | |||
25 : | h | 108 | #define DEBUGCBR(A,B,C) { char tmp[100]; wsprintf(tmp, "CBR: frame: %i, quant: %i, deviation: %i\n", (A), (B), (C)); OutputDebugString(tmp); } |
26 : | |||
27 : | h | 34 | #ifdef _DEBUG |
28 : | Isibaar | 3 | #define DEBUG(S) OutputDebugString((S)); |
29 : | #define DEBUG1(S,I) { char tmp[100]; wsprintf(tmp, "%s %i\n", (S), (I)); OutputDebugString(tmp); } | ||
30 : | #define DEBUG2(X,A,B) { char tmp[100]; wsprintf(tmp, "%s %i %i\n", (X), (A), (B)); OutputDebugString(tmp); } | ||
31 : | #define DEBUG3(X,A,B,C){ char tmp[1000]; wsprintf(tmp,"%s %i %i %i",(X),(A), (B), (C)); OutputDebugString(tmp); } | ||
32 : | chenm001 | 161 | #define DEBUG4(X,A,B,C,D){ char tmp[1000]; wsprintf(tmp,"%s %i %i %i %i",(X),(A), (B), (C), (D)); OutputDebugString(tmp); } |
33 : | Isibaar | 3 | #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); } |
34 : | h | 34 | #else |
35 : | #define DEBUG(S) | ||
36 : | #define DEBUG1(S,I) | ||
37 : | #define DEBUG2(X,A,B) | ||
38 : | #define DEBUG3(X,A,B,C) | ||
39 : | chenm001 | 161 | #define DEBUG4(X,A,B,C,D) |
40 : | h | 34 | #define DEBUG8(X,A,B,C,D,E,F,G,H) |
41 : | #endif | ||
42 : | Isibaar | 3 | |
43 : | |||
44 : | #define int8_t char | ||
45 : | #define uint8_t unsigned char | ||
46 : | #define int16_t short | ||
47 : | #define uint16_t unsigned short | ||
48 : | #define int32_t int | ||
49 : | #define uint32_t unsigned int | ||
50 : | #define int64_t __int64 | ||
51 : | #define uint64_t unsigned __int64 | ||
52 : | |||
53 : | #define EMMS() __asm {emms} | ||
54 : | |||
55 : | Isibaar | 42 | #define CACHE_LINE 16 |
56 : | edgomez | 78 | |
57 : | suxen_drol | 68 | #if _MSC_VER <= 1200 |
58 : | h | 80 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
59 : | edgomez | 78 | type name##_storage[(sizex)*(sizey)+(alignment)-1]; \ |
60 : | type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1)) | ||
61 : | suxen_drol | 68 | #else |
62 : | h | 80 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
63 : | edgomez | 88 | __declspec(align(alignment)) type name[(sizex)*(sizey)] |
64 : | suxen_drol | 68 | #endif |
65 : | Isibaar | 42 | |
66 : | Isibaar | 3 | // needed for bitstream.h |
67 : | #define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax | ||
68 : | |||
69 : | // needed for timer.c | ||
70 : | edgomez | 195 | static __inline int64_t |
71 : | read_counter() | ||
72 : | { | ||
73 : | Isibaar | 3 | int64_t ts; |
74 : | uint32_t ts1, ts2; | ||
75 : | |||
76 : | __asm { | ||
77 : | edgomez | 195 | rdtsc mov ts1, eax mov ts2, edx} |
78 : | |||
79 : | Isibaar | 3 | ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); |
80 : | edgomez | 195 | |
81 : | Isibaar | 3 | return ts; |
82 : | } | ||
83 : | |||
84 : | knhor | 129 | #elif defined(LINUX) || defined(DJGPP) || defined(FREEBSD) |
85 : | Isibaar | 3 | |
86 : | chl | 37 | #ifdef _DEBUG |
87 : | |||
88 : | Isibaar | 3 | #include <stdio.h> |
89 : | edgomez | 78 | #define DEBUG_WHERE stdout |
90 : | #define DEBUG(S) fprintf(DEBUG_WHERE, "%s\n", (S)); | ||
91 : | #define DEBUG1(S,I) fprintf(DEBUG_WHERE, "%s %i\n", (S), (I)) | ||
92 : | #define DEBUG2(S,A,B) fprintf(DEBUG_WHERE, "%s%i=%i\n", (S), (A), (B)) | ||
93 : | #define DEBUG3(S,A,B,C) fprintf(DEBUG_WHERE, "%s %i %x %x\n", (S), (A), (B), (C)) | ||
94 : | Isibaar | 3 | #define DEBUG8(S,A,B,C,D,E,F,G,H) |
95 : | h | 108 | #define DEBUGCBR(A,B,C) fprintf(DEBUG_WHERE, "CBR: frame: %i, quant: %i, deviation: %i\n", (A), (B), (C)) |
96 : | chl | 37 | #else |
97 : | #define DEBUG(S) | ||
98 : | #define DEBUG1(S,I) | ||
99 : | #define DEBUG2(X,A,B) | ||
100 : | #define DEBUG3(X,A,B,C) | ||
101 : | #define DEBUG8(X,A,B,C,D,E,F,G,H) | ||
102 : | h | 108 | #define DEBUGCBR(A,B,C) |
103 : | chl | 37 | #endif |
104 : | Isibaar | 3 | |
105 : | Isibaar | 42 | #define CACHE_LINE 16 |
106 : | |||
107 : | Isibaar | 3 | #if defined(LINUX) |
108 : | |||
109 : | #include <stdint.h> | ||
110 : | |||
111 : | canard | 73 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
112 : | type name##_storage[(sizex)*(sizey)+(alignment)-1]; \ | ||
113 : | edgomez | 78 | type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1)) |
114 : | canard | 73 | |
115 : | Isibaar | 3 | #else |
116 : | |||
117 : | knhor | 129 | #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
118 : | edgomez | 78 | __attribute__ ((__aligned__(CACHE_LINE))) type name[(sizex)*(sizey)] |
119 : | |||
120 : | #define int8_t char | ||
121 : | #define uint8_t unsigned char | ||
122 : | #define int16_t short | ||
123 : | Isibaar | 3 | #define uint16_t unsigned short |
124 : | edgomez | 78 | #define int32_t int |
125 : | Isibaar | 3 | #define uint32_t unsigned int |
126 : | edgomez | 78 | #define int64_t long long |
127 : | Isibaar | 3 | #define uint64_t unsigned long long |
128 : | |||
129 : | #endif | ||
130 : | |||
131 : | |||
132 : | // needed for bitstream.h | ||
133 : | canard | 45 | #ifdef ARCH_PPC |
134 : | edgomez | 195 | #define BSWAP(a) __asm__ __volatile__ ( "lwbrx %0,0,%1; eieio" : "=r" (a) : \ |
135 : | canard | 45 | "r" (&(a)), "m" (a)); |
136 : | edgomez | 195 | #define EMMS() |
137 : | canard | 89 | |
138 : | edgomez | 195 | static __inline unsigned long |
139 : | get_tbl(void) | ||
140 : | { | ||
141 : | unsigned long tbl; | ||
142 : | asm volatile ("mftb %0":"=r" (tbl)); | ||
143 : | |||
144 : | return tbl; | ||
145 : | } | ||
146 : | static __inline unsigned long | ||
147 : | get_tbu(void) | ||
148 : | { | ||
149 : | unsigned long tbl; | ||
150 : | asm volatile ("mftbu %0":"=r" (tbl)); | ||
151 : | |||
152 : | return tbl; | ||
153 : | } | ||
154 : | static __inline int64_t | ||
155 : | read_counter() | ||
156 : | { | ||
157 : | unsigned long tb, tu; | ||
158 : | |||
159 : | do { | ||
160 : | tu = get_tbu(); | ||
161 : | tb = get_tbl(); | ||
162 : | } while (tb != get_tbl()); | ||
163 : | return (((int64_t) tu) << 32) | (int64_t) tb; | ||
164 : | } | ||
165 : | canard | 45 | #else |
166 : | edgomez | 195 | #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ) |
167 : | #define EMMS() __asm__("emms\n\t") | ||
168 : | Isibaar | 3 | |
169 : | edgomez | 78 | |
170 : | Isibaar | 3 | // needed for timer.c |
171 : | edgomez | 195 | static __inline int64_t |
172 : | read_counter() | ||
173 : | { | ||
174 : | int64_t ts; | ||
175 : | uint32_t ts1, ts2; | ||
176 : | Isibaar | 3 | |
177 : | edgomez | 195 | __asm__ __volatile__("rdtsc\n\t":"=a"(ts1), |
178 : | "=d"(ts2)); | ||
179 : | Isibaar | 3 | |
180 : | edgomez | 195 | ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); |
181 : | Isibaar | 3 | |
182 : | edgomez | 195 | return ts; |
183 : | Isibaar | 3 | } |
184 : | |||
185 : | edgomez | 78 | #endif |
186 : | |||
187 : | edgomez | 195 | #else // OTHER OS |
188 : | Isibaar | 3 | |
189 : | #define DEBUG(S) | ||
190 : | #define DEBUG1(S,I) | ||
191 : | #define DEBUG2(X,A,B) | ||
192 : | #define DEBUG3(X,A,B,C) | ||
193 : | #define DEBUG8(X,A,B,C,D,E,F,G,H) | ||
194 : | h | 108 | #define DEBUGCBR(A,B,C) |
195 : | Isibaar | 3 | |
196 : | #include <inttypes.h> | ||
197 : | |||
198 : | #define EMMS() | ||
199 : | |||
200 : | // needed for bitstream.h | ||
201 : | #define BSWAP(a) \ | ||
202 : | ((a) = ( ((a)&0xff)<<24) | (((a)&0xff00)<<8) | (((a)>>8)&0xff00) | (((a)>>24)&0xff)) | ||
203 : | |||
204 : | // rdtsc command most likely not supported, | ||
205 : | // so just dummy code here | ||
206 : | edgomez | 195 | static __inline int64_t |
207 : | read_counter() | ||
208 : | { | ||
209 : | Isibaar | 3 | return 0; |
210 : | } | ||
211 : | |||
212 : | Isibaar | 42 | #define CACHE_LINE 16 |
213 : | #define CACHE_ALIGN | ||
214 : | |||
215 : | Isibaar | 3 | #endif |
216 : | |||
217 : | edgomez | 195 | #endif // _PORTAB_H_ |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |