[PATCH] POSIX monotonic clock

Yaakov (Cygwin/X) yselkowitz@users.sourceforge.net
Mon Aug 2 20:49:00 GMT 2010


Here is an attempt to implement POSIX.1-2004+ Monotonic Clock:

http://www.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html

In summary, I took hires_us and changed the resolution to nanoseconds. I
dropped systime() because the only place hires_us was being used is in
strace.cc which ignored it, and WRT POSIX monotonic clocks the absolute
value of the clock is meaningless.  Since systime() has only 100ns
precision, using it would either force a loss in resolution or (if
multiplied by 100 to get ns) an early overflow.  I also switched from
ENOSYS to EINVAL, as POSIX.1-2004 and 2008 dropped references to the
former (as noted in Change History).

Patches for newlib, winsup/cygwin and winsup/doc attached.

I have also attached an STC for the new functionality.  FWIW, on my
machine, QueryPerformanceFrequency() returns just over 2.9 million,
resulting in a clock_getres(CLOCK_MONOTONIC) of 340ns.

I would appreciate a careful review of this patch, both from the Cygwin
API and POSIX POVs.


Yaakov

-------------- next part --------------
A non-text attachment was scrubbed...
Name: clock-test.c
Type: text/x-csrc
Size: 776 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20100802/fa1f14ac/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: newlib-cygwin-monotonic-clock.patch
Type: text/x-patch
Size: 838 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20100802/fa1f14ac/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winsup-cygwin-monotonic-clock.patch
Type: text/x-patch
Size: 7909 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20100802/fa1f14ac/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winsup-doc-monotonic-clock.patch
Type: text/x-patch
Size: 670 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20100802/fa1f14ac/attachment-0003.bin>


More information about the Cygwin-patches mailing list