1.\"	$NetBSD: pthread_getcpuclockid.3,v 1.1 2016/04/23 23:12:19 christos Exp $
2.\"
3.\" Copyright (c) 2016 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Christos Zoulas.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.Dd April 23, 2016
31.Dt clock_getcpuclockid2 2
32.Os
33.Sh NAME
34.Nm clock_getcpuclockid2
35.Nd retrieve the clock id of a process or lwp
36.Sh LIBRARY
37.Lb libc
38.Sh SYNOPSIS
39.In time.h
40.Ft int
41.Fn clock_getcpuclockid2 "idtype_t idtype" "id_t id" "clockid_t *clock_id"
42.Ft int
43.Fn clock_getcpuclockid "pid_t pid" "clockid_t *clock_id"
44.Sh DESCRIPTION
45The
46.Fn cpu_getcpuclockid2
47function retrieves the
48.Fa clock_id
49for the specified
50.Fa id
51and
52.Fa idtype.
53Supported
54.Fa idtypes
55are:
56.Bl -tag -width P_LWPID
57.It Dv P_PID
58The specified process id or
59.Dv 0
60for the current process.
61.It Dv P_LWPID
62The specified LWP id or
63.Dv 0
64for the current LWP.
65.El
66.Pp
67The
68.Fn clock_getcpuclockid
69function is equivalent to calling
70.Fn clock_getcpuclockid2
71with
72.Fa idtype
73.Dv P_PID
74and
75.Fa id
76.Fa pid .
77.Pp
78The
79.Xr clock_gettime 2
80function can be used with the returned
81.Fa clock_id
82to retrieve process and LWP times.
83.Sh RETURN VALUES
84The
85.Fn clock_getcpuclockid
86and
87.Fn clock_getcpuclockid2
88functions succeed and return 0, placing the requested
89.Fa clock_id
90in the argument.
91On error, the value \-1 is returned
92and the value of
93.Va errno
94is set to reflect what went wrong.
95.Sh ERRORS
96These functions fail if:
97.Bl -tag -width Er
98.It Bq Er EINVAL
99An unsuppored
100.Fa idtype
101was supplied.
102.El
103.Sh SEE ALSO
104.Xr clock_gettime 2
105.Sh STANDARDS
106The
107.Fn clock_getcpuclockid
108function conforms to
109.St -p1003.1-2001 .
110The
111.Fn clock_getcpuclockid2
112is a
113.Nx
114extension.
115.Sh HISTORY
116The
117.Fn clock_getcpuclockid
118and
119.Fn clock_getcpuclockid2
120functions appeared in
121.Nx 8 .
122