1120386Ssam/*- 2120386Ssam * Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.org> 360317Sdarrenr * 4139823Simp * Redistribution and use in source and binary forms, with or without 560317Sdarrenr * modification, are permitted provided that the following conditions 660317Sdarrenr * are met: 760317Sdarrenr * 1. Redistributions of source code must retain the above copyright 860317Sdarrenr * notice, this list of conditions and the following disclaimer. 960317Sdarrenr * 2. Redistributions in binary form must reproduce the above copyright 1060317Sdarrenr * notice, this list of conditions and the following disclaimer in the 1160317Sdarrenr * documentation and/or other materials provided with the distribution. 1260317Sdarrenr * 1360317Sdarrenr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1460317Sdarrenr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1560317Sdarrenr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1660317Sdarrenr * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1760317Sdarrenr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1860317Sdarrenr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1960317Sdarrenr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2060317Sdarrenr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2160317Sdarrenr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2260317Sdarrenr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2360317Sdarrenr * SUCH DAMAGE. 2460317Sdarrenr */ 2560317Sdarrenr 2660317Sdarrenr#include <sys/cdefs.h> 2760317Sdarrenr__FBSDID("$FreeBSD$"); 2860317Sdarrenr 2960317Sdarrenr#include <sys/syscall.h> 3060317Sdarrenr#include <sys/time.h> 3160317Sdarrenr#include <sys/vdso.h> 3260317Sdarrenr#include <errno.h> 3360317Sdarrenr#include <time.h> 3460317Sdarrenr#include "libc_private.h" 35120386Ssam 36130731Sbdeint __clock_gettime(clockid_t, struct timespec *ts); 37120386Ssam 38120386Ssam__weak_reference(__clock_gettime, clock_gettime); 39155226Scsjp 40173904Smlaierint 4160317Sdarrenr__clock_gettime(clockid_t clock_id, struct timespec *ts) 4260317Sdarrenr{ 4360317Sdarrenr int error; 44135920Smlaier 4560317Sdarrenr if (__vdso_clock_gettime != NULL && __vdso_gettc != NULL) 46254769Sandre error = __vdso_clock_gettime(clock_id, ts); 47254769Sandre else 48254769Sandre error = ENOSYS; 4960317Sdarrenr if (error == ENOSYS) 5060317Sdarrenr error = __sys_clock_gettime(clock_id, ts); 51254773Sandre return (error); 52254773Sandre} 5360317Sdarrenr