1.\" $NetBSD: clock_getcpuclockid2.2,v 1.6 2018/06/25 01:21:21 dholland 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 June 24, 2018 31.Dt CLOCK_GETCPUCLOCKID2 2 32.Os 33.Sh NAME 34.Nm clock_getcpuclockid2 , 35.Nm clock_getcpuclockid 36.Nd retrieve the clock id of a process or LWP 37.Sh LIBRARY 38.Lb libc 39.Sh SYNOPSIS 40.In time.h 41.Ft int 42.Fn clock_getcpuclockid2 "idtype_t idtype" "id_t id" "clockid_t *clock_id" 43.Ft int 44.Fn clock_getcpuclockid "pid_t pid" "clockid_t *clock_id" 45.Sh DESCRIPTION 46The 47.Fn cpu_getcpuclockid2 48function retrieves the 49.Fa clock_id 50for the CPU-time clock of the specified 51.Fa id 52and 53.Fa idtype . 54Supported 55.Fa idtypes 56are: 57.Bl -tag -width P_LWPID 58.It Dv P_PID 59The specified process id or 60.Dv 0 61for the current process. 62.It Dv P_LWPID 63The specified LWP id or 64.Dv 0 65for the current LWP. 66.El 67.Pp 68The 69.Fn clock_getcpuclockid 70function is equivalent to calling 71.Fn clock_getcpuclockid2 72with 73.Fa idtype 74.Dv P_PID 75and 76.Fa id 77.Fa pid . 78.Pp 79The 80.Xr clock_gettime 2 81function can be used with the returned 82.Fa clock_id 83to retrieve process and LWP CPU usage times. 84.Sh RETURN VALUES 85.Rv -std clock_getcpuclockid2 86.Pp 87If successful, the 88.Fn clock_getcpuclockid 89function will return 0. 90Otherwise an error number will be returned. 91.Sh ERRORS 92These functions fail if: 93.Bl -tag -width Er 94.It Bq Er EFAULT 95.Fa clock_id 96points outside the process's allocated address space. 97.El 98.Pp 99In addition 100.Fn clock_getcpuclockid2 101will fail if: 102.Bl -tag -width Er 103.It Bq Er EINVAL 104An unsupported 105.Fa idtype 106was supplied. 107.El 108.Sh SEE ALSO 109.Xr clock_gettime 2 110.Sh STANDARDS 111The 112.Fn clock_getcpuclockid 113function conforms to 114.St -p1003.1-2001 . 115The 116.Fn clock_getcpuclockid2 117is a 118.Nx 119extension. 120.Sh HISTORY 121The 122.Fn clock_getcpuclockid 123and 124.Fn clock_getcpuclockid2 125functions appeared in 126.Nx 8 . 127