--- portab.h 2002/03/08 02:44:32 1.1.1.1 +++ portab.h 2002/03/25 20:01:54 1.7 @@ -5,12 +5,19 @@ #include +#ifdef _DEBUG #define DEBUG(S) OutputDebugString((S)); #define DEBUG1(S,I) { char tmp[100]; wsprintf(tmp, "%s %i\n", (S), (I)); OutputDebugString(tmp); } #define DEBUG2(X,A,B) { char tmp[100]; wsprintf(tmp, "%s %i %i\n", (X), (A), (B)); OutputDebugString(tmp); } #define DEBUG3(X,A,B,C){ char tmp[1000]; wsprintf(tmp,"%s %i %i %i",(X),(A), (B), (C)); 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); } - +#else +#define DEBUG(S) +#define DEBUG1(S,I) +#define DEBUG2(X,A,B) +#define DEBUG3(X,A,B,C) +#define DEBUG8(X,A,B,C,D,E,F,G,H) +#endif #define int8_t char @@ -24,6 +31,13 @@ #define EMMS() __asm {emms} +#define CACHE_LINE 16 +#if _MSC_VER <= 1200 +#define CACHE_ALIGN +#else +#define CACHE_ALIGN __declspec(align(CACHE_LINE)) +#endif + // needed for bitstream.h #define BSWAP(a) __asm mov eax,a __asm bswap eax __asm mov a, eax @@ -45,6 +59,9 @@ #elif defined(LINUX) || defined(DJGPP) + +#ifdef _DEBUG + #include #define DEBUG_WHERE stdout #define DEBUG(S) fprintf(DEBUG_WHERE, "%s\n", (S)); @@ -52,6 +69,17 @@ #define DEBUG2(S,A,B) fprintf(DEBUG_WHERE, "%s%i=%i\n", (S), (A), (B)) #define DEBUG3(S,A,B,C) fprintf(DEBUG_WHERE, "%s %i %x %x\n", (S), (A), (B), (C)) #define DEBUG8(S,A,B,C,D,E,F,G,H) +#else +#define DEBUG(S) +#define DEBUG1(S,I) +#define DEBUG2(X,A,B) +#define DEBUG3(X,A,B,C) +#define DEBUG8(X,A,B,C,D,E,F,G,H) +#endif + +#define CACHE_LINE 16 +#define CACHE_ALIGN __attribute__ ((__aligned__(CACHE_LINE))) + #if defined(LINUX) @@ -70,10 +98,16 @@ #endif -#define EMMS() __asm__("emms\n\t") // needed for bitstream.h -#define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ) +#ifdef ARCH_PPC + #define BSWAP(a) __asm__ ( "lwbrx %0,0,%1; eieio" : "=r" (a) : \ + "r" (&(a)), "m" (a)); + #define EMMS() +#else + #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ) + #define EMMS() __asm__("emms\n\t") +#endif // needed for timer.c static __inline int64_t read_counter() { @@ -109,6 +143,9 @@ return 0; } +#define CACHE_LINE 16 +#define CACHE_ALIGN + #endif #endif // _PORTAB_H_