32 |
#define EMMS() __asm {emms} |
#define EMMS() __asm {emms} |
33 |
|
|
34 |
#define CACHE_LINE 16 |
#define CACHE_LINE 16 |
35 |
#define CACHE_ALIGN __declspec(align(CACHE_LINE)) |
|
36 |
|
#if _MSC_VER <= 1200 |
37 |
|
#define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
38 |
|
type name##_storage[(sizex)*(sizey)+(alignment)-1]; \ |
39 |
|
type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1)) |
40 |
|
#else |
41 |
|
#define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
42 |
|
__declspec(align(alignment)) type name[(sizex)*(sizey)] |
43 |
|
#endif |
44 |
|
|
45 |
// needed for bitstream.h |
// needed for bitstream.h |
46 |
#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 |
82 |
#endif |
#endif |
83 |
|
|
84 |
#define CACHE_LINE 16 |
#define CACHE_LINE 16 |
|
#define CACHE_ALIGN __attribute__ ((__aligned__(CACHE_LINE))) |
|
|
|
|
85 |
|
|
86 |
#if defined(LINUX) |
#if defined(LINUX) |
87 |
|
|
88 |
#include <stdint.h> |
#include <stdint.h> |
89 |
|
|
90 |
|
#define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
91 |
|
type name##_storage[(sizex)*(sizey)+(alignment)-1]; \ |
92 |
|
type * name = (type *) (((int32_t) name##_storage+(alignment - 1)) & ~((int32_t)(alignment)-1)) |
93 |
|
|
94 |
#else |
#else |
95 |
|
|
96 |
|
#define #define #define DECLARE_ALIGNED_MATRIX(name,sizex,sizey,type,alignment) \ |
97 |
|
__attribute__ ((__aligned__(CACHE_LINE))) type name[(sizex)*(sizey)] |
98 |
|
|
99 |
#define int8_t char |
#define int8_t char |
100 |
#define uint8_t unsigned char |
#define uint8_t unsigned char |
101 |
#define int16_t short |
#define int16_t short |
110 |
|
|
111 |
// needed for bitstream.h |
// needed for bitstream.h |
112 |
#ifdef ARCH_PPC |
#ifdef ARCH_PPC |
113 |
#define BSWAP(a) __asm__ ( "lwbrx %0,0,%1; eieio" : "=r" (a) : \ |
#define BSWAP(a) __asm__ __volatile__ ( "lwbrx %0,0,%1; eieio" : "=r" (a) : \ |
114 |
"r" (&(a)), "m" (a)); |
"r" (&(a)), "m" (a)); |
115 |
#define EMMS() |
#define EMMS() |
116 |
|
|
117 |
|
static __inline unsigned long get_tbl(void) { |
118 |
|
unsigned long tbl; |
119 |
|
asm volatile("mftb %0" : "=r" (tbl)); |
120 |
|
return tbl; |
121 |
|
} |
122 |
|
static __inline unsigned long get_tbu(void) { |
123 |
|
unsigned long tbl; |
124 |
|
asm volatile("mftbu %0" : "=r" (tbl)); |
125 |
|
return tbl; |
126 |
|
} |
127 |
|
static __inline int64_t read_counter() { |
128 |
|
unsigned long tb, tu; |
129 |
|
do { |
130 |
|
tu = get_tbu(); |
131 |
|
tb = get_tbl(); |
132 |
|
} while(tb != get_tbl()); |
133 |
|
return (((int64_t)tu) << 32) | (int64_t)tb; |
134 |
|
} |
135 |
#else |
#else |
136 |
#define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ) |
#define BSWAP(a) __asm__ ( "bswapl %0\n" : "=r" (a) : "0" (a) ) |
137 |
#define EMMS() __asm__("emms\n\t") |
#define EMMS() __asm__("emms\n\t") |
138 |
#endif |
|
139 |
|
|
140 |
// needed for timer.c |
// needed for timer.c |
141 |
static __inline int64_t read_counter() { |
static __inline int64_t read_counter() { |
149 |
return ts; |
return ts; |
150 |
} |
} |
151 |
|
|
152 |
|
#endif |
153 |
|
|
154 |
#else // OTHER OS |
#else // OTHER OS |
155 |
|
|
156 |
#define DEBUG(S) |
#define DEBUG(S) |