diff options
author | Evan Martin <martine@danga.com> | 2011-05-24 16:55:39 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2011-05-24 16:55:39 (GMT) |
commit | 8f36cec4bd63d774f87394076eeac6adc398b6ef (patch) | |
tree | 0b8916c7b95816cac635384456d0511b3e6b1391 /src/util.cc | |
parent | 9227b6d0ddd8ae0171aa466ceda797a948441740 (diff) | |
download | Ninja-8f36cec4bd63d774f87394076eeac6adc398b6ef.zip Ninja-8f36cec4bd63d774f87394076eeac6adc398b6ef.tar.gz Ninja-8f36cec4bd63d774f87394076eeac6adc398b6ef.tar.bz2 |
move GetTimeMillis to util
Diffstat (limited to 'src/util.cc')
-rw-r--r-- | src/util.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/util.cc b/src/util.cc index ff6d18e..14b3379 100644 --- a/src/util.cc +++ b/src/util.cc @@ -14,6 +14,10 @@ #include "util.h" +#ifdef _WIN32 +#include <windows.h> +#endif + #include <errno.h> #include <stdarg.h> #include <stdio.h> @@ -21,6 +25,7 @@ #include <string.h> #include <sys/stat.h> #include <sys/types.h> +#include <sys/time.h> #include <vector> @@ -173,3 +178,14 @@ int ReadFile(const string& path, string* contents, string* err) { fclose(f); return 0; } + +int64_t GetTimeMillis() { +#ifdef _WIN32 + // GetTickCount64 is only available on Vista or later. + return GetTickCount(); +#else + timeval now; + gettimeofday(&now, NULL); + return ((int64_t)now.tv_sec * 1000) + (now.tv_usec / 1000); +#endif +} |