[Midnightbsd-cvs] src [8105] trunk/lib/libc: use struct vdso_timehads data to implement fast gettimeofday(2) and clock_gettime(2) functions if supported.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Thu Sep 15 19:19:31 EDT 2016


Revision: 8105
          http://svnweb.midnightbsd.org/src/?rev=8105
Author:   laffer1
Date:     2016-09-15 19:19:31 -0400 (Thu, 15 Sep 2016)
Log Message:
-----------
use struct vdso_timehads data to implement fast gettimeofday(2) and clock_gettime(2) functions if supported.

Modified Paths:
--------------
    trunk/lib/libc/amd64/sys/Makefile.inc
    trunk/lib/libc/gen/aux.c
    trunk/lib/libc/i386/sys/Makefile.inc
    trunk/lib/libc/include/libc_private.h
    trunk/lib/libc/sys/Makefile.inc

Added Paths:
-----------
    trunk/lib/libc/amd64/sys/__vdso_gettc.c
    trunk/lib/libc/i386/sys/__vdso_gettc.c
    trunk/lib/libc/sys/__vdso_gettimeofday.c
    trunk/lib/libc/sys/clock_gettime.c
    trunk/lib/libc/sys/gettimeofday.c

Modified: trunk/lib/libc/amd64/sys/Makefile.inc
===================================================================
--- trunk/lib/libc/amd64/sys/Makefile.inc	2016-09-15 23:15:24 UTC (rev 8104)
+++ trunk/lib/libc/amd64/sys/Makefile.inc	2016-09-15 23:19:31 UTC (rev 8105)
@@ -1,7 +1,8 @@
 #	from: Makefile.inc,v 1.1 1993/09/03 19:04:23 jtc Exp
 # $MidnightBSD$
 
-SRCS+=	amd64_get_fsbase.c amd64_get_gsbase.c amd64_set_fsbase.c amd64_set_gsbase.c
+SRCS+=	amd64_get_fsbase.c amd64_get_gsbase.c amd64_set_fsbase.c \
+	amd64_set_gsbase.c __vdso_gettc.c
 
 MDASM=	vfork.S brk.S cerror.S exect.S getcontext.S pipe.S ptrace.S \
 	reboot.S sbrk.S setlogin.S sigreturn.S

Added: trunk/lib/libc/amd64/sys/__vdso_gettc.c
===================================================================
--- trunk/lib/libc/amd64/sys/__vdso_gettc.c	                        (rev 0)
+++ trunk/lib/libc/amd64/sys/__vdso_gettc.c	2016-09-15 23:19:31 UTC (rev 8105)
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 2012 Konstantin Belousov <kib at FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+#include <machine/cpufunc.h>
+
+static u_int
+__vdso_gettc_low(const struct vdso_timehands *th)
+{
+	uint32_t rv;
+
+	__asm __volatile("rdtsc; shrd %%cl, %%edx, %0"
+	    : "=a" (rv) : "c" (th->th_x86_shift) : "edx");
+	return (rv);
+}
+
+u_int
+__vdso_gettc(const struct vdso_timehands *th)
+{
+
+	return (th->th_x86_shift > 0 ? __vdso_gettc_low(th) : rdtsc32());
+}


Property changes on: trunk/lib/libc/amd64/sys/__vdso_gettc.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/libc/gen/aux.c
===================================================================
--- trunk/lib/libc/gen/aux.c	2016-09-15 23:15:24 UTC (rev 8104)
+++ trunk/lib/libc/gen/aux.c	2016-09-15 23:19:31 UTC (rev 8105)
@@ -66,6 +66,7 @@
 static pthread_once_t aux_once = PTHREAD_ONCE_INIT;
 static int pagesize, osreldate, canary_len, ncpus, pagesizes_len;
 static char *canary, *pagesizes;
+static void *timekeep;
 
 static void
 init_aux(void)
@@ -101,6 +102,10 @@
 		case AT_NCPUS:
 			ncpus = aux->a_un.a_val;
 			break;
+
+		case AT_TIMEKEEP:
+			timekeep = aux->a_un.a_ptr;
+			break;
 		}
 	}
 }
@@ -163,6 +168,16 @@
 		} else
 			res = EINVAL;
 		break;
+	case AT_TIMEKEEP:
+		if (buflen == sizeof(void *)) {
+			if (timekeep != NULL) {
+				*(void **)buf = timekeep;
+				res = 0;
+			} else
+				res = ENOENT;
+		} else
+			res = EINVAL;
+		break;
 	default:
 		res = ENOENT;
 		break;

Modified: trunk/lib/libc/i386/sys/Makefile.inc
===================================================================
--- trunk/lib/libc/i386/sys/Makefile.inc	2016-09-15 23:15:24 UTC (rev 8104)
+++ trunk/lib/libc/i386/sys/Makefile.inc	2016-09-15 23:19:31 UTC (rev 8105)
@@ -5,7 +5,8 @@
 SRCS+=	i386_clr_watch.c i386_set_watch.c i386_vm86.c
 .endif
 SRCS+=	i386_get_fsbase.c i386_get_gsbase.c i386_get_ioperm.c i386_get_ldt.c \
