| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- /*
- * Copyright (c) 2014, Oculus VR, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- */
- #if defined(_WIN32) && !defined(__GNUC__) &&!defined(__GCCXML__)
- #include "gettimeofday.h"
- // From http://www.openasthra.com/c-tidbits/gettimeofday-function-for-windows/
- #include "WindowsIncludes.h"
- #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
- #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
- #else
- #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
- #endif
- int gettimeofday(struct timeval *tv, struct timezone *tz)
- {
- #if defined(WINDOWS_PHONE_8) || defined(WINDOWS_STORE_RT)
- // _tzset not supported
- (void) tv;
- (void) tz;
- #else
- FILETIME ft;
- unsigned __int64 tmpres = 0;
- static int tzflag;
- if (NULL != tv)
- {
- GetSystemTimeAsFileTime(&ft);
- tmpres |= ft.dwHighDateTime;
- tmpres <<= 32;
- tmpres |= ft.dwLowDateTime;
- /*converting file time to unix epoch*/
- tmpres /= 10; /*convert into microseconds*/
- tmpres -= DELTA_EPOCH_IN_MICROSECS;
- tv->tv_sec = (long)(tmpres / 1000000UL);
- tv->tv_usec = (long)(tmpres % 1000000UL);
- }
- if (NULL != tz)
- {
- if (!tzflag)
- {
- _tzset();
- tzflag++;
- }
- tz->tz_minuteswest = _timezone / 60;
- tz->tz_dsttime = _daylight;
- }
- #endif
- return 0;
- }
- #endif
|