--- portab.h 2002/03/28 20:57:24 1.9 +++ portab.h 2002/03/30 00:58:20 1.12 @@ -34,12 +34,12 @@ #define CACHE_LINE 16 #if _MSC_VER <= 1200 -#define #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ +#define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ type name##_storage[(sizex)*(sizey)+(alignment)-1]; \ type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1)) #else -#define #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ - __declspec(align(CACHE_LINE)) type name[(sizex)*(sizey)] +#define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ + __declspec(align(alignment)) type name[(sizex)*(sizey)] #endif // needed for bitstream.h @@ -113,6 +113,25 @@ #define BSWAP(a) __asm__ ( "lwbrx %0,0,%1; eieio" : "=r" (a) : \ "r" (&(a)), "m" (a)); #define EMMS() + + static __inline unsigned long get_tbl(void) { + unsigned long tbl; + asm volatile("mftb %0" : "=r" (tbl)); + return tbl; + } + static __inline unsigned long get_tbu(void) { + unsigned long tbl; + asm volatile("mftbu %0" : "=r" (tbl)); + return tbl; + } + static __inline int64_t read_counter() { + unsigned long tb, tu; + do { + tb = get_tbl(); + tu = get_tbu(); + } while(tb != get_tbl()); + return (((int64_t)tu) << 32) | (int64_t)tb; + } #else #define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ) #define EMMS() __asm__("emms\n\t")