-	i386_set_fsbase.c i386_set_gsbase.c i386_set_ioperm.c i386_set_ldt.c
+	i386_set_fsbase.c i386_set_gsbase.c i386_set_ioperm.c i386_set_ldt.c \
+	__vdso_gettc.c
 
 MDASM=	Ovfork.S brk.S cerror.S exect.S getcontext.S pipe.S ptrace.S \
 	reboot.S sbrk.S setlogin.S sigreturn.S syscall.S

Added: trunk/lib/libc/i386/sys/__vdso_gettc.c
===================================================================
--- trunk/lib/libc/i386/sys/__vdso_gettc.c	                        (rev 0)
+++ trunk/lib/libc/i386/sys/__vdso_gettc.c	2016-09-15 23:19:31 UTC (rev 8105)
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 2012 Konstantin Belousov <kib at FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+#include <machine/cpufunc.h>
+
+static u_int
+__vdso_gettc_low(const struct vdso_timehands *th)
+{
+	uint32_t rv;
+
+	__asm __volatile("rdtsc; shrd %%cl, %%edx, %0"
+	    : "=a" (rv) : "c" (th->th_x86_shift) : "edx");
+	return (rv);
+}
+
+#pragma weak __vdso_gettc
+u_int
+__vdso_gettc(const struct vdso_timehands *th)
+{
+
+	return (th->th_x86_shift > 0 ? __vdso_gettc_low(th) : rdtsc32());
+}


Property changes on: trunk/lib/libc/i386/sys/__vdso_gettc.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/lib/libc/include/libc_private.h
===================================================================
--- trunk/lib/libc/include/libc_private.h	2016-09-15 23:15:24 UTC (rev 8104)
+++ trunk/lib/libc/include/libc_private.h	2016-09-15 23:19:31 UTC (rev 8105)
@@ -34,6 +34,7 @@
 
 #ifndef _LIBC_PRIVATE_H_
 #define _LIBC_PRIVATE_H_
+#include <sys/_types.h>
 #include <sys/_pthreadtypes.h>
 
 /*
@@ -245,6 +246,12 @@
 /* Without back-compat translation */
 extern int	__sys_fcntl(int, int, ...);
 
+struct timespec;
+struct timeval;
+struct timezone;
+int	__sys_gettimeofday(struct timeval *, struct timezone *);
+int	__sys_clock_gettime(__clockid_t, struct timespec *ts);
+
 /* execve() with PATH processing to implement posix_spawnp() */
 int _execvpe(const char *, char * const *, char * const *);
 

Modified: trunk/lib/libc/sys/Makefile.inc
===================================================================
--- trunk/lib/libc/sys/Makefile.inc	2016-09-15 23:15:24 UTC (rev 8104)
+++ trunk/lib/libc/sys/Makefile.inc	2016-09-15 23:19:31 UTC (rev 8105)
@@ -15,6 +15,10 @@
 #
 .sinclude "${.CURDIR}/${LIBC_ARCH}/sys/Makefile.inc"
 
+SRCS+= clock_gettime.c gettimeofday.c __vdso_gettimeofday.c
+NOASM+=  clock_gettime.o gettimeofday.o
+PSEUDO+= _clock_gettime.o _gettimeofday.o
+
 # Sources common to both syscall interfaces:
 SRCS+=	stack_protector.c stack_protector_compat.c __error.c
 .if !defined(WITHOUT_SYSCALL_COMPAT)

