| 1 | 
 /* | 
 
 
 
 
 
 | 2 | 
    Copyright (c) 2011-2016  mingw-w64 project | 
 
 
 
 
 
 | 3 | 
  | 
 
 
 
 
 
 | 4 | 
    Permission is hereby granted, free of charge, to any person obtaining a | 
 
 
 
 
 
 | 5 | 
    copy of this software and associated documentation files (the "Software"), | 
 
 
 
 
 
 | 6 | 
    to deal in the Software without restriction, including without limitation | 
 
 
 
 
 
 | 7 | 
    the rights to use, copy, modify, merge, publish, distribute, sublicense, | 
 
 
 
 
 
 | 8 | 
    and/or sell copies of the Software, and to permit persons to whom the | 
 
 
 
 
 
 | 9 | 
    Software is furnished to do so, subject to the following conditions: | 
 
 
 
 
 
 | 10 | 
  | 
 
 
 
 
 
 | 11 | 
    The above copyright notice and this permission notice shall be included in | 
 
 
 
 
 
 | 12 | 
    all copies or substantial portions of the Software. | 
 
 
 
 
 
 | 13 | 
  | 
 
 
 
 
 
 | 14 | 
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
 
 
 
 
 
 | 15 | 
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
 
 
 
 
 
 | 16 | 
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 
 
 
 
 
 
 | 17 | 
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
 
 
 
 
 
 | 18 | 
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | 
 
 
 
 
 
 | 19 | 
    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 
 
 
 
 
 
 | 20 | 
    DEALINGS IN THE SOFTWARE. | 
 
 
 
 
 
 | 21 | 
 */ | 
 
 
 
 
 
 | 22 | 
  | 
 
 
 
 
 
 | 23 | 
 #include <sys/timeb.h> | 
 
 
 
 
 
 | 24 | 
  | 
 
 
 
 
 
 | 25 | 
 #ifndef WIN_PTHREADS_TIME_H | 
 
 
 
 
 
 | 26 | 
 #define WIN_PTHREADS_TIME_H | 
 
 
 
 
 
 | 27 | 
  | 
 
 
 
 
 
 | 28 | 
 /* Posix timers are supported */ | 
 
 
 
 
 
 | 29 | 
 #ifndef _POSIX_TIMERS | 
 
 
 
 
 
 | 30 | 
 #define _POSIX_TIMERS           200809L | 
 
 
 
 
 
 | 31 | 
 #endif | 
 
 
 
 
 
 | 32 | 
  | 
 
 
 
 
 
 | 33 | 
 /* Monotonic clocks are available.  */ | 
 
 
 
 
 
 | 34 | 
 #ifndef _POSIX_MONOTONIC_CLOCK | 
 
 
 
 
 
 | 35 | 
 #define _POSIX_MONOTONIC_CLOCK  200809L | 
 
 
 
 
 
 | 36 | 
 #endif | 
 
 
 
 
 
 | 37 | 
  | 
 
 
 
 
 
 | 38 | 
 /* CPU-time clocks are available.  */ | 
 
 
 
 
 
 | 39 | 
 #ifndef _POSIX_CPUTIME | 
 
 
 
 
 
 | 40 | 
 #define _POSIX_CPUTIME          200809L | 
 
 
 
 
 
 | 41 | 
 #endif | 
 
 
 
 
 
 | 42 | 
  | 
 
 
 
 
 
 | 43 | 
 /* Clock support in threads are available.  */ | 
 
 
 
 
 
 | 44 | 
 #ifndef _POSIX_THREAD_CPUTIME | 
 
 
 
 
 
 | 45 | 
 #define _POSIX_THREAD_CPUTIME   200809L | 
 
 
 
 
 
 | 46 | 
 #endif | 
 
 
 
 
 
 | 47 | 
  | 
 
 
 
 
 
 | 48 | 
 #ifndef __clockid_t_defined | 
 
 
 
 
 
 | 49 | 
 typedef int clockid_t; | 
 
 
 
 
 
 | 50 | 
 #define __clockid_t_defined 1 | 
 
 
 
 
 
 | 51 | 
 #endif  /* __clockid_t_defined */ | 
 
 
 
 
 
 | 52 | 
  | 
 
 
 
 
 
 | 53 | 
 #ifndef TIMER_ABSTIME | 
 
 
 
 
 
 | 54 | 
 #define TIMER_ABSTIME   1 | 
 
 
 
 
 
 | 55 | 
 #endif | 
 
 
 
 
 
 | 56 | 
  | 
 
 
 
 
 
 | 57 | 
 #ifndef CLOCK_REALTIME | 
 
 
 
 
 
 | 58 | 
 #define CLOCK_REALTIME              0 | 
 
 
 
 
 
 | 59 | 
 #endif | 
 
 
 
 
 
 | 60 | 
  | 
 
 
 
 
 
 | 61 | 
 #ifndef CLOCK_MONOTONIC | 
 
 
 
 
 
 | 62 | 
 #define CLOCK_MONOTONIC             1 | 
 
 
 
 
 
 | 63 | 
 #endif | 
 
 
 
 
 
 | 64 | 
  | 
 
 
 
 
 
 | 65 | 
 #ifndef CLOCK_PROCESS_CPUTIME_ID | 
 
 
 
 
 
 | 66 | 
 #define CLOCK_PROCESS_CPUTIME_ID    2 | 
 
 
 
 
 
 | 67 | 
 #endif | 
 
 
 
 
 
 | 68 | 
  | 
 
 
 
 
 
 | 69 | 
 #ifndef CLOCK_THREAD_CPUTIME_ID | 
 
 
 
 
 
 | 70 | 
 #define CLOCK_THREAD_CPUTIME_ID     3 | 
 
 
 
 
 
 | 71 | 
 #endif | 
 
 
 
 
 
 | 72 | 
  | 
 
 
 
 
 
 | 73 | 
 #ifndef CLOCK_REALTIME_COARSE | 
 
 
 
 
 
 | 74 | 
 #define CLOCK_REALTIME_COARSE       4 | 
 
 
 
 
 
 | 75 | 
 #endif | 
 
 
 
 
 
 | 76 | 
  | 
 
 
 
 
 
 | 77 | 
 #ifdef __cplusplus | 
 
 
 
 
 
 | 78 | 
 extern "C" { | 
 
 
 
 
 
 | 79 | 
 #endif | 
 
 
 
 
 
 | 80 | 
  | 
 
 
 
 
 
 | 81 | 
 /* Make sure we provide default for WINPTHREAD_API, if not defined.  */ | 
 
 
 
 
 
 | 82 | 
 #pragma push_macro("WINPTHREAD_API") | 
 
 
 
 
 
 | 83 | 
 #ifndef WINPTHREAD_API | 
 
 
 
 
 
 | 84 | 
 #define WINPTHREAD_API | 
 
 
 
 
 
 | 85 | 
 #endif | 
 
 
 
 
 
 | 86 | 
  | 
 
 
 
 
 
 | 87 | 
 /* These should really be dllimport'ed if using winpthread dll */ | 
 
 
 
 
 
 | 88 | 
 int __cdecl WINPTHREAD_API nanosleep(const struct timespec *request, struct timespec *remain); | 
 
 
 
 
 
 | 89 | 
  | 
 
 
 
 
 
 | 90 | 
 int __cdecl WINPTHREAD_API clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *request, struct timespec *remain); | 
 
 
 
 
 
 | 91 | 
 int __cdecl WINPTHREAD_API clock_getres(clockid_t clock_id, struct timespec *res); | 
 
 
 
 
 
 | 92 | 
 int __cdecl WINPTHREAD_API clock_gettime(clockid_t clock_id, struct timespec *tp); | 
 
 
 
 
 
 | 93 | 
 int __cdecl WINPTHREAD_API clock_settime(clockid_t clock_id, const struct timespec *tp); | 
 
 
 
 
 
 | 94 | 
  | 
 
 
 
 
 
 | 95 | 
 #pragma pop_macro("WINPTHREAD_API") | 
 
 
 
 
 
 | 96 | 
  | 
 
 
 
 
 
 | 97 | 
 #ifdef __cplusplus | 
 
 
 
 
 
 | 98 | 
 } | 
 
 
 
 
 
 | 99 | 
 #endif | 
 
 
 
 
 
 | 100 | 
  | 
 
 
 
 
 
 | 101 | 
 #endif /* WIN_PTHREADS_TIME_H */ | 
 
 
 
 
 
 | 102 | 
  |