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