17
17
core:: sync:: atomic:: Ordering :: Relaxed ,
18
18
} ;
19
19
20
- // `getauxval` wasn't supported in glibc until 2.16. Also this lets us use
21
- // `*mut` as the return type to preserve strict provenance.
22
- #[ cfg( not( feature = "runtime" ) ) ]
23
- weak ! ( fn getauxval( c:: c_ulong) -> * mut c:: c_void) ;
24
-
25
- // With the "runtime" feature, go ahead and depend on `getauxval` existing so
26
- // that we never fail.
27
- #[ cfg( feature = "runtime" ) ]
28
20
extern "C" {
29
21
fn getauxval ( type_ : c:: c_ulong ) -> * mut c:: c_void ;
30
22
}
@@ -99,18 +91,6 @@ pub(crate) fn clock_ticks_per_second() -> u64 {
99
91
#[ cfg( feature = "param" ) ]
100
92
#[ inline]
101
93
pub ( crate ) fn linux_hwcap ( ) -> ( usize , usize ) {
102
- #[ cfg( not( feature = "runtime" ) ) ]
103
- unsafe {
104
- if let Some ( libc_getauxval) = getauxval. get ( ) {
105
- let hwcap = libc_getauxval ( AT_HWCAP ) as usize ;
106
- let hwcap2 = libc_getauxval ( AT_HWCAP2 ) as usize ;
107
- ( hwcap, hwcap2)
108
- } else {
109
- ( 0 , 0 )
110
- }
111
- }
112
-
113
- #[ cfg( feature = "runtime" ) ]
114
94
unsafe {
115
95
let hwcap = getauxval ( AT_HWCAP ) as usize ;
116
96
let hwcap2 = getauxval ( AT_HWCAP2 ) as usize ;
@@ -140,19 +120,7 @@ pub(crate) fn linux_minsigstksz() -> usize {
140
120
#[ cfg( feature = "param" ) ]
141
121
#[ inline]
142
122
pub ( crate ) fn linux_execfn ( ) -> & ' static CStr {
143
- #[ cfg( not( feature = "runtime" ) ) ]
144
- unsafe {
145
- if let Some ( libc_getauxval) = getauxval. get ( ) {
146
- CStr :: from_ptr ( libc_getauxval ( AT_EXECFN ) . cast ( ) )
147
- } else {
148
- cstr ! ( "" )
149
- }
150
- }
151
-
152
- #[ cfg( feature = "runtime" ) ]
153
- unsafe {
154
- CStr :: from_ptr ( getauxval ( AT_EXECFN ) . cast ( ) )
155
- }
123
+ unsafe { CStr :: from_ptr ( getauxval ( AT_EXECFN ) . cast ( ) ) }
156
124
}
157
125
158
126
#[ cfg( feature = "runtime" ) ]
@@ -176,19 +144,7 @@ pub(crate) fn exe_phdrs() -> (*const c::c_void, usize, usize) {
176
144
/// if we don't see it, this function returns a null pointer.
177
145
#[ inline]
178
146
pub ( in super :: super ) fn sysinfo_ehdr ( ) -> * const Elf_Ehdr {
179
- #[ cfg( not( feature = "runtime" ) ) ]
180
- unsafe {
181
- if let Some ( libc_getauxval) = getauxval. get ( ) {
182
- libc_getauxval ( AT_SYSINFO_EHDR ) as * const Elf_Ehdr
183
- } else {
184
- null ( )
185
- }
186
- }
187
-
188
- #[ cfg( feature = "runtime" ) ]
189
- unsafe {
190
- getauxval ( AT_SYSINFO_EHDR ) as * const Elf_Ehdr
191
- }
147
+ unsafe { getauxval ( AT_SYSINFO_EHDR ) as * const Elf_Ehdr }
192
148
}
193
149
194
150
#[ cfg( feature = "runtime" ) ]
@@ -214,7 +170,7 @@ pub(crate) fn vsyscall() -> *const c_void {
214
170
if vsyscall. is_null ( ) {
215
171
#[ cold]
216
172
fn compute_vsyscall ( ) -> * mut c_void {
217
- let vsyscall = unsafe { getauxval ( AT_SYSINFO ) } as * mut c_void ;
173
+ let vsyscall = unsafe { getauxval ( AT_SYSINFO ) as * mut c_void } ;
218
174
VSYSCALL . store ( vsyscall, Relaxed ) ;
219
175
vsyscall
220
176
}
0 commit comments