1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00

Avoid gettimeofday vsyscall

This commit is contained in:
Ulrich Drepper
2011-09-06 20:22:37 -04:00
parent 42a36f6670
commit d53a73acdb
2 changed files with 8 additions and 19 deletions

View File

@ -1,3 +1,8 @@
2011-09-06 Ulrich Drepper <drepper@gmail.com>
* sysdeps/unix/sysv/linux/getsysstats.c (__get_nprocs): Don't use
gettimeofday vsyscall, just use time.
2011-09-06 Andreas Schwab <schwab@redhat.com> 2011-09-06 Andreas Schwab <schwab@redhat.com>
* sysdeps/unix/sysv/linux/x86_64/gettimeofday.c [!SHARED]: Include * sysdeps/unix/sysv/linux/x86_64/gettimeofday.c [!SHARED]: Include

View File

@ -37,15 +37,6 @@
#include <not-cancel.h> #include <not-cancel.h>
#include <kernel-features.h> #include <kernel-features.h>
#ifndef HAVE_CLOCK_GETTIME_VSYSCALL
# undef INTERNAL_VSYSCALL
# define INTERNAL_VSYSCALL INTERNAL_SYSCALL
# undef INLINE_VSYSCALL
# define INLINE_VSYSCALL INLINE_SYSCALL
#else
# include <bits/libc-vdso.h>
#endif
/* How we can determine the number of available processors depends on /* How we can determine the number of available processors depends on
the configuration. There is currently (as of version 2.0.21) no the configuration. There is currently (as of version 2.0.21) no
@ -141,17 +132,10 @@ __get_nprocs ()
static int cached_result; static int cached_result;
static time_t timestamp; static time_t timestamp;
#ifdef __ASSUME_POSIX_TIMERS time_t now = time (NULL);
struct timespec ts;
INTERNAL_SYSCALL_DECL (err);
INTERNAL_VSYSCALL (clock_gettime, err, 2, CLOCK_REALTIME, &ts);
#else
struct timeval ts;
__gettimeofday (&ts, NULL);
#endif
time_t prev = timestamp; time_t prev = timestamp;
atomic_read_barrier (); atomic_read_barrier ();
if (ts.tv_sec == prev) if (now == prev)
return cached_result; return cached_result;
/* XXX Here will come a test for the new system call. */ /* XXX Here will come a test for the new system call. */
@ -243,7 +227,7 @@ __get_nprocs ()
out: out:
cached_result = result; cached_result = result;
atomic_write_barrier (); atomic_write_barrier ();
timestamp = ts.tv_sec; timestamp = now;
return result; return result;
} }