76 |
|
|
77 |
/* debug level for this library */ |
/* debug level for this library */ |
78 |
#ifdef _DEBUG |
#ifdef _DEBUG |
79 |
#define DPRINTF_LEVEL (DPRINTF_RC|0x0000000f) |
#define DPRINTF_LEVEL (DPRINTF_RC|0x0000007F) |
80 |
#else |
#else |
81 |
#define DPRINTF_LEVEL DPRINTF_RC |
#define DPRINTF_LEVEL DPRINTF_RC |
82 |
#endif |
#endif |
101 |
| msvc (lacks such a header file) |
| msvc (lacks such a header file) |
102 |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
103 |
|
|
104 |
#elif defined(_MSC_VER) |
#elif defined(_MSC_VER) || defined (__WATCOMC__) |
105 |
# define int8_t char |
# define int8_t char |
106 |
# define uint8_t unsigned char |
# define uint8_t unsigned char |
107 |
# define int16_t short |
# define int16_t short |
167 |
#include <windows.h> |
#include <windows.h> |
168 |
#include <stdio.h> |
#include <stdio.h> |
169 |
|
|
170 |
|
/* non-ansi function mapping */ |
171 |
|
# define snprintf _snprintf |
172 |
|
# define vsnprintf _vsnprintf |
173 |
|
|
174 |
/* |
/* |
175 |
* This function must be declared/defined all the time because MSVC does |
* This function must be declared/defined all the time because MSVC does |
176 |
* not support C99 variable arguments macros |
* not support C99 variable arguments macros |
202 |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
203 |
# if defined(ARCH_X86) |
# if defined(ARCH_X86) |
204 |
# 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} |
|
|
# define FEMMS() __asm {femms} |
|
205 |
|
|
206 |
static __inline int64_t read_counter(void) |
static __inline int64_t read_counter(void) |
207 |
{ |
{ |
227 |
(((x) & 0x0000ff00) << 8) | \ |
(((x) & 0x0000ff00) << 8) | \ |
228 |
(((x) & 0x000000ff) << 24)) |
(((x) & 0x000000ff) << 24)) |
229 |
|
|
|
#define EMMS() |
|
|
#define FEMMS() |
|
230 |
# endif |
# endif |
231 |
|
|
232 |
|
|
272 |
*---------------------------------------------------------------------------*/ |
*---------------------------------------------------------------------------*/ |
273 |
# if defined(ARCH_X86) |
# if defined(ARCH_X86) |
274 |
# 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"); |
|
|
# define FEMMS() __asm__ ("femms\n\t"); |
|
275 |
|
|
276 |
static __inline int64_t read_counter(void) |
static __inline int64_t read_counter(void) |
277 |
{ |
{ |
288 |
# elif defined(ARCH_PPC) |
# elif defined(ARCH_PPC) |
289 |
# define BSWAP(a) __asm__ __volatile__ \ |
# define BSWAP(a) __asm__ __volatile__ \ |
290 |
( "lwbrx %0,0,%1; eieio" : "=r" (a) : "r" (&(a)), "m" (a)); |
( "lwbrx %0,0,%1; eieio" : "=r" (a) : "r" (&(a)), "m" (a)); |
|
# define EMMS() |
|
|
# define FEMMS() |
|
291 |
|
|
292 |
static __inline unsigned long get_tbl(void) |
static __inline unsigned long get_tbl(void) |
293 |
{ |
{ |
320 |
# define BSWAP(a) __asm__ __volatile__ \ |
# define BSWAP(a) __asm__ __volatile__ \ |
321 |
("mux1 %1 = %0, @rev" ";;" \ |
("mux1 %1 = %0, @rev" ";;" \ |
322 |
"shr.u %1 = %1, 32" : "=r" (a) : "r" (a)); |
"shr.u %1 = %1, 32" : "=r" (a) : "r" (a)); |
|
# define EMMS() |
|
|
# define FEMMS() |
|
323 |
|
|
324 |
static __inline int64_t read_counter(void) { |
static __inline int64_t read_counter(void) { |
325 |
unsigned long result; |
unsigned long result; |
334 |
# define BSWAP(a) \ |
# define BSWAP(a) \ |
335 |
((a) = (((a) & 0xff) << 24) | (((a) & 0xff00) << 8) | \ |
((a) = (((a) & 0xff) << 24) | (((a) & 0xff00) << 8) | \ |
336 |
(((a) >> 8) & 0xff00) | (((a) >> 24) & 0xff)) |
(((a) >> 8) & 0xff00) | (((a) >> 24) & 0xff)) |
|
# define EMMS() |
|
|
# define FEMMS() |
|
337 |
|
|
338 |
static __inline int64_t read_counter(void) |
static __inline int64_t read_counter(void) |
339 |
{ |
{ |
347 |
# define BSWAP(a) \ |
# define BSWAP(a) \ |
348 |
((a) = (((a) & 0xff) << 24) | (((a) & 0xff00) << 8) | \ |
((a) = (((a) & 0xff) << 24) | (((a) & 0xff00) << 8) | \ |
349 |
(((a) >> 8) & 0xff00) | (((a) >> 24) & 0xff)) |
(((a) >> 8) & 0xff00) | (((a) >> 24) & 0xff)) |
|
# define EMMS() |
|
|
# define FEMMS() |
|
350 |
|
|
351 |
static __inline int64_t read_counter(void) |
static __inline int64_t read_counter(void) |
352 |
{ |
{ |
364 |
(((x) & 0x0000ff00) << 8) | \ |
(((x) & 0x0000ff00) << 8) | \ |
365 |
(((x) & 0x000000ff) << 24)) |
(((x) & 0x000000ff) << 24)) |
366 |
|
|
|
#define EMMS() |
|
|
#define FEMMS() |
|
367 |
# endif /* Architecture checking */ |
# endif /* Architecture checking */ |
368 |
|
|
369 |
/***************************************************************************** |
/***************************************************************************** |
370 |
|
* OPEN WATCOM C/C++ compiler |
371 |
|
****************************************************************************/ |
372 |
|
#elif defined(__WATCOMC__) |
373 |
|
|
374 |
|
# include <stdio.h> |
375 |
|
# include <stdarg.h> |
376 |
|
|
377 |
|
static __inline void DPRINTF(int level, char *fmt, ...) |
378 |
|
{ |
379 |
|
if (DPRINTF_LEVEL & level) { |
380 |
|
va_list args; |
381 |
|
char buf[DPRINTF_BUF_SZ]; |
382 |
|
va_start(args, fmt); |
383 |
|
vsprintf(buf, fmt, args); |
384 |
|
fprintf(stderr, "%s\n", buf); |
385 |
|
} |
386 |
|
} |
387 |
|
|
388 |
|
# define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
389 |
|
type name##_storage[(sizex)*(sizey)+(alignment)-1]; \ |
390 |
|
type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1)) |
391 |
|
|
392 |
|
/*---------------------------------------------------------------------------- |
393 |
|
| watcom x86 specific macros/functions |
394 |
|
*---------------------------------------------------------------------------*/ |
395 |
|
# if defined(ARCH_X86) |
396 |
|
|
397 |
|
# define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax |
398 |
|
|
399 |
|
static __inline int64_t read_counter(void) |
400 |
|
{ |
401 |
|
int64_t ts; |
402 |
|
uint32_t ts1, ts2; |
403 |
|
__asm { |
404 |
|
rdtsc |
405 |
|
mov ts1, eax |
406 |
|
mov ts2, edx |
407 |
|
} |
408 |
|
ts = ((uint64_t) ts2 << 32) | ((uint64_t) ts1); |
409 |
|
return ts; |
410 |
|
} |
411 |
|
|
412 |
|
/*---------------------------------------------------------------------------- |
413 |
|
| watcom unsupported architecture |
414 |
|
*---------------------------------------------------------------------------*/ |
415 |
|
# else |
416 |
|
|
417 |
|
# define BSWAP(x) \ |
418 |
|
x = ((((x) & 0xff000000) >> 24) | \ |
419 |
|
(((x) & 0x00ff0000) >> 8) | \ |
420 |
|
(((x) & 0x0000ff00) << 8) | \ |
421 |
|
(((x) & 0x000000ff) << 24)) |
422 |
|
|
423 |
|
static int64_t read_counter() { return 0; } |
424 |
|
|
425 |
|
# endif |
426 |
|
/***************************************************************************** |
427 |
* Unknown compiler |
* Unknown compiler |
428 |
****************************************************************************/ |
****************************************************************************/ |
429 |
#else /* Compiler test */ |
#else /* Compiler test */ |