xref: /netbsd-src/lib/libc/sys/clock_getcpuclockid2.2 (revision 03dcb730d46d34d85c9f496c1f5a3a6a43f2b7b3)
1.\"	$NetBSD: clock_getcpuclockid2.2,v 1.4 2017/03/05 18:42:51 njoly 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 March 5, 2017
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
84.Rv -std clock_getcpuclockid2
85.Pp
86If successful, the
87.Fn clock_getcpuclockid
88function will return 0.
89Otherwise an error number will be returned.
90.Sh ERRORS
91These functions fail if:
92.Bl -tag -width Er
93.It Bq Er EFAULT
94.Fa clock_id
95points outside the process's allocated address space.
96.El
97.Pp
98In addition
99.Fn clock_getcpuclockid2
100will fail if:
101.Bl -tag -width Er
102.It Bq Er EINVAL
103An unsupported
104.Fa idtype
105was supplied.
106.El
107.Sh SEE ALSO
108.Xr clock_gettime 2
109.Sh STANDARDS
110The
111.Fn clock_getcpuclockid
112function conforms to
113.St -p1003.1-2001 .
114The
115.Fn clock_getcpuclockid2
116is a
117.Nx
118extension.
119.Sh HISTORY
120The
121.Fn clock_getcpuclockid
122and
123.Fn clock_getcpuclockid2
124functions appeared in
125.Nx 8 .
126