xref: /freebsd/lib/libc/gen/clock_getcpuclockid.c (revision 559a218c9b257775fb249b67945fe4a05b7a6b9f)
1d915a14eSPedro F. Giffuni /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3d915a14eSPedro F. Giffuni  *
4d65f1abcSDavid Xu  * Copyright (c) 2012 David Xu <davidxu@FreeBSD.org>.
5d65f1abcSDavid Xu  * All rights reserved.
6d65f1abcSDavid Xu  *
7d65f1abcSDavid Xu  * Redistribution and use in source and binary forms, with or without
8d65f1abcSDavid Xu  * modification, are permitted provided that the following conditions
9d65f1abcSDavid Xu  * are met:
10d65f1abcSDavid Xu  * 1. Redistributions of source code must retain the above copyright
11d65f1abcSDavid Xu  *    notice, this list of conditions and the following disclaimer.
12d65f1abcSDavid Xu  * 2. Redistributions in binary form must reproduce the above copyright
13d65f1abcSDavid Xu  *    notice, this list of conditions and the following disclaimer in the
14d65f1abcSDavid Xu  *    documentation and/or other materials provided with the distribution.
15d65f1abcSDavid Xu  *
16d65f1abcSDavid Xu  * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS''
17d65f1abcSDavid Xu  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18d65f1abcSDavid Xu  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19d65f1abcSDavid Xu  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20d65f1abcSDavid Xu  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21d65f1abcSDavid Xu  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22d65f1abcSDavid Xu  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23d65f1abcSDavid Xu  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24d65f1abcSDavid Xu  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25d65f1abcSDavid Xu  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26d65f1abcSDavid Xu  * SUCH DAMAGE.
27d65f1abcSDavid Xu  */
28d65f1abcSDavid Xu 
29d65f1abcSDavid Xu #include <errno.h>
30d65f1abcSDavid Xu #include <time.h>
31d65f1abcSDavid Xu #include <unistd.h>
32d65f1abcSDavid Xu #include <sys/time.h>
33d65f1abcSDavid Xu 
34cdfe9026SDavid Xu int
clock_getcpuclockid(pid_t pid,clockid_t * clock_id)35d65f1abcSDavid Xu clock_getcpuclockid(pid_t pid, clockid_t *clock_id)
36d65f1abcSDavid Xu {
37cdfe9026SDavid Xu 	if (clock_getcpuclockid2(pid, CPUCLOCK_WHICH_PID, clock_id))
38cdfe9026SDavid Xu 		return (errno);
39cdfe9026SDavid Xu 	return (0);
40d65f1abcSDavid Xu }
41