Skip to main content

linux_syscalls/env/vdso/
s390x.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 clock_getres(&self) -> *const core::ffi::c_void {
17        self.0.clock_getres
18    }
19
20    #[inline]
21    pub fn clock_gettime(&self) -> *const core::ffi::c_void {
22        self.0.clock_gettime
23    }
24
25    #[inline]
26    pub fn gettimeofday(&self) -> *const core::ffi::c_void {
27        self.0.gettimeofday
28    }
29}
30
31pub(crate) static mut VDSO: UnsafeCell<Vdso> = UnsafeCell::new(Vdso(RawVdso {
32    clock_getres: core::ptr::null(),
33    clock_gettime: core::ptr::null(),
34    gettimeofday: core::ptr::null(),
35}));
36
37pub(crate) unsafe fn init() {
38    if let Some(vdso) =
39        crate::env::aux::get::<SysInfoHeader>().and_then(|info| unsafe { RawVdso::from_ptr(info) })
40    {
41        (*VDSO.get()).0 = vdso;
42    }
43}