From 439d6b1c2a6da5cb6adc4c4dfc555af235722396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 19 Sep 2018 13:52:05 +0300 Subject: [PATCH] Include sys/time.h for cycleclock.h when building on MinGW (#680) When building for ARM, there is a fallback codepath that uses gettimeofday, which requires sys/time.h. The Windows SDK doesn't have this header, but MinGW does have it. Thus, this fixes building for Windows on ARM with MinGW headers/libraries, while Windows on ARM with the Windows SDK still is broken. --- src/cycleclock.h | 2 +- src/internal_macros.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cycleclock.h b/src/cycleclock.h index 00d5764167..f5e37b011b 100644 --- a/src/cycleclock.h +++ b/src/cycleclock.h @@ -41,7 +41,7 @@ extern "C" uint64_t __rdtsc(); #pragma intrinsic(__rdtsc) #endif -#ifndef BENCHMARK_OS_WINDOWS +#if !defined(BENCHMARK_OS_WINDOWS) || defined(BENCHMARK_OS_MINGW) #include #include #endif diff --git a/src/internal_macros.h b/src/internal_macros.h index 32089e69f6..5dbf4fd275 100644 --- a/src/internal_macros.h +++ b/src/internal_macros.h @@ -40,6 +40,9 @@ #define BENCHMARK_OS_CYGWIN 1 #elif defined(_WIN32) #define BENCHMARK_OS_WINDOWS 1 + #if defined(__MINGW32__) + #define BENCHMARK_OS_MINGW 1 + #endif #elif defined(__APPLE__) #define BENCHMARK_OS_APPLE 1 #include "TargetConditionals.h"