Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/sys add clock_nanosleep(2)
details: https://anonhg.NetBSD.org/src/rev/fc3bb85b2248
branches: trunk
changeset: 781806:fc3bb85b2248
user: christos <christos%NetBSD.org@localhost>
date: Tue Oct 02 01:46:40 2012 +0000
description:
add clock_nanosleep(2)
diffstat:
lib/libc/sys/Makefile.inc | 7 ++-
lib/libc/sys/nanosleep.2 | 82 ++++++++++++++++++++++++++++++++++++++++------
2 files changed, 74 insertions(+), 15 deletions(-)
diffs (154 lines):
diff -r d67e4aa92dcf -r fc3bb85b2248 lib/libc/sys/Makefile.inc
--- a/lib/libc/sys/Makefile.inc Tue Oct 02 01:46:20 2012 +0000
+++ b/lib/libc/sys/Makefile.inc Tue Oct 02 01:46:40 2012 +0000
@@ -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 @@
# 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+=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
diff -r d67e4aa92dcf -r fc3bb85b2248 lib/libc/sys/nanosleep.2
--- a/lib/libc/sys/nanosleep.2 Tue Oct 02 01:46:20 2012 +0000
+++ b/lib/libc/sys/nanosleep.2 Tue Oct 02 01:46:40 2012 +0000
@@ -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
+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
+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
-suspends execution of the calling process until either the number of
-seconds and nanoseconds specified by
-.Fa rqtp
-have elapsed or a signal is delivered to the calling process and its
-action is to invoke a signal catching function or to terminate the
-process.
-The suspension time may be longer than requested due to the
-scheduling of other activity by the system.
+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 @@
.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 @@
.Fn nanosleep
function conforms to
.St -p1003.1b-93 .
+The
+.Fn clock_nanosleep
+function conforms to
+.St -p1003.1j-2000 .
Home |
Main Index |
Thread Index |
Old Index