Commit cf8a8e02 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

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
parent f1450856
......@@ -20,10 +20,8 @@
#include <cstdint>
#include <Windows.h>
extern "C" {
int gettimeofday(timeval* tv, timezone*) {
int gettimeofday(timeval* tv, struct timezone*) {
constexpr auto posixWinFtOffset = 116444736000000000ULL;
if (tv) {
......
......@@ -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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment