From cf8a8e02cbc96a06cf4290d03f3e5012610f128d Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Sat, 24 Jun 2017 17:00:32 -0700 Subject: [PATCH] Explicitly specify that timezone is a struct Summary: In the parameter declarations for the `gettimeofday` portability header implementation. More details on exactly why can be found in the newly added comment on the function. Reviewed By: yfeldblum Differential Revision: D5281301 fbshipit-source-id: 1b246adc7743b5470201e452c008418429f7f142 --- folly/portability/SysTime.cpp | 4 +--- folly/portability/SysTime.h | 10 +++++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/folly/portability/SysTime.cpp b/folly/portability/SysTime.cpp index 48b343f4..c3a965f2 100644 --- a/folly/portability/SysTime.cpp +++ b/folly/portability/SysTime.cpp @@ -20,10 +20,8 @@ #include -#include - extern "C" { -int gettimeofday(timeval* tv, timezone*) { +int gettimeofday(timeval* tv, struct timezone*) { constexpr auto posixWinFtOffset = 116444736000000000ULL; if (tv) { diff --git a/folly/portability/SysTime.h b/folly/portability/SysTime.h index ef0293e9..2b66dbdd 100755 --- a/folly/portability/SysTime.h +++ b/folly/portability/SysTime.h @@ -27,7 +27,15 @@ struct timezone { }; extern "C" { -int gettimeofday(timeval* tv, timezone*); +// Note that this needs to explicitly be `struct timezone` due to the fact that +// the python 3 headers `#define timezone _timezone` on Windows. `_timezone` is +// a global field that contains information on the current timezone. By +// explicitly specifying that this is a `struct`, we ensure that it's treated as +// a type, regardless of what name that type actually is :) +// Note that this will break if `gettimeofday` ever becomes declared as anything +// other than `extern "C"`, as the mangled name would be dependent on whether +// python had been included before this header. +int gettimeofday(timeval* tv, struct timezone*); void timeradd(timeval* a, timeval* b, timeval* res); void timersub(timeval* a, timeval* b, timeval* res); } -- 2.34.1