Module Name:    src
Committed By:   christos
Date:           Sat Apr 23 23:12:19 UTC 2016

Modified Files:
        src/lib/libpthread: Makefile pthread.h
Added Files:
        src/lib/libpthread: pthread_getcpuclockid.3 pthread_getcpuclockid.c

Log Message:
Add pthread_getcpuclockid(3)


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/lib/libpthread/Makefile
cvs rdiff -u -r1.35 -r1.36 src/lib/libpthread/pthread.h
cvs rdiff -u -r0 -r1.1 src/lib/libpthread/pthread_getcpuclockid.3 \
    src/lib/libpthread/pthread_getcpuclockid.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libpthread/Makefile
diff -u src/lib/libpthread/Makefile:1.85 src/lib/libpthread/Makefile:1.86
--- src/lib/libpthread/Makefile:1.85	Tue Dec 16 15:05:54 2014
+++ src/lib/libpthread/Makefile	Sat Apr 23 19:12:19 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.85 2014/12/16 20:05:54 pooka Exp $
+#	$NetBSD: Makefile,v 1.86 2016/04/23 23:12:19 christos Exp $
 #
 
 WARNS?=	5
@@ -54,6 +54,7 @@ SRCS+=	pthread_barrier.c
 SRCS+=	pthread_cancelstub.c
 .endif
 SRCS+=	pthread_cond.c
+SRCS+=	pthread_getcpuclockid.c
 SRCS+=	pthread_lock.c 
 SRCS+=	${PTHREAD_MAKELWP}
 SRCS+=	pthread_misc.c
@@ -134,6 +135,7 @@ MAN+=	affinity.3 pthread.3 \
 	pthread_create.3 pthread_detach.3 pthread_equal.3 \
 	pthread_curcpu_np.3 \
 	pthread_exit.3 \
+	pthread_getcpuclockid.3 \
 	pthread_getname_np.3 \
 	pthread_getspecific.3 pthread_join.3 \
 	pthread_key_create.3 pthread_kill.3 \

Index: src/lib/libpthread/pthread.h
diff -u src/lib/libpthread/pthread.h:1.35 src/lib/libpthread/pthread.h:1.36
--- src/lib/libpthread/pthread.h:1.35	Fri Nov  2 23:10:50 2012
+++ src/lib/libpthread/pthread.h	Sat Apr 23 19:12:19 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pthread.h,v 1.35 2012/11/03 03:10:50 christos Exp $	*/
+/*	$NetBSD: pthread.h,v 1.36 2016/04/23 23:12:19 christos Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -138,6 +138,8 @@ int	pthread_resume_np(pthread_t);
 
 unsigned int	pthread_curcpu_np(void);
 
+int	pthread_getcpuclockid(pthread_t, clockid_t *);
+
 struct pthread_cleanup_store {
 	void	*pad[4];
 };

Added files:

Index: src/lib/libpthread/pthread_getcpuclockid.3
diff -u /dev/null src/lib/libpthread/pthread_getcpuclockid.3:1.1
--- /dev/null	Sat Apr 23 19:12:19 2016
+++ src/lib/libpthread/pthread_getcpuclockid.3	Sat Apr 23 19:12:19 2016
@@ -0,0 +1,121 @@
+.\"	$NetBSD: pthread_getcpuclockid.3,v 1.1 2016/04/23 23:12:19 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 .
Index: src/lib/libpthread/pthread_getcpuclockid.c
diff -u /dev/null src/lib/libpthread/pthread_getcpuclockid.c:1.1
--- /dev/null	Sat Apr 23 19:12:19 2016
+++ src/lib/libpthread/pthread_getcpuclockid.c	Sat Apr 23 19:12:19 2016
@@ -0,0 +1,46 @@
+/*	$NetBSD: pthread_getcpuclockid.c,v 1.1 2016/04/23 23:12:19 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: pthread_getcpuclockid.c,v 1.1 2016/04/23 23:12:19 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+#include <pthread.h>
+#include <time.h>
+
+#include "pthread_int.h"
+
+int
+pthread_getcpuclockid(pthread_t thread, clockid_t *clock_id)
+{
+	return clock_getcpuclockid2(P_LWPID, (id_t)thread->pt_lid, clock_id);
+}

Reply via email to