diff --git a/far/changelog b/far/changelog index 3542362445..555f9b1afe 100644 --- a/far/changelog +++ b/far/changelog @@ -1,3 +1,7 @@ +w17 30.08.2017 13:19:19 +0300 - build 5016 + +1. Уточнение 5015 + w17 30.08.2017 12:21:12 +0300 - build 5015 1. Plerolad %FARHOME%\legacy\lua51.dll if x86 CPU doesn't support SSE2. diff --git a/far/far.vcxproj b/far/far.vcxproj index 65852b69c4..a6ff474120 100644 --- a/far/far.vcxproj +++ b/far/far.vcxproj @@ -256,6 +256,7 @@ cl /nologo /c /Fo"$(IntDir)%(Filename)_c++.testobj" /TP api_test.c + @@ -436,7 +437,7 @@ cl /nologo /c /Fo"$(IntDir)%(Filename)_c++.testobj" /TP api_test.c - + diff --git a/far/far.vcxproj.filters b/far/far.vcxproj.filters index bad4fd7b38..43be0cd0b0 100644 --- a/far/far.vcxproj.filters +++ b/far/far.vcxproj.filters @@ -221,6 +221,9 @@ Source Files + + Source Files + Source Files @@ -655,6 +658,9 @@ Header Files + + Header Files + Header Files diff --git a/far/legacy_cpu_check.cpp b/far/legacy_cpu_check.cpp new file mode 100644 index 0000000000..73493eeab4 --- /dev/null +++ b/far/legacy_cpu_check.cpp @@ -0,0 +1,28 @@ +#include "headers.hpp" +#pragma hdrstop + +#include "legacy_cpu_check.hpp" + +bool IsLegacyCPU() +{ +#if defined(_WIN32) && !defined(_WIN64) && (defined(_MSC_VER) || defined(__GNUC__)) + bool have_sse2 = false; + int info[4] = { 0, 0, 0, 0 }; +#ifdef _MSC_VER +#include + __cpuidex(info, 0, 0); + if (info[0] >= 1) { + __cpuidex(info, 1, 0); +#else +#include + __cpuid_count(0, 0, info[0], info[1], info[2], info[3]); + if (info[0] >= 1) { + __cpuid_count(1, 0, info[0], info[1], info[2], info[3]); +#endif + have_sse2 = (info[3] & ((int)1 << 26)) != 0; + } + return !have_sse2; +#else + return false; +#endif +} diff --git a/far/legacy_cpu_check.hpp b/far/legacy_cpu_check.hpp new file mode 100644 index 0000000000..c487139ac5 --- /dev/null +++ b/far/legacy_cpu_check.hpp @@ -0,0 +1,40 @@ +#ifndef LEGACY_CPU_CHECK_HPP_38B388C1_AF11_4F09_9643_074418E35699 +#define LEGACY_CPU_CHECK_HPP_38B388C1_AF11_4F09_9643_074418E35699 +#pragma once + +/* +legacy_cpu_check.hpp + +Ïðîâåðêà ïîääåðæêè SSE2 äëÿ x86 +*/ +/* +Copyright © 1996 Eugene Roshal +Copyright © 2000 Far Group +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +bool IsLegacyCPU(); + +#endif // LASTERROR_HPP_1C20B3B0_E43C_4DCC_9729_DFD883E99DD3 diff --git a/far/main.cpp b/far/main.cpp index 442542577e..092cb17c6f 100644 --- a/far/main.cpp +++ b/far/main.cpp @@ -70,6 +70,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "cvtname.hpp" #include "drivemix.hpp" #include "new_handler.hpp" +#include "legacy_cpu_check.hpp" global *Global = nullptr; @@ -149,33 +150,11 @@ static int MainProcess( ppanel = Global->Opt->LocalProfilePath; } -#if defined(_WIN32) && !defined(_WIN64) && (defined(_MSC_VER) || defined(__GNUC__)) - // actual lua51.dll uses SSE2 instructions on x86. - // so we have to preload legacy lua51.dll if x86 CPU doesn't support SSE2 + if (IsLegacyCPU()) { - bool have_sse2 = false; - int info[4] = { 0, 0, 0, 0 }; -#ifdef _MSC_VER -#include - __cpuidex(info, 0, 0); - if (info[0] >= 1) { - __cpuidex(info, 1, 0); -#else -#include - __cpuid_count(0, 0, info[0], info[1], info[2], info[3]); - if (info[0] >= 1) { - __cpuid_count(1, 0, info[0], info[1], info[2], info[3]); -#endif - have_sse2 = (info[3] & ((int)1 << 26)) != 0; - } - - if (!have_sse2) - { - auto legay_path = Global->g_strFarPath + L"\\legacy\\lua51.dll"; // %FARHOME%\legacy\lua51.dll - LoadLibraryW(legay_path.data()); - } + auto legacy_path = Global->g_strFarPath + L"\\legacy\\lua51.dll"; // %FARHOME%\legacy\lua51.dll + LoadLibraryW(legacy_path.data()); } -#endif if (!ename.empty() || !vname.empty()) { diff --git a/far/makefile_gcc b/far/makefile_gcc index 92732c7a9e..8ab3d55458 100644 --- a/far/makefile_gcc +++ b/far/makefile_gcc @@ -91,6 +91,7 @@ SRCS = \ keyboard.cpp \ language.cpp \ lasterror.cpp \ + legacy_cpu_check.cpp \ locale.cpp \ lockscrn.cpp \ macro.cpp \ diff --git a/far/makefile_vc b/far/makefile_vc index 6119d74e79..667edc56b8 100644 --- a/far/makefile_vc +++ b/far/makefile_vc @@ -175,6 +175,7 @@ LINK_OBJS = \ "$(INTDIR)\keyboard.obj" \ "$(INTDIR)\language.obj" \ "$(INTDIR)\lasterror.obj" \ + "$(INTDIR)\legacy_cpu_check.obj" \ "$(INTDIR)\locale.obj" \ "$(INTDIR)\lockscrn.obj" \ "$(INTDIR)\macro.obj" \ diff --git a/far/vbuild.m4 b/far/vbuild.m4 index d82edeb405..102c11d439 100644 --- a/far/vbuild.m4 +++ b/far/vbuild.m4 @@ -1 +1 @@ -m4_define(BUILD,5015)m4_dnl +m4_define(BUILD,5016)m4_dnl