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