]>
sourceware.org Git - newlib-cygwin.git/blob - winsup/cygwin/hires.h
1 /* hires.h: Definitions for hires clock calculations
3 This file is part of Cygwin.
5 This software is a copyrighted work licensed under the terms of the
6 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
14 /* Conversions for per-process and per-thread clocks */
15 #define PID_TO_CLOCKID(pid) (pid * 8 + CLOCK_PROCESS_CPUTIME_ID)
16 #define CLOCKID_TO_PID(cid) ((cid - CLOCK_PROCESS_CPUTIME_ID) / 8)
17 #define CLOCKID_IS_PROCESS(cid) ((cid % 8) == CLOCK_PROCESS_CPUTIME_ID)
18 #define THREADID_TO_CLOCKID(tid) (tid * 8 + CLOCK_THREAD_CPUTIME_ID)
19 #define CLOCKID_TO_THREADID(cid) ((cid - CLOCK_THREAD_CPUTIME_ID) / 8)
20 #define CLOCKID_IS_THREAD(cid) ((cid % 8) == CLOCK_THREAD_CPUTIME_ID)
22 /* Largest delay in ms for sleep and alarm calls.
23 Allow actual delay to exceed requested delay by 10 s.
24 Express as multiple of 1000 (i.e. seconds) + max resolution
25 The tv_sec argument in timeval structures cannot exceed
26 HIRES_DELAY_MAX / 1000 - 1, so that adding fractional part
27 and rounding won't exceed HIRES_DELAY_MAX */
28 #define HIRES_DELAY_MAX ((((UINT_MAX - 10000) / 1000) * 1000) + 10)
30 /* 100ns difference between Windows and UNIX timebase. */
31 #define FACTOR (0x19db1ded53e8000LL)
32 /* # of nanosecs per second. */
33 #define NSPERSEC (1000000000)
34 /* # of 100ns intervals per second. */
35 #define NS100PERSEC (10000000)
36 /* # of millisecs per second. */
37 #define USPERSEC (1000000)
44 void reset() {inited
= false;}
47 class hires_ns
: public hires_base
49 LARGE_INTEGER primed_pc
;
53 LONGLONG
nsecs (bool monotonic
= false);
54 LONGLONG
usecs () {return nsecs () / 1000LL;}
55 LONGLONG
resolution();
58 class hires_ms
: public hires_base
62 LONGLONG
usecs () {return nsecs () / 10LL;}
63 LONGLONG
msecs () {return nsecs () / 10000LL;}
68 #endif /*__HIRES_H__*/
This page took 0.039212 seconds and 5 git commands to generate.