23 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
24 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
25 |
* |
* |
26 |
* $Id: portab.h,v 1.43 2003-02-15 15:22:17 edgomez Exp $ |
* $Id: portab.h,v 1.45 2003-02-16 05:11:39 suxen_drol Exp $ |
27 |
* |
* |
28 |
****************************************************************************/ |
****************************************************************************/ |
29 |
|
|
46 |
#define DPRINTF_DEBUG 0x80000000 |
#define DPRINTF_DEBUG 0x80000000 |
47 |
|
|
48 |
/* debug level for this library */ |
/* debug level for this library */ |
49 |
|
#ifdef _DEBUG |
50 |
|
#define DPRINTF_LEVEL 0x000000ff |
51 |
|
#else |
52 |
#define DPRINTF_LEVEL 0 |
#define DPRINTF_LEVEL 0 |
53 |
|
#endif |
54 |
|
|
55 |
/* Buffer size for msvc implementation because it outputs to DebugOutput */ |
/* Buffer size for msvc implementation because it outputs to DebugOutput */ |
56 |
#define DPRINTF_BUF_SZ 1024 |
#define DPRINTF_BUF_SZ 1024 |
115 |
#include <windows.h> |
#include <windows.h> |
116 |
#include <stdio.h> |
#include <stdio.h> |
117 |
|
|
118 |
|
/* Non ANSI mapping */ |
119 |
|
# define snprintf _snprintf |
120 |
|
# define vsnprintf _vsnprintf |
121 |
|
|
122 |
/* |
/* |
123 |
* This function must be declared/defined all the time because MSVC does |
* This function must be declared/defined all the time because MSVC does |
124 |
* not support C99 variable arguments macros. |
* not support C99 variable arguments macros. |
139 |
} |
} |
140 |
} |
} |
141 |
# else |
# else |
142 |
static __inline void DPRINTF(int level, char *fmt, ...) |
static __inline void DPRINTF(int level, char *fmt, ...) {} |
|
{ |
|
|
} |
|
143 |
# endif |
# endif |
144 |
|
|
145 |
# if _MSC_VER <= 1200 |
# if _MSC_VER <= 1200 |
157 |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
158 |
# if defined(ARCH_IS_IA32) |
# if defined(ARCH_IS_IA32) |
159 |
# 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 |
|
# define EMMS() __asm {emms} |
|
160 |
|
|
|
# ifdef _PROFILING_ |
|
161 |
static __inline int64_t read_counter(void) |
static __inline int64_t read_counter(void) |
162 |
{ |
{ |
163 |
int64_t ts; |
int64_t ts; |
170 |
ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); |
ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); |
171 |
return ts; |
return ts; |
172 |
} |
} |
|
# endif |
|
173 |
|
|
174 |
/*---------------------------------------------------------------------------- |
/*---------------------------------------------------------------------------- |
175 |
| msvc GENERIC (plain C only) - Probably alpha or some embedded device |
| msvc GENERIC (plain C only) - Probably alpha or some embedded device |
178 |
# define BSWAP(a) \ |
# define BSWAP(a) \ |
179 |
((a) = (((a) & 0xff) << 24) | (((a) & 0xff00) << 8) | \ |
((a) = (((a) & 0xff) << 24) | (((a) & 0xff00) << 8) | \ |
180 |
(((a) >> 8) & 0xff00) | (((a) >> 24) & 0xff)) |
(((a) >> 8) & 0xff00) | (((a) >> 24) & 0xff)) |
|
# define EMMS() |
|
181 |
|
|
|
# ifdef _PROFILING_ |
|
182 |
# include <time.h> |
# include <time.h> |
183 |
static __inline int64_t read_counter(void) |
static __inline int64_t read_counter(void) |
184 |
{ |
{ |
185 |
return (int64_t)clock(); |
return (int64_t)clock(); |
186 |
} |
} |
|
# endif |
|
187 |
|
|
188 |
/*---------------------------------------------------------------------------- |
/*---------------------------------------------------------------------------- |
189 |
| msvc Not given architecture - This is probably an user who tries to build |
| msvc Not given architecture - This is probably an user who tries to build |
240 |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
241 |
# if defined(ARCH_IS_IA32) |
# if defined(ARCH_IS_IA32) |
242 |
# define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ); |
# define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ); |
|
# define EMMS() __asm__ ("emms\n\t"); |
|
243 |
|
|
|
# ifdef _PROFILING_ |
|
244 |
static __inline int64_t read_counter(void) |
static __inline int64_t read_counter(void) |
245 |
{ |
{ |
246 |
int64_t ts; |
int64_t ts; |
249 |
ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); |
ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); |
250 |
return ts; |
return ts; |
251 |
} |
} |
|
# endif |
|
252 |
|
|
253 |
/*---------------------------------------------------------------------------- |
/*---------------------------------------------------------------------------- |
254 |
| gcc PPC and PPC Altivec specific macros/functions |
| gcc PPC and PPC Altivec specific macros/functions |
256 |
# elif defined(ARCH_IS_PPC) |
# elif defined(ARCH_IS_PPC) |
257 |
# define BSWAP(a) __asm__ __volatile__ \ |
# define BSWAP(a) __asm__ __volatile__ \ |
258 |
( "lwbrx %0,0,%1; eieio" : "=r" (a) : "r" (&(a)), "m" (a)); |
( "lwbrx %0,0,%1; eieio" : "=r" (a) : "r" (&(a)), "m" (a)); |
|
# define EMMS() |
|
259 |
|
|
|
# ifdef _PROFILING_ |
|
260 |
static __inline unsigned long get_tbl(void) |
static __inline unsigned long get_tbl(void) |
261 |
{ |
{ |
262 |
unsigned long tbl; |
unsigned long tbl; |
280 |
}while (tb != get_tbl()); |
}while (tb != get_tbl()); |
281 |
return (((int64_t) tu) << 32) | (int64_t) tb; |
return (((int64_t) tu) << 32) | (int64_t) tb; |
282 |
} |
} |
|
# endif |
|
283 |
|
|
284 |
/*---------------------------------------------------------------------------- |
/*---------------------------------------------------------------------------- |
285 |
| gcc IA64 specific macros/functions |
| gcc IA64 specific macros/functions |
288 |
# define BSWAP(a) __asm__ __volatile__ \ |
# define BSWAP(a) __asm__ __volatile__ \ |
289 |
("mux1 %1 = %0, @rev" ";;" \ |
("mux1 %1 = %0, @rev" ";;" \ |
290 |
"shr.u %1 = %1, 32" : "=r" (a) : "r" (a)); |
"shr.u %1 = %1, 32" : "=r" (a) : "r" (a)); |
|
# define EMMS() |
|
291 |
|
|
|
# ifdef _PROFILING_ |
|
292 |
static __inline int64_t read_counter(void) |
static __inline int64_t read_counter(void) |
293 |
{ |
{ |
294 |
unsigned long result; |
unsigned long result; |
295 |
__asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory"); |
__asm__ __volatile__("mov %0=ar.itc" : "=r"(result) :: "memory"); |
296 |
return result; |
return result; |
297 |
} |
} |
|
# endif |
|
298 |
|
|
299 |
/*---------------------------------------------------------------------------- |
/*---------------------------------------------------------------------------- |
300 |
| gcc GENERIC (plain C only) specific macros/functions |
| gcc GENERIC (plain C only) specific macros/functions |
303 |
# define BSWAP(a) \ |
# define BSWAP(a) \ |
304 |
((a) = (((a) & 0xff) << 24) | (((a) & 0xff00) << 8) | \ |
((a) = (((a) & 0xff) << 24) | (((a) & 0xff00) << 8) | \ |
305 |
(((a) >> 8) & 0xff00) | (((a) >> 24) & 0xff)) |
(((a) >> 8) & 0xff00) | (((a) >> 24) & 0xff)) |
|
# define EMMS() |
|
306 |
|
|
|
# ifdef _PROFILING_ |
|
307 |
# include <time.h> |
# include <time.h> |
308 |
static __inline int64_t read_counter(void) |
static __inline int64_t read_counter(void) |
309 |
{ |
{ |
310 |
return (int64_t)clock(); |
return (int64_t)clock(); |
311 |
} |
} |
|
# endif |
|
312 |
|
|
313 |
/*---------------------------------------------------------------------------- |
/*---------------------------------------------------------------------------- |
314 |
| gcc Not given architecture - This is probably an user who tries to build |
| gcc Not given architecture - This is probably an user who tries to build |
318 |
# error You are trying to compile XviD without defining the architecture type. |
# error You are trying to compile XviD without defining the architecture type. |
319 |
# endif |
# endif |
320 |
|
|
321 |
|
|
322 |
|
|
323 |
|
|
324 |
/***************************************************************************** |
/***************************************************************************** |
325 |
* OPEN WATCOM C/C++ compiler |
* Open WATCOM C/C++ compiler |
326 |
****************************************************************************/ |
****************************************************************************/ |
327 |
|
|
328 |
#elif defined(__WATCOMC__) |
#elif defined(__WATCOMC__) |
329 |
|
|
330 |
# include <stdio.h> |
# include <stdio.h> |
350 |
type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1)) |
type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1)) |
351 |
|
|
352 |
/*---------------------------------------------------------------------------- |
/*---------------------------------------------------------------------------- |
353 |
| watcom x86 specific macros/functions |
| watcom ia32 specific macros/functions |
354 |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
355 |
# if defined(ARCH_IS_IA32) |
# if defined(ARCH_IS_IA32) |
356 |
|
|
357 |
# 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 |
358 |
# define EMMS() __asm {emms} |
|
|
# ifdef _PROFILING_ |
|
359 |
static __inline int64_t read_counter(void) |
static __inline int64_t read_counter(void) |
360 |
{ |
{ |
361 |
uint64_t ts; |
uint64_t ts; |
368 |
ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); |
ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); |
369 |
return ts; |
return ts; |
370 |
} |
} |
|
# endif |
|
371 |
|
|
372 |
/*---------------------------------------------------------------------------- |
/*---------------------------------------------------------------------------- |
373 |
| watcom unsupported architecture |
| watcom GENERIC (plain C only) specific macros/functions. |
374 |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
375 |
# else |
# elif defined(ARCH_IS_GENERIC) |
376 |
|
|
377 |
# define BSWAP(x) \ |
# define BSWAP(x) \ |
378 |
x = ((((x) & 0xff000000) >> 24) | \ |
x = ((((x) & 0xff000000) >> 24) | \ |
379 |
(((x) & 0x00ff0000) >> 8) | \ |
(((x) & 0x00ff0000) >> 8) | \ |
380 |
(((x) & 0x0000ff00) << 8) | \ |
(((x) & 0x0000ff00) << 8) | \ |
381 |
(((x) & 0x000000ff) << 24)) |
(((x) & 0x000000ff) << 24)) |
382 |
# define EMMS() |
|
|
# ifdef _PROFILING_ |
|
383 |
static int64_t read_counter() { return 0; } |
static int64_t read_counter() { return 0; } |
|
# endif |
|
384 |
|
|
385 |
|
/*---------------------------------------------------------------------------- |
386 |
|
| watcom Not given architecture - This is probably an user who tries to build |
387 |
|
| XviD the wrong way. |
388 |
|
*---------------------------------------------------------------------------*/ |
389 |
|
# else |
390 |
|
# error You are trying to compile XviD without defining the architecture type. |
391 |
# endif |
# endif |
392 |
|
|
393 |
|
|
394 |
/***************************************************************************** |
/***************************************************************************** |
395 |
* Unknown compiler |
* Unknown compiler |
396 |
****************************************************************************/ |
****************************************************************************/ |
427 |
((a) = (((a) & 0xff) << 24) | (((a) & 0xff00) << 8) | \ |
((a) = (((a) & 0xff) << 24) | (((a) & 0xff00) << 8) | \ |
428 |
(((a) >> 8) & 0xff00) | (((a) >> 24) & 0xff)) |
(((a) >> 8) & 0xff00) | (((a) >> 24) & 0xff)) |
429 |
|
|
|
# define EMMS() |
|
|
|
|
|
# ifdef _PROFILING_ |
|
430 |
# include <time.h> |
# include <time.h> |
431 |
static __inline int64_t read_counter(void) |
static __inline int64_t read_counter(void) |
432 |
{ |
{ |
433 |
return (int64_t)clock(); |
return (int64_t)clock(); |
434 |
} |
} |
|
# endif |
|
435 |
|
|
436 |
# define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
# define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
437 |
type name[(sizex)*(sizey)] |
type name[(sizex)*(sizey)] |
439 |
#endif /* Compiler test */ |
#endif /* Compiler test */ |
440 |
|
|
441 |
|
|
442 |
#endif |
#endif /* PORTAB_H */ |