chore: remove msvc remnants

This commit is contained in:
jpk68
2026-06-29 21:29:19 -04:00
parent 49c9cfc315
commit 7eb70c7858
12 changed files with 6 additions and 212 deletions
+2 -8
View File
@@ -56,17 +56,11 @@ else ( PKGCONFIG_LIBUSB_FOUND )
if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" ) if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" )
# LibUSB-Win32 binary distribution contains several libs. # LibUSB-Win32 binary distribution contains several libs.
# Use the lib that got compiled with the same compiler. # Use the lib that got compiled with the same compiler.
if ( MSVC ) if ( BORLAND )
if ( WIN32 )
set ( LibUSB_LIBRARY_PATH_SUFFIX lib/msvc )
else ( WIN32 )
set ( LibUSB_LIBRARY_PATH_SUFFIX lib/msvc_x64 )
endif ( WIN32 )
elseif ( BORLAND )
set ( LibUSB_LIBRARY_PATH_SUFFIX lib/bcc ) set ( LibUSB_LIBRARY_PATH_SUFFIX lib/bcc )
elseif ( CMAKE_COMPILER_IS_GNUCC ) elseif ( CMAKE_COMPILER_IS_GNUCC )
set ( LibUSB_LIBRARY_PATH_SUFFIX lib/gcc ) set ( LibUSB_LIBRARY_PATH_SUFFIX lib/gcc )
endif ( MSVC ) endif ()
endif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" ) endif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" )
find_library ( usb_LIBRARY find_library ( usb_LIBRARY
+1 -64
View File
@@ -99,70 +99,7 @@ elseif (WIN32)
PATH_SUFFIXES include PATH_SUFFIXES include
) )
if (MSVC) if(_GCC_COMPATIBLE)
# detect target architecture
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/arch.cpp" [=[
#if defined _M_IX86
#error ARCH_VALUE x86_32
#elif defined _M_X64
#error ARCH_VALUE x86_64
#endif
#error ARCH_VALUE unknown
]=])
try_compile(_UNUSED_VAR "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/arch.cpp"
OUTPUT_VARIABLE _COMPILATION_LOG
)
string(REGEX REPLACE ".*ARCH_VALUE ([a-zA-Z0-9_]+).*" "\\1" _TARGET_ARCH "${_COMPILATION_LOG}")
# construct library path
if (_TARGET_ARCH STREQUAL "x86_32")
string(APPEND _PLATFORM_PATH "Win32")
elseif(_TARGET_ARCH STREQUAL "x86_64")
string(APPEND _PLATFORM_PATH "x64")
else()
message(FATAL_ERROR "the ${_TARGET_ARCH} architecture is not supported by Findsodium.cmake.")
endif()
string(APPEND _PLATFORM_PATH "/$$CONFIG$$")
if (MSVC_VERSION LESS 1900)
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 60")
else()
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 50")
endif()
string(APPEND _PLATFORM_PATH "/v${_VS_VERSION}")
if (sodium_USE_STATIC_LIBS)
string(APPEND _PLATFORM_PATH "/static")
else()
string(APPEND _PLATFORM_PATH "/dynamic")
endif()
string(REPLACE "$$CONFIG$$" "Debug" _DEBUG_PATH_SUFFIX "${_PLATFORM_PATH}")
string(REPLACE "$$CONFIG$$" "Release" _RELEASE_PATH_SUFFIX "${_PLATFORM_PATH}")
find_library(sodium_LIBRARY_DEBUG libsodium.lib
HINTS ${sodium_DIR}
PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX}
)
find_library(sodium_LIBRARY_RELEASE libsodium.lib
HINTS ${sodium_DIR}
PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX}
)
if (NOT sodium_USE_STATIC_LIBS)
set(CMAKE_FIND_LIBRARY_SUFFIXES_BCK ${CMAKE_FIND_LIBRARY_SUFFIXES})
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
find_library(sodium_DLL_DEBUG libsodium
HINTS ${sodium_DIR}
PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX}
)
find_library(sodium_DLL_RELEASE libsodium
HINTS ${sodium_DIR}
PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX}
)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_BCK})
endif()
elseif(_GCC_COMPATIBLE)
if (sodium_USE_STATIC_LIBS) if (sodium_USE_STATIC_LIBS)
find_library(sodium_LIBRARY_DEBUG libsodium.a find_library(sodium_LIBRARY_DEBUG libsodium.a
HINTS ${sodium_DIR} HINTS ${sodium_DIR}
-25
View File
@@ -34,10 +34,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#ifndef _MSC_VER
#include <sys/param.h> #include <sys/param.h>
#endif
#if defined(__ANDROID__) #if defined(__ANDROID__)
#include <byteswap.h> #include <byteswap.h>
@@ -47,20 +44,6 @@
#include <endian.h> #include <endian.h>
#endif #endif
#if defined(_MSC_VER)
#include <stdlib.h>
static inline uint32_t rol32(uint32_t x, int r) {
static_assert(sizeof(uint32_t) == sizeof(unsigned int), "this code assumes 32-bit integers");
return _rotl(x, r);
}
static inline uint64_t rol64(uint64_t x, int r) {
return _rotl64(x, r);
}
#else
static inline uint32_t rol32(uint32_t x, int r) { static inline uint32_t rol32(uint32_t x, int r) {
return (x << (r & 31)) | (x >> (-r & 31)); return (x << (r & 31)) | (x >> (-r & 31));
} }
@@ -69,8 +52,6 @@ static inline uint64_t rol64(uint64_t x, int r) {
return (x << (r & 63)) | (x >> (-r & 63)); return (x << (r & 63)) | (x >> (-r & 63));
} }
#endif
static inline uint64_t hi_dword(uint64_t val) { static inline uint64_t hi_dword(uint64_t val) {
return val >> 32; return val >> 32;
} }
@@ -255,12 +236,6 @@ static inline void memcpy_swap64(void *dst, const void *src, size_t n) {
} }
} }
#ifdef _MSC_VER
# define LITTLE_ENDIAN 1234
# define BIG_ENDIAN 4321
# define BYTE_ORDER LITTLE_ENDIAN
#endif
#if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN) || !defined(BIG_ENDIAN) #if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN) || !defined(BIG_ENDIAN)
static_assert(false, "BYTE_ORDER is undefined. Perhaps, GNU extensions are not enabled"); static_assert(false, "BYTE_ORDER is undefined. Perhaps, GNU extensions are not enabled");
#endif #endif
-4
View File
@@ -40,10 +40,6 @@
#define OUT #define OUT
#endif #endif
#ifdef WINDOWS_PLATFORM
#pragma comment (lib, "Rpcrt4.lib")
#endif
namespace epee namespace epee
{ {
namespace string_tools namespace string_tools
-13
View File
@@ -1,16 +1,5 @@
#pragma once #pragma once
#if defined(_MSC_VER)
#define PUSH_WARNINGS __pragma(warning(push))
#define POP_WARNINGS __pragma(warning(pop))
#define DISABLE_VS_WARNINGS(w) __pragma(warning(disable: w))
#define DISABLE_GCC_WARNING(w)
#define DISABLE_CLANG_WARNING(w)
#define DISABLE_GCC_AND_CLANG_WARNING(w)
#else
#include <boost/preprocessor/stringize.hpp> #include <boost/preprocessor/stringize.hpp>
#define PUSH_WARNINGS _Pragma("GCC diagnostic push") #define PUSH_WARNINGS _Pragma("GCC diagnostic push")
@@ -26,5 +15,3 @@
#endif #endif
#define DISABLE_GCC_AND_CLANG_WARNING(w) _Pragma(BOOST_PP_STRINGIZE(GCC diagnostic ignored BOOST_PP_STRINGIZE(-W##w))) #define DISABLE_GCC_AND_CLANG_WARNING(w) _Pragma(BOOST_PP_STRINGIZE(GCC diagnostic ignored BOOST_PP_STRINGIZE(-W##w)))
#endif
-5
View File
@@ -38,13 +38,8 @@
#endif #endif
#include "memwipe.h" #include "memwipe.h"
#if defined(_MSC_VER)
#define SCARECROW \
__asm;
#else
#define SCARECROW \ #define SCARECROW \
__asm__ __volatile__("" : : "r"(ptr) : "memory"); __asm__ __volatile__("" : : "r"(ptr) : "memory");
#endif
#ifdef HAVE_MEMSET_S #ifdef HAVE_MEMSET_S
-4
View File
@@ -70,12 +70,8 @@ public:
scoped_message_writer(scoped_message_writer&& rhs) scoped_message_writer(scoped_message_writer&& rhs)
: m_flush(std::move(rhs.m_flush)) : m_flush(std::move(rhs.m_flush))
#if defined(_MSC_VER)
, m_oss(std::move(rhs.m_oss))
#else
// GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54316 // GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54316
, m_oss(rhs.m_oss.str(), std::ios_base::out | std::ios_base::ate) , m_oss(rhs.m_oss.str(), std::ios_base::out | std::ios_base::ate)
#endif
, m_color(std::move(rhs.m_color)) , m_color(std::move(rhs.m_color))
, m_log_level(std::move(rhs.m_log_level)) , m_log_level(std::move(rhs.m_log_level))
{ {
-6
View File
@@ -162,12 +162,6 @@ namespace cryptonote {
return (low + time_span - 1) / time_span; return (low + time_span - 1) / time_span;
} }
#if defined(_MSC_VER)
#ifdef max
#undef max
#endif
#endif
const difficulty_type max64bit(std::numeric_limits<std::uint64_t>::max()); const difficulty_type max64bit(std::numeric_limits<std::uint64_t>::max());
const boost::multiprecision::uint256_t max128bit(std::numeric_limits<boost::multiprecision::uint128_t>::max()); const boost::multiprecision::uint256_t max128bit(std::numeric_limits<boost::multiprecision::uint128_t>::max());
const boost::multiprecision::uint512_t max256bit(std::numeric_limits<boost::multiprecision::uint256_t>::max()); const boost::multiprecision::uint512_t max256bit(std::numeric_limits<boost::multiprecision::uint256_t>::max());
-27
View File
@@ -990,8 +990,6 @@ namespace tools
}; };
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
#if !defined(_MSC_VER)
template<typename TException, typename... TArgs> template<typename TException, typename... TArgs>
[[noreturn]] void throw_wallet_ex(std::string&& loc, const TArgs&... args) [[noreturn]] void throw_wallet_ex(std::string&& loc, const TArgs&... args)
{ {
@@ -999,31 +997,6 @@ namespace tools
LOG_PRINT_L0(e.to_string()); LOG_PRINT_L0(e.to_string());
throw e; throw e;
} }
#else
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
template<typename TException>
[[noreturn]] void throw_wallet_ex(std::string&& loc)
{
TException e(std::move(loc));
LOG_PRINT_L0(e.to_string());
throw e;
}
#define GEN_throw_wallet_ex(z, n, data) \
template<typename TException, BOOST_PP_ENUM_PARAMS(n, typename TArg)> \
[[noreturn]] void throw_wallet_ex(std::string&& loc, BOOST_PP_ENUM_BINARY_PARAMS(n, const TArg, &arg)) \
{ \
TException e(std::move(loc), BOOST_PP_ENUM_PARAMS(n, arg)); \
LOG_PRINT_L0(e.to_string()); \
throw e; \
}
BOOST_PP_REPEAT_FROM_TO(1, 6, GEN_throw_wallet_ex, ~)
#endif
} }
} }
-34
View File
@@ -43,40 +43,10 @@ namespace tools
bool serialize_obj_to_file(t_object& obj, const std::string& file_path) bool serialize_obj_to_file(t_object& obj, const std::string& file_path)
{ {
TRY_ENTRY(); TRY_ENTRY();
#if defined(_MSC_VER)
// Need to know HANDLE of file to call FlushFileBuffers
HANDLE data_file_handle = ::CreateFile(file_path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (INVALID_HANDLE_VALUE == data_file_handle)
return false;
int data_file_descriptor = _open_osfhandle((intptr_t)data_file_handle, 0);
if (-1 == data_file_descriptor)
{
::CloseHandle(data_file_handle);
return false;
}
const std::unique_ptr<FILE, tools::close_file> data_file_file{_fdopen(data_file_descriptor, "wb")};
if (nullptr == data_file_file)
{
// Call CloseHandle is not necessary
_close(data_file_descriptor);
return false;
}
// HACK: undocumented constructor, this code may not compile
std::ofstream data_file(data_file_file.get());
if (data_file.fail())
{
// Call CloseHandle and _close are not necessary
return false;
}
#else
std::ofstream data_file; std::ofstream data_file;
data_file.open(file_path , std::ios_base::binary | std::ios_base::out| std::ios::trunc); data_file.open(file_path , std::ios_base::binary | std::ios_base::out| std::ios::trunc);
if (data_file.fail()) if (data_file.fail())
return false; return false;
#endif
boost::archive::portable_binary_oarchive a(data_file); boost::archive::portable_binary_oarchive a(data_file);
a << obj; a << obj;
@@ -84,10 +54,6 @@ namespace tools
return false; return false;
data_file.flush(); data_file.flush();
#if defined(_MSC_VER)
// To make sure the file is fully stored on disk
::FlushFileBuffers(data_file_handle);
#endif
return true; return true;
CATCH_ENTRY_L0("serialize_obj_to_file", false); CATCH_ENTRY_L0("serialize_obj_to_file", false);
+3 -3
View File
@@ -267,11 +267,11 @@ int main(int argc, char *argv[]) {
CATCH_ENTRY_L0("main", 1); CATCH_ENTRY_L0("main", 1);
} }
#if defined(__x86_64__) || (defined(_MSC_VER) && defined(_WIN64)) #if defined(__x86_64__)
#include <emmintrin.h> #include <emmintrin.h>
#if defined(_MSC_VER) || defined(__MINGW32__) #if defined(__MINGW32__)
#include <intrin.h> #include <intrin.h>
#else #else
#include <wmmintrin.h> #include <wmmintrin.h>
@@ -281,7 +281,7 @@ int main(int argc, char *argv[]) {
static inline bool test_variant2_int_sqrt_sse(const uint64_t sqrt_input, const uint64_t correct_result) static inline bool test_variant2_int_sqrt_sse(const uint64_t sqrt_input, const uint64_t correct_result)
{ {
#if defined(__x86_64__) || (defined(_MSC_VER) && defined(_WIN64)) #if defined(__x86_64__)
uint64_t sqrt_result; uint64_t sqrt_result;
VARIANT2_INTEGER_MATH_SQRT_STEP_SSE2(); VARIANT2_INTEGER_MATH_SQRT_STEP_SSE2();
VARIANT2_INTEGER_MATH_SQRT_FIXUP(sqrt_result); VARIANT2_INTEGER_MATH_SQRT_FIXUP(sqrt_result);
-19
View File
@@ -106,28 +106,9 @@ inline void get(std::istream &input, std::vector<char> &res) {
} }
} }
#if !defined(_MSC_VER) || _MSC_VER >= 1800
template<typename T, typename... TT> template<typename T, typename... TT>
typename std::enable_if<(sizeof...(TT) > 0), void>::type typename std::enable_if<(sizeof...(TT) > 0), void>::type
get(std::istream &input, T &res, TT &... resres) { get(std::istream &input, T &res, TT &... resres) {
get(input, res); get(input, res);
get(input, resres...); get(input, resres...);
} }
#else
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
#define NESTED_GET(z, n, data) get(input, BOOST_PP_CAT(res, n));
#define GET(z, n, data) \
template<BOOST_PP_ENUM_PARAMS(n, typename T)> \
void get(std::istream &input, BOOST_PP_ENUM_BINARY_PARAMS(n, T, &res)) { \
BOOST_PP_REPEAT(n, NESTED_GET, ~) \
}
BOOST_PP_REPEAT_FROM_TO(2, 5, GET, ~)
#endif