Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SIMD on MSVC #639

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ endif()
if(NOT MSVC OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT DISABLE_SSE4 AND HOST_X64)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
elseif(MSVC AND NOT DISABLE_SSE4)
# Tell our SIMD code to use SSE4.1 by defining the relevant macros.
# Clang defines these macros, MSVC does not.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D__SSE3__ /D__SSE4_1__")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D__SSE3__ /D__SSE4_1__")
endif()

if(ENABLE_RENDERDOC_API)
Expand Down
14 changes: 0 additions & 14 deletions include/helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <cstdint>
#include <iostream>
#include <iterator>
#include <sstream>
#include <string>
#include <vector>
#include <memory>
Expand Down Expand Up @@ -162,19 +161,6 @@ namespace Helpers {
return std::bit_cast<To, From>(from);
}
#endif

static std::vector<std::string> split(const std::string& s, const char c) {
std::istringstream tmp(s);
std::vector<std::string> result(1);

while (std::getline(tmp, *result.rbegin(), c)) {
result.emplace_back();
}

// Remove temporary slot
result.pop_back();
return result;
}
}; // namespace Helpers

// UDLs for memory size values
Expand Down
18 changes: 17 additions & 1 deletion src/core/crypto/aes_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>

#include "helpers.hpp"

Expand All @@ -15,6 +18,19 @@ namespace Crypto {
return;
}

auto splitString = [](const std::string& s, const char c) -> std::vector<std::string> {
std::istringstream tmp(s);
std::vector<std::string> result(1);

while (std::getline(tmp, *result.rbegin(), c)) {
result.emplace_back();
}

// Remove temporary slot
result.pop_back();
return result;
};

while (!file.eof()) {
std::string line;
std::getline(file, line);
Expand All @@ -24,7 +40,7 @@ namespace Crypto {
continue;
}

const auto parts = Helpers::split(line, '=');
const auto parts = splitString(line, '=');
if (parts.size() != 2) {
Helpers::warn("Keys: Failed to parse %s", line.c_str());
continue;
Expand Down
Loading