linux_syscalls/env/vdso/
powerpc64.rs1use 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 datapage_offset(&self) -> *const core::ffi::c_void {
27 self.0.datapage_offset
28 }
29
30 #[inline]
31 pub fn get_syscall_map(&self) -> *const core::ffi::c_void {
32 self.0.get_syscall_map
33 }
34
35 #[inline]
36 pub fn get_tbfreq(&self) -> *const core::ffi::c_void {
37 self.0.get_tbfreq
38 }
39
40 #[inline]
41 pub fn getcpu(&self) -> *const core::ffi::c_void {
42 self.0.getcpu
43 }
44
45 #[inline]
46 pub fn gettimeofday(&self) -> *const core::ffi::c_void {
47 self.0.gettimeofday
48 }
49
50 #[inline]
51 pub fn sigtramp_rt64(&self) -> *const core::ffi::c_void {
52 self.0.sigtramp_rt64
53 }
54
55 #[inline]
56 pub fn sigtramp32(&self) -> *const core::ffi::c_void {
57 self.0.sigtramp32
58 }
59
60 #[inline]
61 pub fn sync_dicache(&self) -> *const core::ffi::c_void {
62 self.0.sync_dicache
63 }
64
65 #[inline]
66 pub fn sync_dicache_p5(&self) -> *const core::ffi::c_void {
67 self.0.sync_dicache_p5
68 }
69}
70
71pub(crate) static mut VDSO: UnsafeCell<Vdso> = UnsafeCell::new(Vdso(RawVdso {
72 clock_getres: core::ptr::null(),
73 clock_gettime: core::ptr::null(),
74 datapage_offset: core::ptr::null(),
75 get_syscall_map: core::ptr::null(),
76 get_tbfreq: core::ptr::null(),
77 getcpu: core::ptr::null(),
78 gettimeofday: core::ptr::null(),
79 sigtramp_rt64: core::ptr::null(),
80 sigtramp32: core::ptr::null(),
81 sync_dicache: core::ptr::null(),
82 sync_dicache_p5: core::ptr::null(),
83}));
84
85pub(crate) unsafe fn init() {
86 if let Some(vdso) =
87 crate::env::aux::get::<SysInfoHeader>().and_then(|info| unsafe { RawVdso::from_ptr(info) })
88 {
89 (*VDSO.get()).0 = vdso;
90 }
91}