1*5e0724b3Snjoly /* $NetBSD: clock_getcpuclockid.c,v 1.2 2017/03/04 11:16:33 njoly Exp $ */
2817b192dSchristos
3817b192dSchristos /*-
4817b192dSchristos * Copyright (c) 2016 The NetBSD Foundation, Inc.
5817b192dSchristos * All rights reserved.
6817b192dSchristos *
7817b192dSchristos * This code is derived from software contributed to The NetBSD Foundation
8817b192dSchristos * by Christos Zoulas.
9817b192dSchristos *
10817b192dSchristos * Redistribution and use in source and binary forms, with or without
11817b192dSchristos * modification, are permitted provided that the following conditions
12817b192dSchristos * are met:
13817b192dSchristos * 1. Redistributions of source code must retain the above copyright
14817b192dSchristos * notice, this list of conditions and the following disclaimer.
15817b192dSchristos * 2. Redistributions in binary form must reproduce the above copyright
16817b192dSchristos * notice, this list of conditions and the following disclaimer in the
17817b192dSchristos * documentation and/or other materials provided with the distribution.
18817b192dSchristos *
19817b192dSchristos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20817b192dSchristos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21817b192dSchristos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22817b192dSchristos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23817b192dSchristos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24817b192dSchristos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25817b192dSchristos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26817b192dSchristos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27817b192dSchristos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28817b192dSchristos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29817b192dSchristos * POSSIBILITY OF SUCH DAMAGE.
30817b192dSchristos */
31817b192dSchristos #include <sys/cdefs.h>
32817b192dSchristos #if defined(LIBC_SCCS) && !defined(lint)
33*5e0724b3Snjoly __RCSID("$NetBSD: clock_getcpuclockid.c,v 1.2 2017/03/04 11:16:33 njoly Exp $");
34817b192dSchristos #endif /* LIBC_SCCS and not lint */
35817b192dSchristos
36817b192dSchristos #include <sys/types.h>
37*5e0724b3Snjoly #include <errno.h>
38817b192dSchristos #include <time.h>
39817b192dSchristos
40817b192dSchristos int
clock_getcpuclockid(pid_t pid,clockid_t * clock_id)41817b192dSchristos clock_getcpuclockid(pid_t pid, clockid_t *clock_id)
42817b192dSchristos {
43*5e0724b3Snjoly int error = 0, saved_errno;
44*5e0724b3Snjoly
45*5e0724b3Snjoly saved_errno = errno;
46*5e0724b3Snjoly if (clock_getcpuclockid2(P_PID, (id_t)pid, clock_id) == -1)
47*5e0724b3Snjoly error = errno;
48*5e0724b3Snjoly errno = saved_errno;
49*5e0724b3Snjoly
50*5e0724b3Snjoly return error;
51817b192dSchristos }
52