40 #warning "This may NOT work on non-GNUC compilers!"
48 #if defined(RTS_LITTLE_ENDIAN)
49 #elif defined(RTS_BIG_ENDIAN)
55 #define RTS_LITTLE_ENDIAN
57 #elif defined(__x86_64)
59 #define RTS_LITTLE_ENDIAN
61 #elif defined(__i960__)
63 #define RTS_LITTLE_ENDIAN
65 #elif defined(_ARCH_PPC)
67 #define RTS_BIG_ENDIAN
69 #elif defined(__ppc__)
71 #define RTS_BIG_ENDIAN
73 #elif defined(__sparc__)
75 #define RTS_BIG_ENDIAN
77 #elif defined(__alpha__)
80 #define RTS_BIG_ENDIAN
82 #define RTS_LITTLE_ENDIAN
87 #error "Unknown CPU type - can't proceed!"
96 #if defined(__linux__)
97 #define TARGET_SYSTEM "LINUX"
98 #elif defined(__APPLE__)
99 #define TARGET_SYSTEM "LINUX"
100 #elif defined(__sun__)
101 #define TARGET_SYSTEM "SUN"
102 #elif defined(__osf__)
103 #define TARGET_SYSTEM "OSF1"
104 #elif defined(__vxworks__)
106 #if defined(__i960__)
107 #define TARGET_SYSTEM "I960"
109 #define TARGET_SYSTEM "MVME"
113 #error "Unknown OS type - can't proceed!"
120 #ifdef RTS_PROJECT_STAR
122 #define RTS_PROJECT "STAR"
124 #define PROJDIR "/RTS"
128 #ifdef RTS_PROJECT_PP
130 #define RTS_PROJECT "PP"
132 #define PROJDIR "/PP"
136 #define RTS_PROJECT_STAR
137 #define RTS_PROJECT "STAR"
138 #define PROJDIR "/tmp"
143 #define RTS_BINDIR PROJDIR "/bin/" TARGET_SYSTEM
148 #if defined(__linux__) && ! defined(__APPLE__)
150 #include <byteswap.h>
152 #define swap16(x) bswap_16(x)
153 #define swap32(x) bswap_32(x)
157 extern inline unsigned short swap16(
unsigned short x)
159 return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)) ;
162 extern inline unsigned int swap32(
unsigned int x)
164 return ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
165 (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) ;
168 extern inline unsigned long long swap64(
unsigned long long x) {
169 unsigned long long ret = x;
170 unsigned int *low = (
unsigned int *)&ret;
171 unsigned int *high = low + 1;
173 *high = swap32(*high);
181 extern inline float swapf(
float f)
184 memcpy((
char *)&x, (
char *)&f, 4);
186 memcpy((
char *)&f, (
char *)&x, 4);
190 extern inline void swapBuff32(
unsigned int *buff,
int n)
192 for(
int i=0;i<n;i++) {
193 *buff = swap32(*buff);
198 #if defined(RTS_LITTLE_ENDIAN)
202 #define l2hfloat(x) (x)
206 #define b2hfloat(x) swapf(x)
207 #define b2h64(x) swap64(x)
208 #define b2h32(x) swap32(x)
209 #define b2h16(x) swap16(x)
211 #elif defined(RTS_BIG_ENDIAN)
215 #define l2hfloat(x) swapf(x)
216 #define l2h64(x) swap64(x)
217 #define l2h32(x) swap32(x)
218 #define l2h16(x) swap16(x)
219 #define b2hfloat(x) (x)
226 #error "ENDIANESS NOT DEFINED!"
230 #define qswap16(test,x) ((test)?swap16(x):(x))
231 #define qswap32(test,x) ((test)?swap32(x):(x))
232 #define qswap64(test,x) ((test)?swap64(x):(x))
237 #if __GNUC__ == 2 && __GNUC_MINOR__ < 96
238 #define __builtin_expect(x, expected_value) (x)
241 #define likely(x) __builtin_expect((x),1)
242 #define unlikely(x) __builtin_expect((x),0)
248 #define u_int unsigned int
249 typedef unsigned char u_char ;
250 typedef unsigned short u_short ;
256 typedef unsigned long long int UINT64;
258 #define hi64(x) ((UINT32)(x >> 32))
259 #define lo64(x) ((UINT32)(x & 0xffffffff))
260 #define make64(lo, hi) ((UINT64)(((UINT64)hi << 32) | lo))
264 #define lseek64 lseek