1177494Sdavidxu/*
2177494Sdavidxu * Copyright (c) 2008 David Xu <davidxu@freebsd.org>
3177494Sdavidxu * All rights reserved.
4177494Sdavidxu *
5177494Sdavidxu * Redistribution and use in source and binary forms, with or without
6177494Sdavidxu * modification, are permitted provided that the following conditions
7177494Sdavidxu * are met:
8177494Sdavidxu * 1. Redistributions of source code must retain the above copyright
9177494Sdavidxu *    notice, this list of conditions and the following disclaimer.
10177494Sdavidxu * 2. Redistributions in binary form must reproduce the above copyright
11177494Sdavidxu *    notice, this list of conditions and the following disclaimer in the
12177494Sdavidxu *    documentation and/or other materials provided with the distribution.
13177494Sdavidxu *
14177494Sdavidxu * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
15177494Sdavidxu * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16177494Sdavidxu * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17177494Sdavidxu * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18177494Sdavidxu * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19177494Sdavidxu * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20177494Sdavidxu * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21177494Sdavidxu * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22177494Sdavidxu * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23177494Sdavidxu * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24177494Sdavidxu * SUCH DAMAGE.
25177494Sdavidxu *
26177494Sdavidxu * $FreeBSD$
27177494Sdavidxu */
28177494Sdavidxu
29177494Sdavidxu#include "namespace.h"
30177494Sdavidxu#include <errno.h>
31177494Sdavidxu#include <pthread.h>
32177494Sdavidxu#include <sys/time.h>
33177494Sdavidxu#include "un-namespace.h"
34177494Sdavidxu
35177494Sdavidxu#include "thr_private.h"
36177494Sdavidxu
37177494Sdavidxu__weak_reference(_pthread_getcpuclockid, pthread_getcpuclockid);
38177494Sdavidxu
39177494Sdavidxuint
40177494Sdavidxu_pthread_getcpuclockid(pthread_t pthread, clockid_t *clock_id)
41177494Sdavidxu{
42239347Sdavidxu
43177494Sdavidxu	if (pthread == NULL)
44177494Sdavidxu		return (EINVAL);
45177494Sdavidxu
46239347Sdavidxu	if (clock_getcpuclockid2(TID(pthread), CPUCLOCK_WHICH_TID, clock_id))
47239347Sdavidxu		return (errno);
48177494Sdavidxu	return (0);
49177494Sdavidxu}
50