00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _RTS_H_
00027 #define _RTS_H_
00028
00029 #ifndef __GNUC__
00030 #warning "This may NOT work on non-GNUC compilers!"
00031 #endif
00032
00033
00034
00035
00036
00037
00038 #if defined(RTS_LITTLE_ENDIAN)
00039 #elif defined(RTS_BIG_ENDIAN)
00040 #else
00041
00042
00043 #if defined(__i386__)
00044
00045 #define RTS_LITTLE_ENDIAN
00046
00047 #elif defined(__x86_64)
00048
00049 #define RTS_LITTLE_ENDIAN
00050
00051 #elif defined(i960)
00052
00053 #define RTS_LITTLE_ENDIAN
00054
00055 #elif defined(_ARCH_PPC)
00056
00057 #define RTS_BIG_ENDIAN
00058
00059 #elif defined(ppc)
00060
00061 #define RTS_BIG_ENDIAN
00062
00063 #elif defined(sparc)
00064
00065 #define RTS_BIG_ENDIAN
00066
00067 #elif defined(__alpha) && !defined(linux)
00068
00069 #define RTS_BIG_ENDIAN
00070
00071 #elif defined(__alpha)
00072
00073 #define RTS_LITTLE_ENDIAN
00074
00075 #else
00076 #error "Unknown CPU type - can't proceed!"
00077 #endif
00078
00079 #endif
00080
00081
00082 #ifndef TARGET_SYSTEM
00083
00084 #if defined(__linux__)
00085 #define TARGET_SYSTEM "LINUX"
00086 #elif defined(sun)
00087 #define TARGET_SYSTEM "SUN"
00088 #elif defined(__osf__)
00089 #define TARGET_SYSTEM "OSF1"
00090 #elif defined(vxworks)
00091
00092 #if defined(i960)
00093 #define TARGET_SYSTEM "I960"
00094 #else
00095 #define TARGET_SYSTEM "MVME"
00096 #endif
00097
00098 #else
00099 #error "Unknown OS type - can't proceed!"
00100 #endif
00101
00102 #endif
00103
00104
00105 #ifdef RTS_PROJECT_STAR
00106
00107 #define RTS_PROJECT "STAR"
00108 #ifndef PROJDIR
00109 #define PROJDIR "/RTS"
00110 #endif
00111
00112 #else
00113 #ifdef RTS_PROJECT_PP
00114
00115 #define RTS_PROJECT "PP"
00116 #ifndef PROJDIR
00117 #define PROJDIR "/PP"
00118 #endif
00119 #else
00120
00121 #define RTS_PROJECT_STAR
00122 #define RTS_PROJECT "STAR"
00123 #define PROJDIR "/tmp"
00124 #endif
00125 #endif
00126
00127 #ifndef RTS_BINDIR
00128 #define RTS_BINDIR PROJDIR "/bin/" TARGET_SYSTEM
00129 #endif
00130
00131
00132
00133 #ifdef __linux__
00134
00135 #include <byteswap.h>
00136
00137 #define swap16(x) bswap_16(x)
00138 #define swap32(x) bswap_32(x)
00139
00140 #else
00141
00142 extern inline unsigned short swap16(unsigned short x)
00143 {
00144 return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)) ;
00145 }
00146
00147 extern inline unsigned int swap32(unsigned int x)
00148 {
00149 return ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
00150 (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) ;
00151 }
00152
00153
00154 #endif
00155
00156 #if defined(RTS_LITTLE_ENDIAN)
00157
00158 #define RTS_ENDIAN 0
00159
00160 #define l2h32(x) (x)
00161 #define l2h16(x) (x)
00162 #define b2h32(x) swap32(x)
00163 #define b2h16(x) swap16(x)
00164
00165 #elif defined(RTS_BIG_ENDIAN)
00166
00167 #define RTS_ENDIAN 1
00168
00169 #define l2h32(x) swap32(x)
00170 #define l2h16(x) swap16(x)
00171 #define b2h32(x) (x)
00172 #define b2h16(x) (x)
00173
00174 #else
00175
00176 #error "ENDIANESS NOT DEFINED!"
00177
00178 #endif
00179
00180
00181
00182
00183 #if __GNUC__ == 2 && __GNUC_MINOR__ < 96
00184 #define __builtin_expect(x, expected_value) (x)
00185 #endif
00186
00187 #define likely(x) __builtin_expect((x),1)
00188 #define unlikely(x) __builtin_expect((x),0)
00189
00190
00191 #endif