Module Name:    src
Committed By:   christos
Date:           Sat Apr 23 23:11:31 UTC 2016

Modified Files:
        src/lib/libc: shlib_version
        src/lib/libc/sys: Makefile.inc clock_settime.2
Added Files:
        src/lib/libc/sys: clock_getcpuclockid.c clock_getcpuclockid2.2

Log Message:
add clock_getcpuclockid{2,}


To generate a diff of this commit:
cvs rdiff -u -r1.263 -r1.264 src/lib/libc/shlib_version
cvs rdiff -u -r1.229 -r1.230 src/lib/libc/sys/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/lib/libc/sys/clock_getcpuclockid.c \
    src/lib/libc/sys/clock_getcpuclockid2.2
cvs rdiff -u -r1.24 -r1.25 src/lib/libc/sys/clock_settime.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/shlib_version
diff -u src/lib/libc/shlib_version:1.263 src/lib/libc/shlib_version:1.264
--- src/lib/libc/shlib_version:1.263	Sat Apr  2 20:19:42 2016
+++ src/lib/libc/shlib_version	Sat Apr 23 19:11:31 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: shlib_version,v 1.263 2016/04/03 00:19:42 christos Exp $
+#	$NetBSD: shlib_version,v 1.264 2016/04/23 23:11:31 christos Exp $
 #	Remember to update distrib/sets/lists/base/shl.* when changing
 #
 # things we wish to do on next major version bump:
@@ -44,4 +44,4 @@
 # - decide whether soft-float should support fenv.h, including thread-local contett
 # - stop all math functions from setting errno
 major=12
-minor=201
+minor=202

Index: src/lib/libc/sys/Makefile.inc
diff -u src/lib/libc/sys/Makefile.inc:1.229 src/lib/libc/sys/Makefile.inc:1.230
--- src/lib/libc/sys/Makefile.inc:1.229	Sat Apr  2 20:19:42 2016
+++ src/lib/libc/sys/Makefile.inc	Sat Apr 23 19:11:31 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.229 2016/04/03 00:19:42 christos Exp $
+#	$NetBSD: Makefile.inc,v 1.230 2016/04/23 23:11:31 christos Exp $
 #	@(#)Makefile.inc	8.3 (Berkeley) 10/24/94
 
 # sys sources
@@ -8,7 +8,8 @@
 SRCS+=	cpuset.c
 # glue to offer userland wrappers for some syscalls
 SRCS+=	posix_fadvise.c posix_madvise.c sched.c sigqueue.c sigtimedwait.c \
-	sigwait.c sigwaitinfo.c statvfs.c swapon.c semctl.c 
+	sigwait.c sigwaitinfo.c statvfs.c swapon.c semctl.c \
+	clock_getcpuclockid.c
 
 .if ${RUMPRUN} != "yes"
 # modules with non-default implementations on at least one architecture:
@@ -32,7 +33,7 @@ CLEANFILES+=	${_LSRC:MLintSys*.c}
 # with old syscall interfaces.
 GLUE+= fdiscard.c ftruncate.c lseek.c mmap.c \
 	pread.c preadv.c pwrite.c pwritev.c truncate.c ntp_adjtime.c \
-	mknodat.c
+	mknodat.c 
 GLUENOERR+= posix_fallocate.c
 GLUE50+= adjtime.c clock_settime.c settimeofday.c
 
@@ -91,6 +92,7 @@ ASM_GLUE+= tmp___${glue:.c=}50.S
 ASM=	access.S acct.S \
 	bind.S \
 	chdir.S chflags.S chmod.S chown.S chroot.S clock_nanosleep.S \
+		clock_getcpuclockid2.S \
 		__clock_getres50.S __clock_gettime50.S \
 	dup.S dup2.S dup3.S \
 	extattrctl.S \
@@ -241,7 +243,8 @@ LintSysPseudoNoerr.c: ${LIBCDIR}/sys/mak
 	    -s ${DESTDIR}/usr/include/sys/syscall.h ${PSEUDONOERR}
 
 MAN+=	accept.2 access.2 acct.2 adjtime.2 bind.2 brk.2 chdir.2 \
-	chflags.2 chmod.2 chown.2 chroot.2 clock_settime.2 clone.2 close.2 \
+	chflags.2 chmod.2 chown.2 chroot.2 clock_getcpuclockid2.2 \
+	clock_settime.2 clone.2 close.2 \
 	connect.2 dup.2 execve.2 _exit.2 extattr_get_file.2 \
 	fcntl.2 fdatasync.2 fdiscard.2 fhopen.2 \
 	flock.2 fork.2 fsync.2 getcontext.2 getdents.2 \
@@ -378,3 +381,4 @@ MLINKS+=write.2 writev.2 write.2 pwrite.
 MLINKS+=pipe.2 pipe2.2
 MLINKS+=accept.2 paccept.2
 MLINKS+=nanosleep.2 clock_nanosleep.2
+MLINKS+=clock_getcpuclockid2.2 clock_getcpuclockid.2

Index: src/lib/libc/sys/clock_settime.2
diff -u src/lib/libc/sys/clock_settime.2:1.24 src/lib/libc/sys/clock_settime.2:1.25
--- src/lib/libc/sys/clock_settime.2:1.24	Wed Dec  9 03:30:03 2015
+++ src/lib/libc/sys/clock_settime.2	Sat Apr 23 19:11:31 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: clock_settime.2,v 1.24 2015/12/09 08:30:03 wiz Exp $
+.\" $NetBSD: clock_settime.2,v 1.25 2016/04/23 23:11:31 christos Exp $
 .\"
 .\" Copyright (c) 1999 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd December 8, 2015
