Include <folly/portability/SysTime.h> rather than <sys/time.h>
authorChristopher Dykes <cdykes@fb.com>
Mon, 30 May 2016 23:05:07 +0000 (16:05 -0700)
committerFacebook Github Bot 6 <facebook-github-bot-6-bot@fb.com>
Mon, 30 May 2016 23:09:18 +0000 (16:09 -0700)
commit6ca321dc723345b81022178f5d0e67004b4f0cdf
tree7decedd4b5f77ec660de129dc758671302d9d9ce
parent792e823ba3636730a6a0afad367c16c2faea8ca2
Include <folly/portability/SysTime.h> rather than <sys/time.h>

Summary:
This changes includes of `<sys/time.h>` to `<folly/portability/SysTime.h>`.

The ultimate goal of all of this is to get HHVM compiling on Windows with MSVC 2015. At the moment there are no plans to support MCRouter, Squangle, or AFDT under Windows. There are also no current plans to support MinGW or Cygwin.

Now, on to the headers themselves. There are three primary kinds of portability headers.

  - Replacement headers. These are headers such as `<sys/time.h>` that MSVC simply does not have. These headers should always be included instead of the headers they are replacing.
  - Additive headers. These are headers, such as `<time.h>` that MSVC has, but are either missing functions, or has the functions but under a different name. The portability headers for these only needs to be included instead of the original header if you are using a function that MSVC does not have. The reason for this is that forcing the use of the portability header for `<stdlib.h>` just because MSVC doesn't have `mkdtemp` and `realpath` would just be messy.
  - Utility headers. These are portability headers, such as `Memory.h` that exist to provide a portable interface to various things, in this case the allocation and freeing of aligned memory. They are not implementing any existing API, and all contents are in the `folly` namespace.

The API's implemented in the first and second types of headers are intended as drop-in replacements for the Linux versions, however they only implement the functions and features that are actually needed, and are not intended as feature-complete replacements. They are not intended for use outside of Facebook projects. Any API's expecting text input expect them to be in the same encoding as the Posix API's define, in most cases that means UTF-8. Anywhere in the portability headers that fails to account for this is a bug, and should be pointed out in the diff (if it's still in review), or else by filing a task detailing the issue and assigning it to me.

For all headers, if there is a mechanism in C++11, or else in Folly itself, that allows the same functionality, that mechanism should be used instead of adding a function to the portability headers.

Reviewed By: swtaarrs, yfeldblum

Differential Revision: D3095643

fbshipit-source-id: 3a5c0029f95b03ea320725df88e14a67ca38a445
folly/Random.cpp
folly/experimental/EventCount.h
folly/test/AtomicHashMapTest.cpp
folly/test/MPMCQueueTest.cpp