00001 00002 00003 00004 #ifndef GOSU_PLATFORM_HPP 00005 #define GOSU_PLATFORM_HPP 00006 00007 #ifdef __BIG_ENDIAN__ 00008 #define GOSU_IS_BIG_ENDIAN 00009 #define IDENTITY_FUN bigToNative 00010 #define IDENTITY_FUN2 nativeToBig 00011 #define CONV_FUN littleToNative 00012 #define CONV_FUN2 nativeToLittle 00013 #else 00014 #define GOSU_IS_LITTLE_ENDIAN 00015 #define IDENTITY_FUN littleToNative 00016 #define IDENTITY_FUN2 nativeToLittle 00017 #define CONV_FUN bigToNative 00018 #define CONV_FUN2 nativeToBig 00019 #endif 00020 00021 #include <algorithm> 00022 00023 namespace Gosu 00024 { 00025 template<typename T> T IDENTITY_FUN(T t) { return t; } 00026 template<typename T> T IDENTITY_FUN2(T t) { return t; } 00027 00028 template<typename T> 00029 T CONV_FUN(T t) 00030 { 00031 char* begin = reinterpret_cast<char*>(&t); 00032 std::reverse(begin, begin + sizeof t); 00033 return t; 00034 } 00035 00036 template<typename T> T CONV_FUN2(T t) { return CONV_FUN(t); } 00037 } 00038 00039 #undef IDENTITY_FUN 00040 #undef IDENTITY_FUN2 00041 #undef CONV_FUN 00042 #undef CONV_FUN2 00043 00044 #if defined(_MSC_VER) 00045 #define GOSU_NORETURN __declspec(noreturn) 00046 #elif defined(__GNUC__) 00047 #define GOSU_NORETURN __attribute__ ((noreturn)) 00048 #endif 00049 00050 #if defined(WIN32) 00051 # define GOSU_IS_WIN 00052 #else 00053 # define GOSU_IS_UNIX 00054 # if defined(__linux) || defined(__FreeBSD__) 00055 # define GOSU_IS_X 00056 # else 00057 # define GOSU_IS_MAC 00058 # include <TargetConditionals.h> 00059 # if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR 00060 # define GOSU_IS_IPHONE 00061 # endif 00062 # endif 00063 #endif 00064 00065 #endif
Documentation not clear enough? Please go to one of the places listed on http://www.libgosu.org/ and leave feedback. Thanks!