From 43cf8c0ba1c151048679d0cfbeb6d82dab757a64 Mon Sep 17 00:00:00 2001 From: Laptop Windows Date: Wed, 21 Feb 2024 20:24:00 -0500 Subject: [PATCH] windows --- CMakeLists.txt | 2 ++ include/blt/math/math.h | 6 +++++- include/blt/std/memory_util.h | 16 ++++++++++++---- include/blt/std/system.h | 4 ++++ include/blt/std/types.h | 1 + include/blt/std/vector.h | 1 + libraries/parallel-hashmap | 2 +- src/blt/std/system.cpp | 9 +++++++-- 8 files changed, 33 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a59d4d3..180cd20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,7 +88,9 @@ add_library(${BLT_TARGET} ${STD_FILES} ${PROFILING_FILES} ${FS_FILES} ${PARSE_FI if(${ZLIB_FOUND}) target_link_libraries(${BLT_TARGET} PUBLIC ZLIB::ZLIB) endif() +if (!MSVC) target_link_libraries(${BLT_TARGET} PUBLIC stdc++fs) +endif() target_include_directories(${BLT_TARGET} PUBLIC include/) target_include_directories(${BLT_TARGET} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/config/) diff --git a/include/blt/math/math.h b/include/blt/math/math.h index 9e0b78d..22d59e2 100644 --- a/include/blt/math/math.h +++ b/include/blt/math/math.h @@ -31,8 +31,10 @@ namespace blt return ((seed * (seed * seed * 15731 + 789221) + 1376312589) & 0x7fffffff); } +#ifdef __GCC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstrict-aliasing" +#endif /** * fast inverse sqrt @@ -51,8 +53,10 @@ namespace blt return y; } +#ifdef __GCC #pragma GCC diagnostic pop - +#endif + static inline constexpr double pow(int b, int p) { diff --git a/include/blt/std/memory_util.h b/include/blt/std/memory_util.h index 7802e77..c39d26e 100644 --- a/include/blt/std/memory_util.h +++ b/include/blt/std/memory_util.h @@ -27,11 +27,19 @@ #if defined(__clang__) || defined(__llvm__) || defined(__GNUC__) || defined(__GNUG__) - #include + #if defined(__GNUC__) || defined(__GNUG__) + #include + + #define SWAP16(val) bswap_16(val) + #define SWAP32(val) bswap_32(val) + #define SWAP64(val) bswap_64(val) + #else + #define SWAP16(val) __builtin_bswap16(val) + #define SWAP32(val) __builtin_bswap32(val) + #define SWAP64(val) __builtin_bswap64(val) + #endif + - #define SWAP16(val) bswap_16(val) - #define SWAP32(val) bswap_32(val) - #define SWAP64(val) bswap_64(val) #if __cplusplus >= 202002L #include diff --git a/include/blt/std/system.h b/include/blt/std/system.h index 471220a..fbc48bc 100644 --- a/include/blt/std/system.h +++ b/include/blt/std/system.h @@ -144,6 +144,10 @@ namespace blt::system // number of dirty pages (0) std::uint64_t dt; }; + +#ifdef _MSC_VER + using suseconds_t = std::size_t; +#endif struct timeval { time_t tv_sec; /* Seconds */ diff --git a/include/blt/std/types.h b/include/blt/std/types.h index 34dfa99..1bbc4a1 100644 --- a/include/blt/std/types.h +++ b/include/blt/std/types.h @@ -20,6 +20,7 @@ #define BLT_TYPES_H #include +#include #ifndef NO_BLT_NAMESPACE_ON_TYPES namespace blt diff --git a/include/blt/std/vector.h b/include/blt/std/vector.h index c4a6fb9..a91dd1e 100644 --- a/include/blt/std/vector.h +++ b/include/blt/std/vector.h @@ -22,6 +22,7 @@ #include #include #include "ranges.h" +#include namespace blt { diff --git a/libraries/parallel-hashmap b/libraries/parallel-hashmap index 401552d..67c2461 160000 --- a/libraries/parallel-hashmap +++ b/libraries/parallel-hashmap @@ -1 +1 @@ -Subproject commit 401552da80b0971f818e648621260720ad40934e +Subproject commit 67c24619e4f5ab2097b74cc397732c17a25d6944 diff --git a/src/blt/std/system.cpp b/src/blt/std/system.cpp index a251a6d..060894a 100644 --- a/src/blt/std/system.cpp +++ b/src/blt/std/system.cpp @@ -6,10 +6,15 @@ #include #include +#ifndef _MSC_VER #include /* for struct timeval */ -#include /* for CLK_TCK */ - #include +#else + #include + #define RUSAGE_SELF 1 +#endif + +#include /* for CLK_TCK */ #include #ifndef WIN32