[cvs] / xvidcore / src / portab.h Repository:
ViewVC logotype

Diff of /xvidcore/src/portab.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14, Sun Apr 7 11:57:47 2002 UTC revision 1.22, Thu Jun 20 14:05:57 2002 UTC
# Line 4  Line 4 
4  #if defined(WIN32)  #if defined(WIN32)
5    
6  #include <windows.h>  #include <windows.h>
7    #include <stdio.h>
8    
9    
10    #define DPRINTF_BUF_SZ  1024
11    static void
12    DPRINTF(char *fmt,
13                    ...)
14    {
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  #define DEBUGCBR(A,B,C) { char tmp[100]; wsprintf(tmp, "CBR: frame: %i, quant: %i, deviation: %i\n", (A), (B), (C)); OutputDebugString(tmp); }  #define DEBUGCBR(A,B,C) { char tmp[100]; wsprintf(tmp, "CBR: frame: %i, quant: %i, deviation: %i\n", (A), (B), (C)); OutputDebugString(tmp); }
26    
# Line 12  Line 29 
29  #define DEBUG1(S,I) { char tmp[100]; wsprintf(tmp, "%s %i\n", (S), (I)); OutputDebugString(tmp); }  #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); }  #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); }  #define DEBUG3(X,A,B,C){ char tmp[1000]; wsprintf(tmp,"%s %i %i %i",(X),(A), (B), (C)); OutputDebugString(tmp); }
32    #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  #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); }  #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  #else  #else
35  #define DEBUG(S)  #define DEBUG(S)
36  #define DEBUG1(S,I)  #define DEBUG1(S,I)
37  #define DEBUG2(X,A,B)  #define DEBUG2(X,A,B)
38  #define DEBUG3(X,A,B,C)  #define DEBUG3(X,A,B,C)
39    #define DEBUG4(X,A,B,C,D)
40  #define DEBUG8(X,A,B,C,D,E,F,G,H)  #define DEBUG8(X,A,B,C,D,E,F,G,H)
41  #endif  #endif
42    
# Line 30  Line 49 
49  #define uint32_t unsigned int  #define uint32_t unsigned int
50  #define int64_t __int64  #define int64_t __int64
51  #define uint64_t unsigned __int64  #define uint64_t unsigned __int64
52    #define ptr_t uint32_t
53    
54  #define EMMS() __asm {emms}  #define EMMS() __asm {emms}
55    
# Line 48  Line 68 
68  #define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax  #define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax
69    
70  // needed for timer.c  // needed for timer.c
71  static __inline int64_t read_counter() {  static __inline int64_t
72    read_counter()
73    {
74          int64_t ts;          int64_t ts;
75          uint32_t ts1, ts2;          uint32_t ts1, ts2;
76    
# Line 63  Line 85 
85          return ts;          return ts;
86  }  }
87    
88  #elif defined(LINUX) || defined(DJGPP)  #elif defined(LINUX) || defined(DJGPP) || defined(FREEBSD)
89    
90    #include <stdio.h>
91    #include <stdarg.h>
92    #define DPRINTF_BUF_SZ  1024
93    static void
94    DPRINTF(char *fmt,
95                    ...)
96    {
97            va_list args;
98            char buf[DPRINTF_BUF_SZ];
99    
100            va_start(args, fmt);
101            vsprintf(buf, fmt, args);
102            fprintf(stdout, "%s\n", buf);
103    }
104    
105  #ifdef _DEBUG  #ifdef _DEBUG
106    
# Line 84  Line 121 
121  #define DEBUGCBR(A,B,C)  #define DEBUGCBR(A,B,C)
122  #endif  #endif
123    
 #define CACHE_LINE  16  
   
124  #if defined(LINUX)  #if defined(LINUX)
125    
126  #include <stdint.h>  #include <stdint.h>
127    
128  #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \  #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
129          type name##_storage[(sizex)*(sizey)+(alignment)-1]; \          type name##_storage[(sizex)*(sizey)+(alignment)-1]; \
130          type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1))          type * name = (type *) (((ptr_t) name##_storage+(alignment - 1)) & ~((ptr_t)(alignment)-1))
131    
132  #else  #else
133    
134  #define #define #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \  #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \
135          __attribute__ ((__aligned__(CACHE_LINE))) type name[(sizex)*(sizey)]          __attribute__ ((__aligned__(CACHE_LINE))) type name[(sizex)*(sizey)]
136    
137  #define int8_t   char  #define int8_t   char
# Line 117  Line 152 
152                  "r" (&(a)), "m" (a));                  "r" (&(a)), "m" (a));
153          #define EMMS()          #define EMMS()
154    
155          static __inline unsigned long get_tbl(void) {  static __inline unsigned long
156    get_tbl(void)
157    {
158                  unsigned long tbl;                  unsigned long tbl;
159                  asm volatile("mftb %0" : "=r" (tbl));                  asm volatile("mftb %0" : "=r" (tbl));
160    
161                  return tbl;                  return tbl;
162          }          }
163          static __inline unsigned long get_tbu(void) {  static __inline unsigned long
164    get_tbu(void)
165    {
166                  unsigned long tbl;                  unsigned long tbl;
167                  asm volatile("mftbu %0" : "=r" (tbl));                  asm volatile("mftbu %0" : "=r" (tbl));
168    
169                  return tbl;                  return tbl;
170          }          }
171          static __inline int64_t read_counter() {  static __inline int64_t
172    read_counter()
173    {
174                  unsigned long tb, tu;                  unsigned long tb, tu;
175    
176                  do {                  do {
177                          tu = get_tbu();                          tu = get_tbu();
178                          tb = get_tbl();                          tb = get_tbl();
179                  } while(tb != get_tbl());                  } while(tb != get_tbl());
180                  return (((int64_t)tu) << 32) | (int64_t)tb;                  return (((int64_t)tu) << 32) | (int64_t)tb;
181          }          }
182    
183    #define ptr_t   uint32_t
184    
185    #define CACHE_LINE 16
186    
187    #elif defined(ARCH_IA64)
188    
189    #define ptr_t   uint64_t
190    
191    #define CACHE_LINE 32
192    
193    #define EMMS()
194    
195    // needed for bitstream.h
196    #define BSWAP(a) \
197             ((a) = ( ((a)&0xff)<<24) | (((a)&0xff00)<<8) | (((a)>>8)&0xff00) | (((a)>>24)&0xff))
198    
199    // rdtsc command most likely not supported,
200    // so just dummy code here
201    static __inline int64_t read_counter() {
202            return 0;
203    }
204    
205  #else  #else
206          #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )          #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) )
207          #define EMMS() __asm__("emms\n\t")          #define EMMS() __asm__("emms\n\t")
208    
209    
210  // needed for timer.c  // needed for timer.c
211  static __inline int64_t read_counter() {  static __inline int64_t
212    read_counter()
213    {
214      int64_t ts;      int64_t ts;
215      uint32_t ts1, ts2;      uint32_t ts1, ts2;
216    
217      __asm__ __volatile__("rdtsc\n\t":"=a"(ts1), "=d"(ts2));          __asm__ __volatile__("rdtsc\n\t":"=a"(ts1),
218                                                     "=d"(ts2));
219    
220      ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1);      ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1);
221    
222      return ts;      return ts;
223  }  }
224    
225    #define ptr_t   uint32_t
226    
227    #define CACHE_LINE 16
228    
229  #endif  #endif
230    
231  #else // OTHER OS  #else // OTHER OS
232    
233    
234    #include <stdio.h>
235    #include <stdarg.h>
236    #define DPRINTF_BUF_SZ  1024
237    static void
238    DPRINTF(char *fmt,
239                    ...)
240    {
241            va_list args;
242            char buf[DPRINTF_BUF_SZ];
243    
244            va_start(args, fmt);
245            vsprintf(buf, fmt, args);
246            fprintf(stdout, "%s\n", buf);
247    }
248    
249    
250  #define DEBUG(S)  #define DEBUG(S)
251  #define DEBUG1(S,I)  #define DEBUG1(S,I)
252  #define DEBUG2(X,A,B)  #define DEBUG2(X,A,B)
# Line 173  Line 264 
264    
265  // rdtsc command most likely not supported,  // rdtsc command most likely not supported,
266  // so just dummy code here  // so just dummy code here
267  static __inline int64_t read_counter() {  static __inline int64_t
268    read_counter()
269    {
270          return 0;          return 0;
271  }  }
272    
273    #define ptr_t uint32_t
274    
275  #define CACHE_LINE  16  #define CACHE_LINE  16
276  #define CACHE_ALIGN  #define CACHE_ALIGN
277    
278  #endif  #endif
279    
280  #endif // _PORTAB_H_  #endif // _PORTAB_H_
   

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.22

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4