Merge "Fix vdso system call fallback failures."

am: 7d5777ef15

Change-Id: Id21c390ae782cac39e98a4a3e01cfae73b214578
This commit is contained in:
Elliott Hughes 2017-11-28 19:14:15 +00:00 committed by android-build-merger
commit a034ba2d34

View file

@ -26,11 +26,18 @@
#include <unistd.h>
#include "private/KernelArgumentBlock.h"
static inline int vdso_return(int result) {
if (__predict_true(result == 0)) return 0;
errno = -result;
return -1;
}
int clock_gettime(int clock_id, timespec* tp) {
auto vdso_clock_gettime = reinterpret_cast<decltype(&clock_gettime)>(
__libc_globals->vdso[VDSO_CLOCK_GETTIME].fn);
if (__predict_true(vdso_clock_gettime)) {
return vdso_clock_gettime(clock_id, tp);
return vdso_return(vdso_clock_gettime(clock_id, tp));
}
return __clock_gettime(clock_id, tp);
}
@ -39,17 +46,15 @@ int gettimeofday(timeval* tv, struct timezone* tz) {
auto vdso_gettimeofday = reinterpret_cast<decltype(&gettimeofday)>(
__libc_globals->vdso[VDSO_GETTIMEOFDAY].fn);
if (__predict_true(vdso_gettimeofday)) {
return vdso_gettimeofday(tv, tz);
return vdso_return(vdso_gettimeofday(tv, tz));
}
return __gettimeofday(tv, tz);
}
void __libc_init_vdso(libc_globals* globals, KernelArgumentBlock& args) {
auto&& vdso = globals->vdso;
vdso[VDSO_CLOCK_GETTIME] = { VDSO_CLOCK_GETTIME_SYMBOL,
reinterpret_cast<void*>(__clock_gettime) };
vdso[VDSO_GETTIMEOFDAY] = { VDSO_GETTIMEOFDAY_SYMBOL,
reinterpret_cast<void*>(__gettimeofday) };
vdso[VDSO_CLOCK_GETTIME] = { VDSO_CLOCK_GETTIME_SYMBOL, nullptr };
vdso[VDSO_GETTIMEOFDAY] = { VDSO_GETTIMEOFDAY_SYMBOL, nullptr };
// Do we have a vdso?
uintptr_t vdso_ehdr_addr = args.getauxval(AT_SYSINFO_EHDR);