From 2994f66d345fa09f1870a46f37de8b613f4f0b68 Mon Sep 17 00:00:00 2001 From: Arkadiy Vertleyb Date: Mon, 13 Jun 2022 15:38:12 -0400 Subject: [PATCH] Fixing build/unit test issues in msvc/win32 --- .github/workflows/cpp.yml | 11 +++++++---- cpp/src/arrow/util/bit_util.h | 14 ++++++++++---- cpp/src/arrow/util/io_util.cc | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index 82e99160c3d..6eb2213c93f 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -192,12 +192,15 @@ jobs: strategy: fail-fast: false matrix: - os: - - windows-2019 include: - os: windows-2019 - name: Windows 2019 + name: Windows 2019 x64 generator: Visual Studio 16 2019 + platform: x64 + - os: windows-2019 + name: Windows 2019 Win32 + generator: Visual Studio 16 2019 + platform: Win32 env: ARROW_BOOST_USE_SHARED: OFF ARROW_BUILD_BENCHMARKS: ON @@ -222,7 +225,7 @@ jobs: ARROW_WITH_ZLIB: ON ARROW_WITH_ZSTD: ON BOOST_SOURCE: BUNDLED - CMAKE_ARGS: '-A x64 -DOPENSSL_ROOT_DIR=C:\Program Files\OpenSSL-Win64' + CMAKE_ARGS: '-A ${{ matrix.platform }} -DOPENSSL_ROOT_DIR=C:\Program Files\OpenSSL-Win64' CMAKE_GENERATOR: ${{ matrix.generator }} CMAKE_INSTALL_LIBDIR: bin CMAKE_INSTALL_PREFIX: /usr diff --git a/cpp/src/arrow/util/bit_util.h b/cpp/src/arrow/util/bit_util.h index 8583e10b226..4a3cc9679dc 100644 --- a/cpp/src/arrow/util/bit_util.h +++ b/cpp/src/arrow/util/bit_util.h @@ -67,7 +67,13 @@ static constexpr uint8_t kBytePopcount[] = { 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8}; -static inline uint64_t PopCount(uint64_t bitmap) { return ARROW_POPCOUNT64(bitmap); } +static inline uint64_t PopCount(uint64_t bitmap) { +#if defined(_MSC_VER) && !defined(_M_AMD64) && !defined(_M_X64) + return ARROW_POPCOUNT32((bitmap >> 32) & UINT32_MAX) + ARROW_POPCOUNT32(bitmap & UINT32_MAX); +#else + return ARROW_POPCOUNT64(bitmap); +#endif +} static inline uint32_t PopCount(uint32_t bitmap) { return ARROW_POPCOUNT32(bitmap); } // @@ -199,7 +205,7 @@ static inline int CountLeadingZeros(uint64_t value) { #if defined(__clang__) || defined(__GNUC__) if (value == 0) return 64; return static_cast(__builtin_clzll(value)); -#elif defined(_MSC_VER) +#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_X64)) unsigned long index; // NOLINT if (_BitScanReverse64(&index, value)) { // NOLINT return 63 - static_cast(index); @@ -245,7 +251,7 @@ static inline int CountTrailingZeros(uint64_t value) { #if defined(__clang__) || defined(__GNUC__) if (value == 0) return 64; return static_cast(__builtin_ctzll(value)); -#elif defined(_MSC_VER) +#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_X64)) unsigned long index; // NOLINT if (_BitScanForward64(&index, value)) { return static_cast(index); @@ -255,7 +261,7 @@ static inline int CountTrailingZeros(uint64_t value) { #else int bitpos = 0; if (value) { - while (value & 1 == 0) { + while ((value & 1) == 0) { value >>= 1; ++bitpos; } diff --git a/cpp/src/arrow/util/io_util.cc b/cpp/src/arrow/util/io_util.cc index 8d393d733dc..a290a3ac7ab 100644 --- a/cpp/src/arrow/util/io_util.cc +++ b/cpp/src/arrow/util/io_util.cc @@ -1448,7 +1448,7 @@ Status MemoryAdviseWillNeed(const std::vector& regions) { PrefetchEntry(const MemoryRegion& region) // NOLINT runtime/explicit : VirtualAddress(region.addr), NumberOfBytes(region.size) {} }; - using PrefetchVirtualMemoryFunc = BOOL (*)(HANDLE, ULONG_PTR, PrefetchEntry*, ULONG); + using PrefetchVirtualMemoryFunc = BOOL (__stdcall *)(HANDLE, ULONG_PTR, PrefetchEntry*, ULONG); static const auto prefetch_virtual_memory = reinterpret_cast( GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "PrefetchVirtualMemory")); if (prefetch_virtual_memory != nullptr) {