Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/arch/x86/um/vdso/um_vdso.c
52395 views
1
// SPDX-License-Identifier: GPL-2.0-only
2
/*
3
* Copyright (C) 2011 Richard Weinberger <[email protected]>
4
*
5
* This vDSO turns all calls into a syscall so that UML can trap them.
6
*/
7
8
9
/* Disable profiling for userspace code */
10
#define DISABLE_BRANCH_PROFILING
11
12
#include <vdso/gettime.h>
13
#include <linux/time.h>
14
#include <asm/unistd.h>
15
16
int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts)
17
{
18
long ret;
19
20
asm("syscall"
21
: "=a" (ret)
22
: "0" (__NR_clock_gettime), "D" (clock), "S" (ts)
23
: "rcx", "r11", "memory");
24
25
return ret;
26
}
27
int clock_gettime(clockid_t, struct __kernel_timespec *)
28
__attribute__((weak, alias("__vdso_clock_gettime")));
29
30
int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
31
{
32
long ret;
33
34
asm("syscall"
35
: "=a" (ret)
36
: "0" (__NR_gettimeofday), "D" (tv), "S" (tz)
37
: "rcx", "r11", "memory");
38
39
return ret;
40
}
41
int gettimeofday(struct __kernel_old_timeval *, struct timezone *)
42
__attribute__((weak, alias("__vdso_gettimeofday")));
43
44
__kernel_old_time_t __vdso_time(__kernel_old_time_t *t)
45
{
46
long secs;
47
48
asm volatile("syscall"
49
: "=a" (secs)
50
: "0" (__NR_time), "D" (t) : "cc", "r11", "cx", "memory");
51
52
return secs;
53
}
54
__kernel_old_time_t time(__kernel_old_time_t *t) __attribute__((weak, alias("__vdso_time")));
55
56