00001
00006 #ifndef VL_HOST_H
00007 #define VL_HOST_H
00008
00009
00010
00011
00012
00013
00016 #if defined(linux) || \
00017 defined(__linux) || \
00018 defined(__linux__) || \
00019 defined(__DOXYGEN__)
00020 #define VL_OS_LINUX 1
00021 #endif
00022
00023 #if (defined(__APPLE__) & defined(__MACH__)) || \
00024 defined(__DOXYGEN__)
00025 #define VL_OS_MACOSX 1
00026 #endif
00027
00028 #if defined(__WIN32__) || \
00029 defined(_WIN32) || \
00030 defined(__DOXYGEN__)
00031 #define VL_OS_WIN 1
00032 #endif
00033
00034 #if defined(_WIN64) || \
00035 defined(__DOXYGEN__)
00036 #define VL_OS_WIN64 1
00037 #endif
00038
00042 #if defined(__GNUC__) || defined(__DOXYGEN__)
00043 # if defined(__GNUC_PATCHLEVEL__)
00044 # define VL_COMPILER_GNUC (__GNUC__ * 10000 \
00045 + __GNUC_MINOR__ * 100 \
00046 + __GNUC_PATCHLEVEL__)
00047 # else
00048 # define VL_COMPILER_GNUC (__GNUC__ * 10000 \
00049 + __GNUC_MINOR__ * 100)
00050 # endif
00051 #endif
00052
00053 #if defined(_MSC_VER) || defined(__DOXYGEN__)
00054 #define VL_COMPILER_MSC _MSC_VER
00055 #endif
00056
00057 #if defined(__LCC__) || defined(__DOXYGEN__)
00058 #warning "LCC support is experimental!"
00059 #define VL_COMPILER_LCC 1
00060 #endif
00061
00066 #if defined(i386) || \
00067 defined(__i386__) || \
00068 defined(__DOXYGEN__)
00069 #define VL_ARCH_IX86 300
00070 #elif defined(__i486__)
00071 #define VL_ARCH_IX86 400
00072 #elif defined(__i586__)
00073 #define VL_ARCH_IX86 500
00074 #elif defined(__i686__)
00075 #define VL_ARCH_IX86 600
00076 #elif defined(_M_IX86)
00077 #define VL_ARCH_IX86 _M_IX86
00078 #endif
00079
00080 #if defined(__ia64__) || \
00081 defined(_IA64) || \
00082 defined(__IA64) || \
00083 defined(__ia64) || \
00084 defined(_M_IA64) || \
00085 defined(__DOXYGEN__)
00086 #define VL_ARCH_IA64
00087 #endif
00088
00092 #if defined(__LLP64__) || \
00093 defined(__LLP64) || \
00094 defined(__LLP64) || \
00095 (defined(VL_COMPILER_MSC) & defined(VL_OS_WIN64)) || \
00096 (defined(VL_COMPILER_LCC) & defined(VL_OS_WIN64)) || \
00097 defined(__DOXYGEN__)
00098 #define VL_COMPILER_LLP64
00099 #endif
00100
00101 #if defined(__LP64__) || \
00102 defined(__LP64) || \
00103 defined(__LP64) || \
00104 (defined(VL_OS_MACOSX) & defined(VL_ARCH_IA64)) || \
00105 defined(__DOXYGEN__)
00106 #define VL_COMPILER_LP64
00107 #endif
00108
00109 #if (!defined(VL_COMPILER_LLP64) & !defined(VL_COMPILER_LP64)) || \
00110 defined(__DOXYGEN__)
00111 #define VL_COMPILER_ILP32
00112 #endif
00113
00117 #if defined(__LITTLE_ENDIAN__) || \
00118 defined(VL_ARCH_IX86) || \
00119 defined(VL_ARCH_IA64) || \
00120 defined(__DOXYGEN__)
00121 #define VL_ARCH_LITTLE_ENDIAN
00122 #endif
00123
00124 #if defined(__DOXYGEN__) || \
00125 !defined(VL_ARCH_LITTLE_ENDIAN)
00126 #define VL_ARCH_BIG_ENDIAN
00127 #endif
00128
00130 #if defined(VL_COMPILER_MSC)
00131 #define VL_INLINE static __inline
00132 #define snprintf _snprintf
00133 #define isnan _isnan
00134 #ifdef VL_BUILD_DLL
00135 #define VL_EXPORT __declspec(dllexport)
00136 #else
00137 #define VL_EXPORT __declspec(dllimport)
00138 #endif
00139 #endif
00140
00141 #if defined(VL_COMPILER_LCC)
00142 #define VL_INLINE static __inline
00143 #define snprintf _snprintf
00144 #define isnan _isnan
00145 #ifdef VL_BUILD_DLL
00146 #define VL_EXPORT __declspec(dllexport)
00147 #else
00148 #define VL_EXPORT
00149 #endif
00150 #endif
00151
00152 #if defined(VL_COMPILER_GNUC) || \
00153 defined(__DOXYGEN__)
00154 #define VL_INLINE static __inline__
00155 #ifdef VL_BUILD_DLL
00156 #define VL_EXPORT __attribute__((visibility ("default")))
00157 #else
00158 #define VL_EXPORT
00159 #endif
00160 #endif
00161
00167 #define VL_TRUE 1
00168 #define VL_FALSE 0
00170 #if defined(VL_COMPILER_LP64) || defined(VL_COMPILER_LLP64)
00171 typedef long long vl_int64 ;
00172 typedef int vl_int32 ;
00173 typedef short vl_int16 ;
00174 typedef char vl_int8 ;
00176 typedef long long unsigned vl_uint64 ;
00177 typedef int unsigned vl_uint32 ;
00178 typedef short unsigned vl_uint16 ;
00179 typedef char unsigned vl_uint8 ;
00181 typedef int vl_int ;
00182 typedef unsigned int vl_uint ;
00184 typedef int vl_bool ;
00185 typedef vl_int64 vl_intptr ;
00186 typedef vl_uint64 vl_uintptr ;
00187 #endif
00188
00189 #if defined(VL_COMPILER_ILP32)
00190
00191 #ifdef VL_COMPILER_MSC
00192 typedef __int64 vl_int64 ;
00193 #else
00194 typedef long long vl_int64 ;
00195 #endif
00196
00197 typedef int vl_int32 ;
00198 typedef short vl_int16 ;
00199 typedef char vl_int8 ;
00200
00201 #ifdef VL_COMPILER_MSC
00202 typedef __int64 unsigned vl_uint64 ;
00203 #else
00204 typedef long long unsigned vl_uint64 ;
00205 #endif
00206 typedef int unsigned vl_uint32 ;
00207 typedef short unsigned vl_uint16 ;
00208 typedef char unsigned vl_uint8 ;
00209
00210 typedef int vl_int ;
00211 typedef unsigned int vl_uint ;
00212
00213 typedef int vl_bool ;
00214 typedef vl_int32 vl_intptr ;
00215 typedef vl_uint32 vl_uintptr ;
00216 #endif
00217
00239 #ifdef VL_COMPILER_MSC
00240 #define VL_FL_INT64 "I64"
00241 #else
00242 #define VL_FL_INT64 "ll"
00243 #endif
00244 #define VL_FL_INT32 ""
00245 #define VL_FL_INT16 "h"
00246 #define VL_FL_INT8 "hh"
00247
00254 #define VL_BIG_INT 0x7FFFFFFFL
00255
00257 #define VL_SMALL_INT (- VL_BIG_INT - 1)
00258
00260 #define VL_BIG_UINT 0xFFFFFFFFUL
00261
00268 VL_INLINE void vl_swap_host_big_endianness_8 (void *dst, void* src) ;
00269 VL_INLINE void vl_swap_host_big_endianness_4 (void *dst, void* src) ;
00270 VL_INLINE void vl_swap_host_big_endianness_2 (void *dst, void* src) ;
00276 VL_EXPORT void vl_print_host_info() ;
00277 VL_EXPORT vl_bool vl_cpu_has_sse3 () ;
00278 VL_EXPORT vl_bool vl_cpu_has_sse2 () ;
00281 VL_EXPORT void vl_set_simd_enabled (vl_bool x) ;
00282 VL_EXPORT vl_bool vl_get_simd_enabled() ;
00283
00292 VL_INLINE void
00293 vl_swap_host_big_endianness_8 (void *dst, void* src)
00294 {
00295 char *dst_ = (char*) dst ;
00296 char *src_ = (char*) src ;
00297 #if defined(VL_ARCH_BIG_ENDIAN)
00298 dst_ [0] = src_ [0] ;
00299 dst_ [1] = src_ [1] ;
00300 dst_ [2] = src_ [2] ;
00301 dst_ [3] = src_ [3] ;
00302 dst_ [4] = src_ [4] ;
00303 dst_ [5] = src_ [5] ;
00304 dst_ [6] = src_ [6] ;
00305 dst_ [7] = src_ [7] ;
00306 #else
00307 dst_ [0] = src_ [7] ;
00308 dst_ [1] = src_ [6] ;
00309 dst_ [2] = src_ [5] ;
00310 dst_ [3] = src_ [4] ;
00311 dst_ [4] = src_ [3] ;
00312 dst_ [5] = src_ [2] ;
00313 dst_ [6] = src_ [1] ;
00314 dst_ [7] = src_ [0] ;
00315 #endif
00316 }
00317
00326 VL_INLINE void
00327 vl_swap_host_big_endianness_4 (void *dst, void* src)
00328 {
00329 char *dst_ = (char*) dst ;
00330 char *src_ = (char*) src ;
00331 #if defined(VL_ARCH_BIG_ENDIAN)
00332 dst_ [0] = src_ [0] ;
00333 dst_ [1] = src_ [1] ;
00334 dst_ [2] = src_ [2] ;
00335 dst_ [3] = src_ [3] ;
00336 #else
00337 dst_ [0] = src_ [3] ;
00338 dst_ [1] = src_ [2] ;
00339 dst_ [2] = src_ [1] ;
00340 dst_ [3] = src_ [0] ;
00341 #endif
00342 }
00343
00352 VL_INLINE void
00353 vl_swap_host_big_endianness_2 (void *dst, void* src)
00354 {
00355 char *dst_ = (char*) dst ;
00356 char *src_ = (char*) src ;
00357 #if defined(VL_ARCH_BIG_ENDIAN)
00358 dst_ [0] = src_ [0] ;
00359 dst_ [1] = src_ [1] ;
00360 #else
00361 dst_ [0] = src_ [1] ;
00362 dst_ [1] = src_ [0] ;
00363 #endif
00364 }
00365
00366
00367 #endif