From 13a9f42818f6b89a72b3e40923be809b490400d8 Mon Sep 17 00:00:00 2001 From: kib Date: Fri, 22 Jun 2012 07:13:30 +0000 Subject: Use struct vdso_timehands data to implement fast gettimeofday(2) and clock_gettime(2) functions if supported. The speedup seen in microbenchmarks is in range 4x-7x depending on the hardware. Only amd64 and i386 architectures are supported. Libc uses rdtsc and kernel data to calculate current time, if enabled by kernel. Hopefully, this code is going to migrate into vdso in some future. Discussed with: bde Reviewed by: jhb Tested by: flo MFC after: 1 month --- lib/libc/gen/aux.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/libc/gen/aux.c') diff --git a/lib/libc/gen/aux.c b/lib/libc/gen/aux.c index 4bf8643..3767ac0 100644 --- a/lib/libc/gen/aux.c +++ b/lib/libc/gen/aux.c @@ -66,6 +66,7 @@ __init_elf_aux_vector(void) 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 @@ init_aux(void) case AT_NCPUS: ncpus = aux->a_un.a_val; break; + + case AT_TIMEKEEP: + timekeep = aux->a_un.a_ptr; + break; } } } @@ -163,6 +168,16 @@ _elf_aux_info(int aux, void *buf, int buflen) } 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; -- cgit v1.1