[PATCH] clock_nanosleep(2)
Corinna Vinschen
corinna-cygwin@cygwin.com
Wed Jul 20 07:57:00 GMT 2011
Hi Yaakov,
On Jul 19 20:54, Yaakov (Cygwin/X) wrote:
> This patchset implements the POSIX clock_nanosleep(2) function:
>
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_nanosleep.html
> http://www.kernel.org/doc/man-pages/online/pages/man2/clock_nanosleep.2.html
>
> In summary, clock_nanosleep(2) replaces nanosleep(2) as the primary
> sleeping function, with all others rewritten in terms of the former. It
> also restores maximum precision to hires_ms::resolution(), saving the
> <5000 100ns check for the one place where resolution is rounded off.
I like this, it's probably not only faster but it makes the code better
readable. But let's talk about the newlib side first.
> Index: libc/include/time.h
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/include/time.h,v
> retrieving revision 1.19
> diff -u -r1.19 time.h
> --- libc/include/time.h 16 Oct 2008 21:53:58 -0000 1.19
> +++ libc/include/time.h 15 May 2011 19:22:48 -0000
> @@ -168,6 +168,9 @@
>
> /* High Resolution Sleep, P1003.1b-1993, p. 269 */
>
> +int _EXFUN(clock_nanosleep,
> + (clockid_t clock_id, int flags, const struct timespec *rqtp,
> + struct timespec *rmtp));
> int _EXFUN(nanosleep, (const struct timespec *rqtp, struct timespec *rmtp));
>
> #ifdef __cplusplus
This doesn't look right. In contrast to nanosleep, clock_nanosleep
is not subsumed under the _POSIX_TIMERS option. In fact it's the only
function under the _POSIX_CLOCK_SELECTION option. So clock_nanosleep
should be guarded independently of _POSIX_TIMERS, kind of like this:
#if defined(_POSIX_CLOCK_SELECTION)
extern "C" {
int _EXFUN(clock_nanosleep, ...
Additionally _POSIX_CLOCK_SELECTION has to be activated in features.h.
Would you mind to send this patch to the newlib list then?
I haven't much time right now. If cgf doesn't beat me to it, I'll
review the function later.
Thanks,
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat
More information about the Cygwin-patches
mailing list