Added: trunk/lib/libc/sys/__vdso_gettimeofday.c
===================================================================
--- trunk/lib/libc/sys/__vdso_gettimeofday.c	                        (rev 0)
+++ trunk/lib/libc/sys/__vdso_gettimeofday.c	2016-09-15 23:19:31 UTC (rev 8105)
@@ -0,0 +1,142 @@
+/*-
+ * Copyright (c) 2012 Konstantin Belousov <kib at FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/elf.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+#include <errno.h>
+#include <time.h>
+#include <machine/atomic.h>
+#include "libc_private.h"
+
+static u_int
+tc_delta(const struct vdso_timehands *th)
+{
+
+	return ((__vdso_gettc(th) - th->th_offset_count) &
+	    th->th_counter_mask);
+}
+
+static int
+binuptime(struct bintime *bt, struct vdso_timekeep *tk, int abs)
+{
+	struct vdso_timehands *th;
+	uint32_t curr, gen;
+
+	do {
+		if (!tk->tk_enabled)
+			return (ENOSYS);
+
+		/*
+		 * XXXKIB. The load of tk->tk_current should use
+		 * atomic_load_acq_32 to provide load barrier. But
+		 * since tk points to r/o mapped page, x86
+		 * implementation of atomic_load_acq faults.
+		 */
+		curr = tk->tk_current;
+		rmb();
+		th = &tk->tk_th[curr];
+		if (th->th_algo != VDSO_TH_ALGO_1)
+			return (ENOSYS);
+		gen = th->th_gen;
+		*bt = th->th_offset;
+		bintime_addx(bt, th->th_scale * tc_delta(th));
+		if (abs)
+			bintime_add(bt, &th->th_boottime);
+
+		/*
+		 * Barrier for load of both tk->tk_current and th->th_gen.
+		 */
+		rmb();
+	} while (curr != tk->tk_current || gen == 0 || gen != th->th_gen);
+	return (0);
+}
+
+static struct vdso_timekeep *tk;
+
+int
+__vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+	struct bintime bt;
+	int error;
+
+	if (tz != NULL)
+		return (ENOSYS);
+	if (tk == NULL) {
+		error = _elf_aux_info(AT_TIMEKEEP, &tk, sizeof(tk));
+		if (error != 0 || tk == NULL)
+			return (ENOSYS);
+	}
+	if (tk->tk_ver != VDSO_TK_VER_CURR)
+		return (ENOSYS);
+	error = binuptime(&bt, tk, 1);
+	if (error != 0)
+		return (error);
+	bintime2timeval(&bt, tv);
+	return (0);
+}
+
+int
+__vdso_clock_gettime(clockid_t clock_id, struct timespec *ts)
+{
+	struct bintime bt;
+	int abs, error;
+
+	if (tk == NULL) {
+		error = _elf_aux_info(AT_TIMEKEEP, &tk, sizeof(tk));
+		if (error != 0 || tk == NULL)
+			return (ENOSYS);
+	}
+	if (tk->tk_ver != VDSO_TK_VER_CURR)
+		return (ENOSYS);
+	switch (clock_id) {
+	case CLOCK_REALTIME:
+	case CLOCK_REALTIME_PRECISE:
+	case CLOCK_REALTIME_FAST:
+	case CLOCK_SECOND:
+		abs = 1;
+		break;
+	case CLOCK_MONOTONIC:
+	case CLOCK_MONOTONIC_PRECISE:
+	case CLOCK_MONOTONIC_FAST:
+	case CLOCK_UPTIME:
+	case CLOCK_UPTIME_PRECISE:
+	case CLOCK_UPTIME_FAST:
+		abs = 0;
+		break;
+	default:
+		return (ENOSYS);
+	}
+	error = binuptime(&bt, tk, abs);
+	if (error != 0)
+		return (error);
+	bintime2timespec(&bt, ts);
+	if (clock_id == CLOCK_SECOND)
+		ts->tv_nsec = 0;
+	return (0);
+}


Property changes on: trunk/lib/libc/sys/__vdso_gettimeofday.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/libc/sys/clock_gettime.c
===================================================================
--- trunk/lib/libc/sys/clock_gettime.c	                        (rev 0)
+++ trunk/lib/libc/sys/clock_gettime.c	2016-09-15 23:19:31 UTC (rev 8105)
@@ -0,0 +1,52 @@
+/*-
+ * Copyright (c) 2012 Konstantin Belousov <kib at FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/syscall.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+#include <errno.h>
+#include <time.h>
+#include "libc_private.h"
+
+int __clock_gettime(clockid_t, struct timespec *ts);
+
+__weak_reference(__clock_gettime, clock_gettime);
+
+int
+__clock_gettime(clockid_t clock_id, struct timespec *ts)
+{
+	int error;
+
+	if (__vdso_clock_gettime != NULL && __vdso_gettc != NULL)
+		error = __vdso_clock_gettime(clock_id, ts);
+	else
+		error = ENOSYS;
+	if (error == ENOSYS)
+		error = __sys_clock_gettime(clock_id, ts);
+	return (error);
+}


Property changes on: trunk/lib/libc/sys/clock_gettime.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/lib/libc/sys/gettimeofday.c
===================================================================
--- trunk/lib/libc/sys/gettimeofday.c	                        (rev 0)
+++ trunk/lib/libc/sys/gettimeofday.c	2016-09-15 23:19:31 UTC (rev 8105)
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 2012 Konstantin Belousov <kib at FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/syscall.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+#include <errno.h>
+#include "libc_private.h"
+
+int __gettimeofday(struct timeval *tv, struct timezone *tz);
+
+__weak_reference(__gettimeofday, gettimeofday);
+
+int
+__gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+	int error;
+
+	if (__vdso_gettimeofday != NULL && __vdso_gettc != NULL)
+		error = __vdso_gettimeofday(tv, tz);
+	else
+		error = ENOSYS;
+	if (error == ENOSYS)
+		error = __sys_gettimeofday(tv, tz);
+	return (error);
+}


Property changes on: trunk/lib/libc/sys/gettimeofday.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property


More information about the Midnightbsd-cvs mailing list