google/benchmark — pull request #29 by pleroy (2014-06-07 10:11:46+00:00)
Title: Port to Windows 7/Visual Studio 2013

Apologies for the size of this pull request but it seems hard to split it in a meaningful way.

In porting the benchmark library I have tried to follow the model used by `glog`, and I have lifted some code from there. Here is an overview of the changes:

1. Add a subdirectory `msvc/` containing the MS project and solution files. There is one project for the library (`google-benchmark`) and one project for the tests (`google-benchmark-test`). This stuff is just humongous blobs of automatically-generated XML, not much to review.
1. Change `.gitignore` and `.gitattributes` to properly handle the MSVC artifacts.
1. Add a `src/port.h` file (and the corresponding `src/port.cc`) to factor out the differences between Windows and the various Unix-ish OSes. I lifted this file from `glog` and did the necessary adjustments. In particular, it defines a bunch of `HAVE_` symbols that act as a poor man's `config.h`. `src/port.h` must be included early in every source file that has OS dependencies, as among other things it defines the all-important symbols `OS_WINDOWS` and `COMPILER_MSVC`.
1. Change a bunch of includes to make them depend on the `HAVE_` symbols.
1. Implement `MyCPUUsage` for Windows. No `ChildrenCPUUsage` yet.
1. Add a `pthread` library for Windows in `src/windows/pthread.{h,cc}`. I got this library from http://locklessinc.com/articles/pthreads_on_windows/. I did minimal changes to make it compile (mostly fixing casts) and I separated it into `.h` and `.cc` files instead of having everything in the `.h` file (which caused linker errors). This library is distributed under a 3-clause BSD licence so I am assuming that using it is not problematic.
1. Other than porting, I made two significant changes to the code of the benchmark library:
* In `BenchmarkFamilies::RemoveBenchmark` I commented out some code which was changing a vector while iterating over it.
* In `State::FinishInterval` I turned a `CHECK` into a warning because the wall time clock has poor accuracy on Windows 7.