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 #ifndef __SGLDB_H
00026 #define __SGLDB_H
00027
00028 #if defined(WIN32) && defined(_DLL)
00029
00030 #ifdef sgldb_DLL_FILE
00031 #define SGLDB_DLL_API __declspec(dllexport)
00032 #else
00033 #define SGLDB_DLL_API __declspec(dllimport)
00034 #endif
00035 #else
00036 #define SGLDB_DLL_API
00037 #endif
00038
00039 #include <sgl.h>
00040
00041 #if defined(linux)
00042 #include <endian.h>
00043 #endif
00044
00045 #if defined(WIN32) || (defined(sgi) && defined(unix) && defined(_MIPSEL)) || (defined(sun) && defined(unix) && !defined(_BIG_ENDIAN)) || (defined(__BYTE_ORDER) && (__BYTE_ORDER == __LITTLE_ENDIAN)) || (defined(__APPLE__) && defined( __LITTLE_ENDIAN__ ))
00046 # define SGL_LITTLE_ENDIAN
00047 #elif (defined(sgi) && defined(unix) && defined(_MIPSEB)) || (defined(sun) && defined(unix) && defined(_BIG_ENDIAN)) || defined(vxw) || (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || (defined(__APPLE__) && defined( __BIG_ENDIAN__) )
00048 # define SGL_BIG_ENDIAN
00049 #else
00050 # error unknown endian type
00051 #endif
00052
00053 static inline void sglEndianSwap(unsigned int *x)
00054 {
00055 *x = (( *x >> 24 ) & 0x000000FF ) |
00056 (( *x >> 8 ) & 0x0000FF00 ) |
00057 (( *x << 8 ) & 0x00FF0000 ) |
00058 (( *x << 24 ) & 0xFF000000 ) ;
00059 }
00060
00061 static inline void sglEndianSwap(int *x)
00062 {
00063 *x = (( *x >> 24 ) & 0x000000FF ) |
00064 (( *x >> 8 ) & 0x0000FF00 ) |
00065 (( *x << 8 ) & 0x00FF0000 ) |
00066 (( *x << 24 ) & 0xFF000000 ) ;
00067 }
00068
00069 static inline void sglEndianSwap(unsigned short *x)
00070 {
00071 *x = (( *x >> 8 ) & 0x00FF ) |
00072 (( *x << 8 ) & 0xFF00 ) ;
00073 }
00074
00075 static inline void sglEndianSwap(short *x)
00076 {
00077 *x = (( *x >> 8 ) & 0x00FF ) |
00078 (( *x << 8 ) & 0xFF00 ) ;
00079 }
00080
00081 #endif