From: <man...@us...> - 2013-06-28 21:20:28
|
Revision: 2434 http://sourceforge.net/p/modplug/code/2434 Author: manxorist Date: 2013-06-28 21:20:18 +0000 (Fri, 28 Jun 2013) Log Message: ----------- [Ref] Move platform endianness detection from typedefs.h to CompilerDetect.h so we can use in in BuildSettings.h. [Ref] Always disable file saving on big-endian platforms for now because it is known broken and unlikely to be fixed anytime soon. [Ref] Make testsuite compileable without file saving support. Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/common/CompilerDetect.h trunk/OpenMPT/common/typedefs.h trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2013-06-28 21:02:30 UTC (rev 2433) +++ trunk/OpenMPT/common/BuildSettings.h 2013-06-28 21:20:18 UTC (rev 2434) @@ -128,7 +128,7 @@ #elif defined(LIBOPENMPT_BUILD) #define ENABLE_TESTS -#define MODPLUG_NO_FILESAVE +//#define MODPLUG_NO_FILESAVE //#define NO_LOGGING #define NO_ARCHIVE_SUPPORT //#define NO_FILEREADER_STD_ISTREAM @@ -170,9 +170,13 @@ #endif #if defined(ENABLE_TESTS) && defined(MODPLUG_NO_FILESAVE) -#undef MODPLUG_NO_FILESAVE // tests require file saving +#undef MODPLUG_NO_FILESAVE // tests recommend file saving #endif +#if defined(PLATFORM_BIG_ENDIAN) && !defined(MODPLUG_NO_FILESAVE) +#define MODPLUG_NO_FILESAVE // file saving is broken on big endian +#endif + #if !defined(NO_LIBMODPLUG) #if !defined(LIBOPENMPT_BUILD) || (defined(LIBOPENMPT_BUILD) && defined(_WIN32) && !defined(LIBOPENMPT_BUILD_DLL)) #define NO_LIBMODPLUG // libmodplug interface emulation requires libopenmpt dll build on windows Modified: trunk/OpenMPT/common/CompilerDetect.h =================================================================== --- trunk/OpenMPT/common/CompilerDetect.h 2013-06-28 21:02:30 UTC (rev 2433) +++ trunk/OpenMPT/common/CompilerDetect.h 2013-06-28 21:20:18 UTC (rev 2434) @@ -87,3 +87,55 @@ #define MPT_MSVC_AT_LEAST(version,sp) 0 #define MPT_MSVC_BEFORE(version,sp) 0 #endif + + + +#if MPT_COMPILER_MSVC + #define PLATFORM_LITTLE_ENDIAN +#elif MPT_COMPILER_GCC + #if MPT_GCC_AT_LEAST(4,6,0) + #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + #define PLATFORM_BIG_ENDIAN + #elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + #define PLATFORM_LITTLE_ENDIAN + #endif + #endif +#elif MPT_COMPILER_CLANG + #if MPT_CLANG_AT_LEAST(3,2,0) + #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + #define PLATFORM_BIG_ENDIAN + #elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + #define PLATFORM_LITTLE_ENDIAN + #endif + #endif +#endif + +// fallback: +#if !defined(PLATFORM_BIG_ENDIAN) && !defined(PLATFORM_LITTLE_ENDIAN) + // taken from boost/detail/endian.hpp + #if (defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)) \ + || (defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)) \ + || (defined(_STLP_BIG_ENDIAN) && !defined(_STLP_LITTLE_ENDIAN)) + #define PLATFORM_BIG_ENDIAN + #elif (defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)) \ + || (defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) \ + || (defined(_STLP_LITTLE_ENDIAN) && !defined(_STLP_BIG_ENDIAN)) + #define PLATFORM_LITTLE_ENDIAN + #elif defined(__sparc) || defined(__sparc__) \ + || defined(_POWER) || defined(__powerpc__) \ + || defined(__ppc__) || defined(__hpux) || defined(__hppa) \ + || defined(_MIPSEB) || defined(_POWER) \ + || defined(__s390__) + #define PLATFORM_BIG_ENDIAN + #elif defined(__i386__) || defined(__alpha__) \ + || defined(__ia64) || defined(__ia64__) \ + || defined(_M_IX86) || defined(_M_IA64) \ + || defined(_M_ALPHA) || defined(__amd64) \ + || defined(__amd64__) || defined(_M_AMD64) \ + || defined(__x86_64) || defined(__x86_64__) \ + || defined(_M_X64) || defined(__bfin__) + #define PLATFORM_LITTLE_ENDIAN + #else + #error "unkown endianness" + #endif +#endif Modified: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h 2013-06-28 21:02:30 UTC (rev 2433) +++ trunk/OpenMPT/common/typedefs.h 2013-06-28 21:20:18 UTC (rev 2434) @@ -31,59 +31,7 @@ #if MPT_COMPILER_MSVC - #define PLATFORM_LITTLE_ENDIAN -#elif MPT_COMPILER_GCC - #if MPT_GCC_AT_LEAST(4,6,0) - #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ - #define PLATFORM_BIG_ENDIAN - #elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ - #define PLATFORM_LITTLE_ENDIAN - #endif - #endif -#elif MPT_COMPILER_CLANG - #if MPT_CLANG_AT_LEAST(3,2,0) - #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ - #define PLATFORM_BIG_ENDIAN - #elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ - #define PLATFORM_LITTLE_ENDIAN - #endif - #endif -#endif -// fallback: -#if !defined(PLATFORM_BIG_ENDIAN) && !defined(PLATFORM_LITTLE_ENDIAN) - // taken from boost/detail/endian.hpp - #if (defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)) \ - || (defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)) \ - || (defined(_STLP_BIG_ENDIAN) && !defined(_STLP_LITTLE_ENDIAN)) - #define PLATFORM_BIG_ENDIAN - #elif (defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)) \ - || (defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) \ - || (defined(_STLP_LITTLE_ENDIAN) && !defined(_STLP_BIG_ENDIAN)) - #define PLATFORM_LITTLE_ENDIAN - #elif defined(__sparc) || defined(__sparc__) \ - || defined(_POWER) || defined(__powerpc__) \ - || defined(__ppc__) || defined(__hpux) || defined(__hppa) \ - || defined(_MIPSEB) || defined(_POWER) \ - || defined(__s390__) - #define PLATFORM_BIG_ENDIAN - #elif defined(__i386__) || defined(__alpha__) \ - || defined(__ia64) || defined(__ia64__) \ - || defined(_M_IX86) || defined(_M_IA64) \ - || defined(_M_ALPHA) || defined(__amd64) \ - || defined(__amd64__) || defined(_M_AMD64) \ - || defined(__x86_64) || defined(__x86_64__) \ - || defined(_M_X64) || defined(__bfin__) - #define PLATFORM_LITTLE_ENDIAN - #else - #error "unkown endianness" - #endif -#endif - - - -#if MPT_COMPILER_MSVC - #if MPT_MSVC_BEFORE(2010,0) #define nullptr 0 #endif Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2013-06-28 21:02:30 UTC (rev 2433) +++ trunk/OpenMPT/test/test.cpp 2013-06-28 21:20:18 UTC (rev 2434) @@ -1289,6 +1289,8 @@ return; } +#ifndef MODPLUG_NO_FILESAVE + static void SaveIT(const TSoundFileContainer &sndFile, const std::string &filename) { sndFile->SaveIT(filename.c_str(), false); @@ -1306,8 +1308,10 @@ #endif +#endif + // Test file loading and saving void TestLoadSaveFile() //--------------------- @@ -1324,13 +1328,16 @@ TestLoadMPTMFile(GetrSoundFile(sndFileContainer)); - // Test file saving - SaveIT(sndFileContainer, filenameBase + "saved.mptm"); + #ifndef MODPLUG_NO_FILESAVE + // Test file saving + SaveIT(sndFileContainer, filenameBase + "saved.mptm"); + #endif DestroySoundFileContainer(sndFileContainer); } // Reload the saved file and test if everything is still working correctly. + #ifndef MODPLUG_NO_FILESAVE { TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + "saved.mptm"); @@ -1338,6 +1345,7 @@ DestroySoundFileContainer(sndFileContainer); } + #endif // Test XM file loading { @@ -1353,13 +1361,16 @@ GetrSoundFile(sndFileContainer).m_nSamples++; GetrSoundFile(sndFileContainer).Instruments[1]->Keyboard[110] = GetrSoundFile(sndFileContainer).GetNumSamples(); - // Test file saving - SaveXM(sndFileContainer, filenameBase + "saved.xm"); + #ifndef MODPLUG_NO_FILESAVE + // Test file saving + SaveXM(sndFileContainer, filenameBase + "saved.xm"); + #endif DestroySoundFileContainer(sndFileContainer); } // Reload the saved file and test if everything is still working correctly. + #ifndef MODPLUG_NO_FILESAVE { TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + "saved.xm"); @@ -1367,6 +1378,7 @@ DestroySoundFileContainer(sndFileContainer); } + #endif // Test S3M file loading { @@ -1374,13 +1386,16 @@ TestLoadS3MFile(GetrSoundFile(sndFileContainer), false); - // Test file saving - SaveS3M(sndFileContainer, filenameBase + "saved.s3m"); + #ifndef MODPLUG_NO_FILESAVE + // Test file saving + SaveS3M(sndFileContainer, filenameBase + "saved.s3m"); + #endif DestroySoundFileContainer(sndFileContainer); } // Reload the saved file and test if everything is still working correctly. + #ifndef MODPLUG_NO_FILESAVE { TSoundFileContainer sndFileContainer = CreateSoundFileContainer(filenameBase + "saved.s3m"); @@ -1388,6 +1403,7 @@ DestroySoundFileContainer(sndFileContainer); } + #endif } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |