| /* A part of the Native C Library for Windows NT |
| Copyright 2007-2015 PC GO Ld. |
| |
| This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| */ |
| |
| #ifndef _SYS_TIME_H |
| #define _SYS_TIME_H |
| |
| #include <time.h> |
| |
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
| |
| #ifndef _TIMEVAL_DEFINED |
| #define _TIMEVAL_DEFINED |
| struct timeval { |
| long tv_sec; |
| long tv_usec; |
| }; |
| #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) |
| #define timercmp(tvp, uvp, cmp) \ |
| (((tvp)->tv_sec != (uvp)->tv_sec) ? \ |
| ((tvp)->tv_sec cmp (uvp)->tv_sec) : \ |
| ((tvp)->tv_usec cmp (uvp)->tv_usec)) |
| #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 |
| #endif /* _TIMEVAL_DEFINED */ |
| |
| /* Provided for compatibility with code that assumes that |
| the presence of gettimeofday function implies a definition |
| of struct timezone. */ |
| struct timezone { |
| int tz_minuteswest; /* of Greenwich */ |
| int tz_dsttime; /* type of dst correction to apply */ |
| }; |
| |
| /* |
| Implementation as per: |
| The Open Group Base Specifications, Issue 6 |
| IEEE Std 1003.1, 2004 Edition |
| |
| The timezone pointer arg is ignored. Errors are ignored. |
| */ |
| int __cdecl __MINGW_NOTHROW gettimeofday(struct timeval *__restrict__, struct timezone *__restrict__); |
| int __cdecl __MINGW_NOTHROW settimeofday(const struct timeval *__restrict__, const struct timezone *__restrict__); |
| |
| int __cdecl __MINGW_NOTHROW utimes(const char *, const struct timeval *); |
| |
| |
| #if 0 |
| #ifndef _WINNT_H |
| typedef struct _LARGE_INTEGER LARGE_INTEGER; |
| #endif |
| void __hurdred_nanoseconds_since_1601_to_timeval(const LARGE_INTEGER *, struct timeval *); |
| void __timeval_to_hurdred_nanoseconds_since_1601(const struct timeval *, LARGE_INTEGER *); |
| #else |
| #define __hurdred_nanoseconds_since_1601_to_timeval(li, tv) \ |
| do { \ |
| unsigned long int _t; \ |
| RtlTimeToSecondsSince1970((li), &_t); \ |
| (tv)->tv_sec = _t; \ |
| (tv)->tv_usec = ((li)->QuadPart / 10) % 1000000; \ |
| } while(0) |
| #define __timeval_to_hurdred_nanoseconds_since_1601(tv, li) \ |
| do { \ |
| (li)->QuadPart = (tv)->tv_sec * 1000000ULL; \ |
| (li)->QuadPart += (tv)->tv_usec; \ |
| (li)->QuadPart += 11644473600000000ULL; \ |
| (li)->QuadPart *= 10; \ |
| } while(0) |
| #endif |
| |
| #define __hurdred_nanoseconds_since_1601_to_timespec(li, ts) \ |
| do { \ |
| unsigned long int _t; \ |
| RtlTimeToSecondsSince1970((li), &_t); \ |
| (ts)->tv_sec = _t; \ |
| (ts)->tv_nsec = ((li)->QuadPart % 10000000) * 100; \ |
| } while(0) |
| #define __timespec_to_hurdred_nanoseconds_since_1601(ts, li) \ |
| do { \ |
| (li)->QuadPart = (ts)->tv_nsec / 100; \ |
| (li)->QuadPart += (ts)->tv_sec * 10000000ULL; \ |
| (li)->QuadPart += 11644473600000000ULL * 10; \ |
| } while(0) |
| |
| |
| #ifdef __cplusplus |
| } |
| #endif |
| |
| #endif |