| /********************************************************************** |
| // @@@ START COPYRIGHT @@@ |
| // |
| // Licensed to the Apache Software Foundation (ASF) under one |
| // or more contributor license agreements. See the NOTICE file |
| // distributed with this work for additional information |
| // regarding copyright ownership. The ASF licenses this file |
| // to you under the Apache License, Version 2.0 (the |
| // "License"); you may not use this file except in compliance |
| // with the License. You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, |
| // software distributed under the License is distributed on an |
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| // KIND, either express or implied. See the License for the |
| // specific language governing permissions and limitations |
| // under the License. |
| // |
| // @@@ END COPYRIGHT @@@ |
| // |
| **********************************************************************/ |
| |
| // This file is used by WIN32 only to getTimeOfDay |
| |
| #ifndef TIMEVALH |
| #define TIMEVALH |
| |
| #if defined(_WINDOWS) |
| #include <winsock.h> |
| #include <windows.h> |
| #include <time.h> |
| |
| #define EPOCHFILETIME (116444736000000000i64) |
| |
| |
| //struct timeval { |
| // long tv_sec; /* seconds */ |
| //long tv_usec; /* microseconds */ |
| //}; |
| |
| struct timezone { |
| int tz_minuteswest; /* minutes W of Greenwich */ |
| int tz_dsttime; /* type of dst correction */ |
| }; |
| |
| __inline int gettimeofday(struct timeval *tv, struct timezone *tz) |
| { |
| FILETIME ft; |
| LARGE_INTEGER li; |
| __int64 t; |
| static int tzflag; |
| |
| if (tv) |
| { |
| GetSystemTimeAsFileTime(&ft); |
| li.LowPart = ft.dwLowDateTime; |
| li.HighPart = ft.dwHighDateTime; |
| t = li.QuadPart; /* In 100-nanosecond intervals */ |
| t -= EPOCHFILETIME; /* Offset to the Epoch time */ |
| t /= 10; /* In microseconds */ |
| tv->tv_sec = (long)(t / 1000000); |
| tv->tv_usec = (long)(t % 1000000); |
| } |
| |
| if (tz) |
| { |
| if (!tzflag) |
| { |
| _tzset(); |
| tzflag++; |
| } |
| tz->tz_minuteswest = _timezone / 60; |
| tz->tz_dsttime = _daylight; |
| } |
| |
| return 0; |
| } |
| |
| #endif /* _WIN32 */ |
| #endif /* TIMEVALH */ |