linux_syscalls/env/vdso/
x86.rs

1use core::cell::UnsafeCell;
2
3use crate::env::aux::SysInfoHeader;
4
5pub use linux_raw_vdso::Vdso as RawVdso;
6
7#[non_exhaustive]
8#[repr(transparent)]
9pub struct Vdso(pub(crate) RawVdso);
10
11unsafe impl Send for Vdso {}
12unsafe impl Sync for Vdso {}
13
14impl Vdso {
15    #[inline]
16    pub fn sigreturn(&self) -> *const core::ffi::c_void {
17        self.0.sigreturn
18    }
19
20    #[inline]
21    pub fn rt_sigreturn(&self) -> *const core::ffi::c_void {
22        self.0.rt_sigreturn
23    }
24
25    #[inline]
26    pub fn vsyscall(&self) -> *const core::ffi::c_void {
27        self.0.vsyscall
28    }
29
30    #[inline]
31    pub fn clock_gettime(&self) -> *const core::ffi::c_void {
32        self.0.clock_gettime
33    }
34
35    #[inline]
36    pub fn gettimeofday(&self) -> *const core::ffi::c_void {
37        self.0.gettimeofday
38    }
39
40    #[inline]
41    pub fn time(&self) -> *const core::ffi::c_void {
42        self.0.time
43    }
44
45    #[inline]
46    pub fn clock_getres(&self) -> *const core::ffi::c_void {
47        self.0.clock_getres
48    }
49
50    #[inline]
51    pub fn clock_gettime64(&self) -> *const core::ffi::c_void {
52        self.0.clock_gettime64
53    }
54
55    #[inline]
56    pub fn getcpu(&self) -> *const core::ffi::c_void {
57        self.0.getcpu
58    }
59}
60
61pub(crate) static mut VDSO: UnsafeCell<Vdso> = UnsafeCell::new(Vdso(RawVdso {
62    sigreturn: core::ptr::null(),
63    rt_sigreturn: core::ptr::null(),
64    vsyscall: core::ptr::null(),
65    clock_gettime: core::ptr::null(),
66    gettimeofday: core::ptr::null(),
67    time: core::ptr::null(),
68    clock_getres: core::ptr::null(),
69    clock_gettime64: core::ptr::null(),
70    getcpu: core::ptr::null(),
71}));
72
73pub(crate) unsafe fn quasi_init() {
74    if let Some(vdso) =
75        crate::env::aux::get::<SysInfoHeader>().and_then(|info| unsafe { RawVdso::from_ptr(info) })
76    {
77        (*VDSO.get()).0 = vdso;
78    }
79}
80
81pub(crate) unsafe fn init() {}