+.Dd April 23, 2016
 .Dt CLOCK_SETTIME 2
 .Os
 .Sh NAME
@@ -88,10 +88,11 @@ and obtained by
 represent the amount of time (in seconds and nanoseconds)
 since 00:00 Universal Coordinated Time, January 1, 1970.
 .Pp
-A
+The following
 .Fa clock_id
-of
-.Dv CLOCK_MONOTONIC
+values are supported:
+.Bl -tag -width CLOCK_MONOTONIC
+.It Dv CLOCK_MONOTONIC
 identifies a clock that increases at a steady rate (monotonically).
 This clock
 is not affected by calls to
@@ -104,20 +105,19 @@ fail with an
 error if it's the clock specified in a call to
 .Fn clock_settime .
 The origin of the clock is unspecified.
-.Pp
-A
-.Fa clock_id
-of
-.Dv CLOCK_VIRTUAL
+.It Dv CLOCK_VIRTUAL
 identifies a clock that increments only when the CPU is running in
 user mode on behalf of the calling process.
-.Pp
-A
-.Fa clock_id
-of
-.Dv CLOCK_PROF
+.It Dv CLOCK_PROF
 identifies a clock that increments when the CPU is running in user
 or kernel mode on behalf of the calling process.
+.It Dv CLOCK_PROCESS_CPUTIME_ID
+identifies a per process clock based on tick values.
+This clock is not settable.
+.It Dv CLOCK_THREAD_CPUTIME_ID
+identifies a per thread clock based on tick values.
+This clock is not settable.
+.El
 .Pp
 If the calling user is not the super-user, the
 .Fn clock_settime

Added files:

Index: src/lib/libc/sys/clock_getcpuclockid.c
diff -u /dev/null src/lib/libc/sys/clock_getcpuclockid.c:1.1
--- /dev/null	Sat Apr 23 19:11:31 2016
+++ src/lib/libc/sys/clock_getcpuclockid.c	Sat Apr 23 19:11:31 2016
@@ -0,0 +1,43 @@
+/*	$NetBSD: clock_getcpuclockid.c,v 1.1 2016/04/23 23:11:31 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: clock_getcpuclockid.c,v 1.1 2016/04/23 23:11:31 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+#include <time.h>
+
+int
+clock_getcpuclockid(pid_t pid, clockid_t *clock_id)
+{
+	return clock_getcpuclockid2(P_PID, (id_t)pid, clock_id);
+}
Index: src/lib/libc/sys/clock_getcpuclockid2.2
diff -u /dev/null src/lib/libc/sys/clock_getcpuclockid2.2:1.1
--- /dev/null	Sat Apr 23 19:11:31 2016
+++ src/lib/libc/sys/clock_getcpuclockid2.2	Sat Apr 23 19:11:31 2016
@@ -0,0 +1,121 @@
+.\"	$NetBSD: clock_getcpuclockid2.2,v 1.1 2016/04/23 23:11:31 christos Exp $
+.\"
+.\" Copyright (c) 2016 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Christos Zoulas.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd April 23, 2016
+.Dt clock_getcpuclockid2 2
+.Os
+.Sh NAME
+.Nm clock_getcpuclockid2
+.Nd retrieve the clock id of a process or lwp
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In time.h
+.Ft int
+.Fn clock_getcpuclockid2 "idtype_t idtype" "id_t id" "clockid_t *clock_id"
+.Ft int
+.Fn clock_getcpuclockid "pid_t pid" "clockid_t *clock_id"
+.Sh DESCRIPTION
+The
+.Fn cpu_getcpuclockid2
+function retrieves the
+.Fa clock_id
+for the specified
+.Fa id
+and
+.Fa idtype.
+Supported
+.Fa idtypes
+are:
+.Bl -tag -width P_LWPID
+.It Dv P_PID
+The specified process id or
+.Dv 0
+for the current process.
+.It Dv P_LWPID
+The specified LWP id or
+.Dv 0
+for the current LWP.
+.El
+.Pp
+The
+.Fn clock_getcpuclockid
+function is equivalent to calling
+.Fn clock_getcpuclockid2
+with
+.Fa idtype
+.Dv P_PID
+and
+.Fa id
+.Fa pid .
+.Pp
+The
+.Xr clock_gettime 2
+function can be used with the returned
+.Fa clock_id
+to retrieve process and LWP times.
+.Sh RETURN VALUES
+The
+.Fn clock_getcpuclockid
+and
+.Fn clock_getcpuclockid2
+functions succeed and return 0, placing the requested
+.Fa clock_id 
+in the argument.
+On error, the value \-1 is returned
+and the value of
+.Va errno
+is set to reflect what went wrong.
+.Sh ERRORS
+These functions fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+An unsuppored
+.Fa idtype
+was supplied.
+.El
+.Sh SEE ALSO
+.Xr clock_gettime 2
+.Sh STANDARDS
+The
+.Fn clock_getcpuclockid
+function conforms to
+.St -p1003.1-2001 .
+The
+.Fn clock_getcpuclockid2
+is a
+.Nx
+extension.
+.Sh HISTORY
+The
+.Fn clock_getcpuclockid
+and
+.Fn clock_getcpuclockid2
+functions appeared in
+.Nx 8 .

Reply via email to