Skip to content

Commit

Permalink
fix incompatibility with Windows macro, fixes #2450, thanks @scuzqy
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 718313441
  • Loading branch information
jan-wassenberg authored and copybara-github committed Jan 22, 2025
1 parent b5dd1c4 commit 70c7d32
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
6 changes: 6 additions & 0 deletions hwy/contrib/sort/vqsort.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@
#if VQSORT_SECURE_SEED == 1
#include <sys/random.h>
#elif VQSORT_SECURE_SEED == 2
#ifndef NOMINMAX
#define NOMINMAX
#endif // NOMINMAX
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif // WIN32_LEAN_AND_MEAN
#include <windows.h>
#if HWY_COMPILER_MSVC || HWY_COMPILER_CLANGCL
#pragma comment(lib, "advapi32.lib")
Expand Down
6 changes: 6 additions & 0 deletions hwy/contrib/thread_pool/futex.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ int __ulock_wake(uint32_t op, void* address, uint64_t zero);

#elif HWY_OS_WIN && !defined(HWY_DISABLE_FUTEX)
// WakeByAddressAll requires Windows 8, so add an opt-out.
#ifndef NOMINMAX
#define NOMINMAX
#endif // NOMINMAX
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif // WIN32_LEAN_AND_MEAN
#include <windows.h>
#pragma comment(lib, "synchronization.lib")

Expand Down
10 changes: 8 additions & 2 deletions hwy/tests/memory_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@
// detected. Must come before Highway headers.
#include "hwy/base.h"
#include "hwy/tests/test_util.h"
#if defined(_WIN32) || defined(_WIN64)
#if HWY_OS_WIN
#ifndef NOMINMAX
#define NOMINMAX
#endif // NOMINMAX
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif // WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#endif // HWY_OS_WIN

#undef HWY_TARGET_INCLUDE
#define HWY_TARGET_INCLUDE "tests/memory_test.cc"
Expand Down
3 changes: 3 additions & 0 deletions hwy/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
#ifndef NOMINMAX
#define NOMINMAX
#endif // NOMINMAX
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif // WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif

Expand Down

0 comments on commit 70c7d32

Please sign in to comment.