From: <sag...@us...> - 2014-03-03 16:44:54
|
Revision: 3813 http://sourceforge.net/p/modplug/code/3813 Author: saga-games Date: 2014-03-03 16:44:47 +0000 (Mon, 03 Mar 2014) Log Message: ----------- [Ref] Remove pointless "Pow2xSmall" in serialization code. [Fix] __readeflags() should use a 64-bit variable in 64-bit builds. [Imp] Sample tab: Don't crash when trying to load soundtouch library that is not a suitable DLL (e.g. different bitness). [Mod] Don't even execute CPUID when /noAssembly is specified. Modified Paths: -------------- trunk/OpenMPT/common/misc_util.cpp trunk/OpenMPT/common/serialization_utils.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Mptrack.cpp Modified: trunk/OpenMPT/common/misc_util.cpp =================================================================== --- trunk/OpenMPT/common/misc_util.cpp 2014-03-03 16:41:27 UTC (rev 3812) +++ trunk/OpenMPT/common/misc_util.cpp 2014-03-03 16:44:47 UTC (rev 3813) @@ -269,10 +269,10 @@ static bool has_cpuid() //--------------------- { - const uint32 eflags_cpuid = 1<<21; - uint32 old_eflags = __readeflags(); + const size_t eflags_cpuid = 1 << 21; + size_t old_eflags = __readeflags(); __writeeflags(old_eflags ^ eflags_cpuid); - bool result = ((__readeflags() ^ old_eflags) & eflags_cpuid) ? true : false; + bool result = ((__readeflags() ^ old_eflags) & eflags_cpuid) != 0; __writeeflags(old_eflags); return result; } @@ -286,7 +286,6 @@ if(has_cpuid()) { - cpuid_result VendorString = cpuid(0x00000000u); cpuid_result StandardFeatureFlags = cpuid(0x00000001u); @@ -297,22 +296,16 @@ if(VendorString.as_string() == "AuthenticAMD") { - cpuid_result ExtendedVendorString = cpuid(0x80000000u); if(ExtendedVendorString.a >= 0x80000001u) { - cpuid_result ExtendedFeatureFlags = cpuid(0x80000001u); if(ExtendedFeatureFlags.d & (1<<22)) ProcSupport |= PROCSUPPORT_AMD_MMXEXT; if(ExtendedFeatureFlags.d & (1<<31)) ProcSupport |= PROCSUPPORT_AMD_3DNOW; if(ExtendedFeatureFlags.d & (1<<30)) ProcSupport |= PROCSUPPORT_AMD_3DNOW2; - } - } - } - } Modified: trunk/OpenMPT/common/serialization_utils.cpp =================================================================== --- trunk/OpenMPT/common/serialization_utils.cpp 2014-03-03 16:41:27 UTC (rev 3812) +++ trunk/OpenMPT/common/serialization_utils.cpp 2014-03-03 16:44:47 UTC (rev 3813) @@ -144,17 +144,11 @@ } -static const uint8 pow2xTable[] = {1, 2, 4, 8, 16, 32, 64, 128}; - -// Returns 2^n. n must be within {0,...,7}. -static inline uint8 Pow2xSmall(const uint8& exp) {ASSERT(exp <= 7); return pow2xTable[exp];} - - void ReadAdaptive1248(std::istream& iStrm, uint64& val) //----------------------------------------------------- { Binaryread<uint64>(iStrm, val, 1); - uint8 bc = Pow2xSmall(static_cast<uint8>(val & 3)); + uint8 bc = 1 << static_cast<uint8>(val & 3); int byte = 1; val &= 0xff; while(bc > 1) @@ -450,7 +444,7 @@ if(flags != s_DefaultFlagbyte) { WriteAdaptive1234(oStrm, 2); //Headersize - now it is 2. - Binarywrite<uint8>(oStrm, HeaderId_FlagByte); + Binarywrite<uint8>(oStrm, HeaderId_FlagByte); Binarywrite<uint8>(oStrm, flags); } else @@ -631,7 +625,7 @@ if (Testbit(header, 5)) { - Binaryread<uint8>(iStrm, tempU8); + Binaryread<uint8>(iStrm, tempU8); iStrm.ignore(tempU8); } @@ -666,7 +660,7 @@ iStrm.ignore(size * (GetFlag(RwfRTwoBytesDescChar) ? 2 : 1)); } - if(Testbit(flagbyte, 3)) + if(Testbit(flagbyte, 3)) iStrm.ignore(5); // Read entrycount Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-03-03 16:41:27 UTC (rev 3812) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-03-03 16:44:47 UTC (rev 3813) @@ -1833,9 +1833,13 @@ HANDLE handleSt = NULL; // Check whether the DLL file exists. - if(PathFileExistsW((CTrackApp::GetAppDirPath() + MPT_PATHSTRING("OpenMPT_SoundTouch_f32.dll")).AsNative().c_str()) == TRUE) + HMODULE dllHandle = LoadLibraryW((CTrackApp::GetAppDirPath() + MPT_PATHSTRING("OpenMPT_SoundTouch_f32.dll")).AsNative().c_str()); + if(dllHandle != NULL) + { + FreeLibrary(dllHandle); handleSt = soundtouch_createInstance(); - if (handleSt == NULL) + } + if (handleSt == NULL) { MsgBox(IDS_SOUNDTOUCH_LOADFAILURE); return -1; Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2014-03-03 16:41:27 UTC (rev 3812) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2014-03-03 16:44:47 UTC (rev 3813) @@ -299,34 +299,30 @@ //================================================ { public: - bool m_bNoDls, m_bSafeMode, m_bNoPlugins, + bool m_bNoDls, m_bNoPlugins, m_bNoAssembly, m_bPortable, m_bNoSettingsOnNewVersion; public: CMPTCommandLineInfo() { - m_bNoDls = m_bSafeMode = - m_bNoPlugins = m_bNoSettingsOnNewVersion = m_bPortable = false; + m_bNoDls = m_bNoPlugins = m_bNoAssembly = + m_bPortable = m_bNoSettingsOnNewVersion = false; } - virtual void ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast); -}; - - -void CMPTCommandLineInfo::ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast) -//----------------------------------------------------------------------------- -{ - if ((lpszParam) && (bFlag)) + virtual void ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast) { - if (!lstrcmpi(lpszParam, _T("nologo"))) { m_bShowSplash = FALSE; return; } else - if (!lstrcmpi(lpszParam, _T("nodls"))) { m_bNoDls = true; return; } else - if (!lstrcmpi(lpszParam, _T("noplugs"))) { m_bNoPlugins = true; return; } else - if (!lstrcmpi(lpszParam, _T("portable"))) { m_bPortable = true; return; } else - if (!lstrcmpi(lpszParam, _T("noSettingsOnNewVersion"))) { m_bNoSettingsOnNewVersion = true; return; } - if (!lstrcmpi(lpszParam, _T("fullMemDump"))) { ExceptionHandler::fullMemDump = true; return; } - if (!lstrcmpi(lpszParam, _T("noAssembly"))) { ProcSupport = 0; return; } + if ((lpszParam) && (bFlag)) + { + if (!lstrcmpi(lpszParam, _T("nologo"))) { m_bShowSplash = FALSE; return; } + if (!lstrcmpi(lpszParam, _T("nodls"))) { m_bNoDls = true; return; } + if (!lstrcmpi(lpszParam, _T("noplugs"))) { m_bNoPlugins = true; return; } + if (!lstrcmpi(lpszParam, _T("portable"))) { m_bPortable = true; return; } + if (!lstrcmpi(lpszParam, _T("noSettingsOnNewVersion"))) { m_bNoSettingsOnNewVersion = true; return; } + if (!lstrcmpi(lpszParam, _T("fullMemDump"))) { ExceptionHandler::fullMemDump = true; return; } + if (!lstrcmpi(lpszParam, _T("noAssembly"))) { m_bNoAssembly = true; return; } + } + CCommandLineInfo::ParseParam(lpszParam, bFlag, bLast); } - CCommandLineInfo::ParseParam(lpszParam, bFlag, bLast); -} +}; ///////////////////////////////////////////////////////////////////////////// @@ -853,11 +849,6 @@ Log("OpenMPT Start"); - // Initialize Audio -#ifdef ENABLE_ASM - InitProcSupport(); -#endif - ASSERT(nullptr == m_pDocManager); m_pDocManager = new CModDocManager(); @@ -867,6 +858,13 @@ CMPTCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); +#ifdef ENABLE_ASM + if(cmdInfo.m_bNoAssembly) + ProcSupport = 0; + else + InitProcSupport(); +#endif + m_pTrackerDirectories = new TrackerDirectories(); // Set up paths to store configuration in This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |