Skip to content

Commit

Permalink
preload %FARHOME%\legacy lua51.dll for x86 without SSE2
Browse files Browse the repository at this point in the history
  • Loading branch information
w17 committed Aug 30, 2017
1 parent 07e454d commit 5129860
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
4 changes: 4 additions & 0 deletions far/changelog
@@ -1,3 +1,7 @@
w17 30.08.2017 12:21:12 +0300 - build 5015

1. Plerolad %FARHOME%\legacy\lua51.dll if x86 CPU doesn't support SSE2.

drkns 26.08.2017 11:20:44 +0100 - build 5014

1. В макрофункции date творилась дичь:
Expand Down
30 changes: 29 additions & 1 deletion far/main.cpp
Expand Up @@ -149,6 +149,34 @@ 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
{
bool have_sse2 = false;
int info[4] = { 0, 0, 0, 0 };
#ifdef _MSC_VER
#include <intrin.h>
__cpuidex(info, 0, 0);
if (info[0] >= 1) {
__cpuidex(info, 1, 0);
#else
#include <cpuid.h>
__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());
}
}
#endif

if (!ename.empty() || !vname.empty())
{
Global->OnlyEditorViewerUsed = true;
Expand Down Expand Up @@ -634,7 +662,7 @@ static int mainImpl(const range<wchar_t**>& Args)
Iter = Next;
}
}
}
}
break;

case L'T':
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
@@ -1 +1 @@
m4_define(BUILD,5014)m4_dnl
m4_define(BUILD,5015)m4_dnl

0 comments on commit 5129860

Please sign in to comment.