summaryrefslogtreecommitdiffhomepage
path: root/vdso/vdso.cc
diff options
context:
space:
mode:
authorHaibo Xu <haibo.xu@arm.com>2019-04-18 16:20:45 -0700
committerShentubot <shentubot@google.com>2019-04-18 16:22:08 -0700
commitf4d434c18002c96511decf8ff1ebdbede46ca6a1 (patch)
treecc781d877ef0ea64ce33c46d6a30b76eefa4753a /vdso/vdso.cc
parentc931c8e0829914718a729e20d7db0c2bf4e73f0b (diff)
Enable vDSO support on arm64.
Signed-off-by: Haibo Xu <haibo.xu@arm.com> Change-Id: I20103cd6d193431ab7e8120005da1f567b9bc2eb PiperOrigin-RevId: 244280119
Diffstat (limited to 'vdso/vdso.cc')
-rw-r--r--vdso/vdso.cc65
1 files changed, 59 insertions, 6 deletions
diff --git a/vdso/vdso.cc b/vdso/vdso.cc
index f30dc26a2..550729035 100644
--- a/vdso/vdso.cc
+++ b/vdso/vdso.cc
@@ -23,9 +23,9 @@
#include "vdso/vdso_time.h"
namespace vdso {
+namespace {
-// __vdso_clock_gettime() implements clock_gettime()
-extern "C" int __vdso_clock_gettime(clockid_t clock, struct timespec* ts) {
+int __common_clock_gettime(clockid_t clock, struct timespec* ts) {
int ret;
switch (clock) {
@@ -44,11 +44,8 @@ extern "C" int __vdso_clock_gettime(clockid_t clock, struct timespec* ts) {
return ret;
}
-extern "C" int clock_gettime(clockid_t clock, struct timespec* ts)
- __attribute__((weak, alias("__vdso_clock_gettime")));
-// __vdso_gettimeofday() implements gettimeofday()
-extern "C" int __vdso_gettimeofday(struct timeval* tv, struct timezone* tz) {
+int __common_gettimeofday(struct timeval* tv, struct timezone* tz) {
if (tv) {
struct timespec ts;
int ret = ClockRealtime(&ts);
@@ -68,6 +65,21 @@ extern "C" int __vdso_gettimeofday(struct timeval* tv, struct timezone* tz) {
return 0;
}
+} // namespace
+
+#if __x86_64__
+
+// __vdso_clock_gettime() implements clock_gettime()
+extern "C" int __vdso_clock_gettime(clockid_t clock, struct timespec* ts) {
+ return __common_clock_gettime(clock, ts);
+}
+extern "C" int clock_gettime(clockid_t clock, struct timespec* ts)
+ __attribute__((weak, alias("__vdso_clock_gettime")));
+
+// __vdso_gettimeofday() implements gettimeofday()
+extern "C" int __vdso_gettimeofday(struct timeval* tv, struct timezone* tz) {
+ return __common_gettimeofday(tv, tz);
+}
extern "C" int gettimeofday(struct timeval* tv, struct timezone* tz)
__attribute__((weak, alias("__vdso_gettimeofday")));
@@ -92,4 +104,45 @@ extern "C" long getcpu(unsigned* cpu, unsigned* node,
struct getcpu_cache* cache)
__attribute__((weak, alias("__vdso_getcpu")));
+#elif __aarch64__
+
+// __kernel_clock_gettime() implements clock_gettime()
+extern "C" int __kernel_clock_gettime(clockid_t clock, struct timespec* ts) {
+ return __common_clock_gettime(clock, ts);
+}
+
+// __kernel_gettimeofday() implements gettimeofday()
+extern "C" int __kernel_gettimeofday(struct timeval* tv, struct timezone* tz) {
+ return __common_gettimeofday(tv, tz);
+}
+
+// __kernel_clock_getres() implements clock_getres()
+extern "C" int __kernel_clock_getres(clockid_t clock, struct timespec* res) {
+ int ret = 0;
+
+ switch (clock) {
+ case CLOCK_REALTIME:
+ case CLOCK_MONOTONIC: {
+ res->tv_sec = 0;
+ res->tv_nsec = 1;
+ break;
+ }
+
+ default:
+ ret = sys_clock_getres(clock, res);
+ break;
+ }
+
+ return ret;
+}
+
+// __kernel_rt_sigreturn() implements gettimeofday()
+extern "C" int __kernel_rt_sigreturn(unsigned long unused) {
+ // No optimizations yet, just make the real system call.
+ return sys_rt_sigreturn();
+}
+
+#else
+#error "unsupported architecture"
+#endif
} // namespace vdso