Module Name: src Committed By: christos Date: Tue Oct 2 01:46:40 UTC 2012
Modified Files: src/lib/libc/sys: Makefile.inc nanosleep.2 Log Message: add clock_nanosleep(2) To generate a diff of this commit: cvs rdiff -u -r1.216 -r1.217 src/lib/libc/sys/Makefile.inc cvs rdiff -u -r1.11 -r1.12 src/lib/libc/sys/nanosleep.2 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/sys/Makefile.inc diff -u src/lib/libc/sys/Makefile.inc:1.216 src/lib/libc/sys/Makefile.inc:1.217 --- src/lib/libc/sys/Makefile.inc:1.216 Tue Sep 11 22:00:53 2012 +++ src/lib/libc/sys/Makefile.inc Mon Oct 1 21:46:40 2012 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.216 2012/09/12 02:00:53 manu Exp $ +# $NetBSD: Makefile.inc,v 1.217 2012/10/02 01:46:40 christos Exp $ # @(#)Makefile.inc 8.3 (Berkeley) 10/24/94 # sys sources @@ -75,8 +75,8 @@ SRCS+= _brk.c _fork.c _getcontext.c _pip # modules with default implementations on all architectures: ASM= access.S acct.S \ bind.S \ - chdir.S chflags.S chmod.S chown.S chroot.S __clock_getres50.S \ - __clock_gettime50.S \ + chdir.S chflags.S chmod.S chown.S chroot.S clock_nanosleep.S \ + __clock_getres50.S __clock_gettime50.S \ dup.S dup2.S dup3.S \ extattrctl.S \ extattr_delete_fd.S extattr_delete_file.S \ @@ -327,3 +327,4 @@ MLINKS+=wait.2 wait3.2 wait.2 wait4.2 wa MLINKS+=write.2 writev.2 write.2 pwrite.2 write.2 pwritev.2 MLINKS+=pipe.2 pipe2.2 MLINKS+=accept.2 paccept.2 +MLINKS+=nanosleep.2 clock_nanosleep.2 Index: src/lib/libc/sys/nanosleep.2 diff -u src/lib/libc/sys/nanosleep.2:1.11 src/lib/libc/sys/nanosleep.2:1.12 --- src/lib/libc/sys/nanosleep.2:1.11 Mon May 17 03:22:03 2010 +++ src/lib/libc/sys/nanosleep.2 Mon Oct 1 21:46:40 2012 @@ -1,4 +1,4 @@ -.\" $NetBSD: nanosleep.2,v 1.11 2010/05/17 07:22:03 jruoho Exp $ +.\" $NetBSD: nanosleep.2,v 1.12 2012/10/02 01:46:40 christos Exp $ .\" .\" Copyright (c) 1986, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)sleep.3 8.1 (Berkeley) 6/4/93 .\" -.Dd May 17, 2010 +.Dd October 1, 2012 .Dt NANOSLEEP 2 .Os .Sh NAME @@ -40,31 +40,78 @@ .Sh SYNOPSIS .In time.h .Ft int +.Fn clock_nanosleep "clockid_t clock_id" "int flags" "const struct timespec *rqtp" "struct timespec *rmtp" +.Ft int .Fn nanosleep "const struct timespec *rqtp" "struct timespec *rmtp" .Sh DESCRIPTION -The -.Fn nanosleep -suspends execution of the calling process until either the number of -seconds and nanoseconds specified by +If the +.Dv TIMER_ABSTIME +flag is not set in the +.Fa flags +argument, then +.Fn clock_nanosleep +suspends execution of the calling thread until either the number of +seconds and nanoseconds specified in the +.Fa rqtp +argument have elapsed using the clock in the +.Fa clock_id +argument, or a signal is delivered to the calling process and its +action is to invoke a signal catching function or to terminate the +process. +.Pp +If the +.Dv TIMER_ABSTIME +flag is set in the +.Fa flags +argument, then +.Fn clock_nanosleep +suspends execution of the calling thread until either the value +of the clock specified in the +.Fa clock_id +argument reaches the value of the .Fa rqtp -have elapsed or a signal is delivered to the calling process and its +argument in seconds and nanoseconds, +or a signal is delivered to the calling process and its action is to invoke a signal catching function or to terminate the process. +.Pp The suspension time may be longer than requested due to the scheduling of other activity by the system. +.Pp +The +.Fn nanosleep +function behaves like +.Fn clock_nanosleep +with the +.Fa clock_id +argument equal to +.Dv CLOCK_MONOTONIC +and the +.Fa flags +argument having +.Dv TIMER_ABSTIME +not set. +.Pp The .Em struct timespec is described in .Xr timespec 3 . +The +.Fa clock_id +specified is the time source. .Sh RETURN VALUES If the +.Fn clock_nanosleep +or the .Fn nanosleep -function returns because the requested time has elapsed, the value +functions return because the requested time has elapsed, the value returned will be zero. .Pp If the +.Fn clock_nanosleep +or the .Fn nanosleep -function returns due to the delivery of a signal, the value returned +functions return due to the delivery of a signal, the value returned will be the \-1, and the global variable .Va errno will be set to indicate the interruption. @@ -97,6 +144,13 @@ specified a nanosecond value less than z .It Bq Er ENOSYS .Nm is not supported by this implementation. +.It Bq Er ENOTSUP +for +.Fn clock_nanosleep , +the clock specified in the +.Fa +clock_id +argument is not supported. .El .Sh SEE ALSO .Xr sleep 3 , @@ -106,3 +160,7 @@ The .Fn nanosleep function conforms to .St -p1003.1b-93 . +The +.Fn clock_nanosleep +function conforms to +.St -p1003.1j-2000 .