thr_getcpuclockid.c revision 302408
1138269Snik/* 2138269Snik * Copyright (c) 2008 David Xu <davidxu@freebsd.org> 3138269Snik * All rights reserved. 4138269Snik * 5138269Snik * Redistribution and use in source and binary forms, with or without 6138269Snik * modification, are permitted provided that the following conditions 7138269Snik * are met: 8138269Snik * 1. Redistributions of source code must retain the above copyright 9138269Snik * notice, this list of conditions and the following disclaimer. 10138269Snik * 2. Redistributions in binary form must reproduce the above copyright 11138269Snik * notice, this list of conditions and the following disclaimer in the 12138269Snik * documentation and/or other materials provided with the distribution. 13138269Snik * 14138269Snik * THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND 15138269Snik * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16138269Snik * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17138269Snik * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18138269Snik * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19138269Snik * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20138269Snik * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21138269Snik * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22138269Snik * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23138269Snik * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24138269Snik * SUCH DAMAGE. 25138269Snik */ 26138269Snik 27138269Snik#include <sys/cdefs.h> 28138269Snik__FBSDID("$FreeBSD: stable/11/lib/libthr/thread/thr_getcpuclockid.c 297706 2016-04-08 11:15:26Z kib $"); 29138269Snik 30138269Snik#include "namespace.h" 31138269Snik#include <errno.h> 32138269Snik#include <pthread.h> 33138269Snik#include <sys/time.h> 34138269Snik#include "un-namespace.h" 35138269Snik 36138269Snik#include "thr_private.h" 37138269Snik 38222485Srwatson__weak_reference(_pthread_getcpuclockid, pthread_getcpuclockid); 39138269Snik 40138269Snikint 41138269Snik_pthread_getcpuclockid(pthread_t pthread, clockid_t *clock_id) 42138269Snik{ 43138269Snik 44138269Snik if (pthread == NULL) 45138269Snik return (EINVAL); 46138269Snik 47138269Snik if (clock_getcpuclockid2(TID(pthread), CPUCLOCK_WHICH_TID, clock_id)) 48138269Snik return (errno); 49138269Snik return (0); 50138269Snik} 51138269Snik