xref: /netbsd-src/lib/libc/sys/clock_getcpuclockid2.2 (revision bc382992a08a8cad5c078c745fd429c4631f0a20)
1*bc382992Sdholland.\"	$NetBSD: clock_getcpuclockid2.2,v 1.6 2018/06/25 01:21:21 dholland Exp $
2817b192dSchristos.\"
3817b192dSchristos.\" Copyright (c) 2016 The NetBSD Foundation, Inc.
4817b192dSchristos.\" All rights reserved.
5817b192dSchristos.\"
6817b192dSchristos.\" This code is derived from software contributed to The NetBSD Foundation
7817b192dSchristos.\" by Christos Zoulas.
8817b192dSchristos.\"
9817b192dSchristos.\" Redistribution and use in source and binary forms, with or without
10817b192dSchristos.\" modification, are permitted provided that the following conditions
11817b192dSchristos.\" are met:
12817b192dSchristos.\" 1. Redistributions of source code must retain the above copyright
13817b192dSchristos.\"    notice, this list of conditions and the following disclaimer.
14817b192dSchristos.\" 2. Redistributions in binary form must reproduce the above copyright
15817b192dSchristos.\"    notice, this list of conditions and the following disclaimer in the
16817b192dSchristos.\"    documentation and/or other materials provided with the distribution.
17817b192dSchristos.\"
18817b192dSchristos.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19817b192dSchristos.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20817b192dSchristos.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21817b192dSchristos.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22817b192dSchristos.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23817b192dSchristos.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24817b192dSchristos.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25817b192dSchristos.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26817b192dSchristos.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27817b192dSchristos.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28817b192dSchristos.\" POSSIBILITY OF SUCH DAMAGE.
29817b192dSchristos.\"
30*bc382992Sdholland.Dd June 24, 2018
31982b0c24Swiz.Dt CLOCK_GETCPUCLOCKID2 2
32817b192dSchristos.Os
33817b192dSchristos.Sh NAME
34c8a396a1Sabhinav.Nm clock_getcpuclockid2 ,
35c8a396a1Sabhinav.Nm clock_getcpuclockid
36982b0c24Swiz.Nd retrieve the clock id of a process or LWP
37817b192dSchristos.Sh LIBRARY
38817b192dSchristos.Lb libc
39817b192dSchristos.Sh SYNOPSIS
40817b192dSchristos.In time.h
41817b192dSchristos.Ft int
42817b192dSchristos.Fn clock_getcpuclockid2 "idtype_t idtype" "id_t id" "clockid_t *clock_id"
43817b192dSchristos.Ft int
44817b192dSchristos.Fn clock_getcpuclockid "pid_t pid" "clockid_t *clock_id"
45817b192dSchristos.Sh DESCRIPTION
46817b192dSchristosThe
47817b192dSchristos.Fn cpu_getcpuclockid2
48817b192dSchristosfunction retrieves the
49817b192dSchristos.Fa clock_id
50*bc382992Sdhollandfor the CPU-time clock of the specified
51817b192dSchristos.Fa id
52817b192dSchristosand
53817b192dSchristos.Fa idtype .
54817b192dSchristosSupported
55817b192dSchristos.Fa idtypes
56817b192dSchristosare:
57817b192dSchristos.Bl -tag -width P_LWPID
58817b192dSchristos.It Dv P_PID
59817b192dSchristosThe specified process id or
60817b192dSchristos.Dv 0
61817b192dSchristosfor the current process.
62817b192dSchristos.It Dv P_LWPID
63817b192dSchristosThe specified LWP id or
64817b192dSchristos.Dv 0
65817b192dSchristosfor the current LWP.
66817b192dSchristos.El
67817b192dSchristos.Pp
68817b192dSchristosThe
69817b192dSchristos.Fn clock_getcpuclockid
70817b192dSchristosfunction is equivalent to calling
71817b192dSchristos.Fn clock_getcpuclockid2
72817b192dSchristoswith
73817b192dSchristos.Fa idtype
74817b192dSchristos.Dv P_PID
75817b192dSchristosand
76817b192dSchristos.Fa id
77817b192dSchristos.Fa pid .
78817b192dSchristos.Pp
79817b192dSchristosThe
80817b192dSchristos.Xr clock_gettime 2
81817b192dSchristosfunction can be used with the returned
82817b192dSchristos.Fa clock_id
83*bc382992Sdhollandto retrieve process and LWP CPU usage times.
84817b192dSchristos.Sh RETURN VALUES
855e0724b3Snjoly.Rv -std clock_getcpuclockid2
865e0724b3Snjoly.Pp
875e0724b3SnjolyIf successful, the
88817b192dSchristos.Fn clock_getcpuclockid
895e0724b3Snjolyfunction will return 0.
905e0724b3SnjolyOtherwise an error number will be returned.
91817b192dSchristos.Sh ERRORS
92817b192dSchristosThese functions fail if:
93817b192dSchristos.Bl -tag -width Er
949be71c74Snjoly.It Bq Er EFAULT
959be71c74Snjoly.Fa clock_id
969be71c74Snjolypoints outside the process's allocated address space.
979be71c74Snjoly.El
989be71c74Snjoly.Pp
999be71c74SnjolyIn addition
1009be71c74Snjoly.Fn clock_getcpuclockid2
1019be71c74Snjolywill fail if:
1029be71c74Snjoly.Bl -tag -width Er
103817b192dSchristos.It Bq Er EINVAL
104982b0c24SwizAn unsupported
105817b192dSchristos.Fa idtype
106817b192dSchristoswas supplied.
107817b192dSchristos.El
108817b192dSchristos.Sh SEE ALSO
109817b192dSchristos.Xr clock_gettime 2
110817b192dSchristos.Sh STANDARDS
111817b192dSchristosThe
112817b192dSchristos.Fn clock_getcpuclockid
113817b192dSchristosfunction conforms to
114817b192dSchristos.St -p1003.1-2001 .
115817b192dSchristosThe
116817b192dSchristos.Fn clock_getcpuclockid2
117817b192dSchristosis a
118817b192dSchristos.Nx
119817b192dSchristosextension.
120817b192dSchristos.Sh HISTORY
121817b192dSchristosThe
122817b192dSchristos.Fn clock_getcpuclockid
123817b192dSchristosand
124817b192dSchristos.Fn clock_getcpuclockid2
125817b192dSchristosfunctions appeared in
126817b192dSchristos.Nx 8 .
127