1717 core:: sync:: atomic:: Ordering :: Relaxed ,
1818} ;
1919
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" ) ]
2820extern "C" {
2921 fn getauxval ( type_ : c:: c_ulong ) -> * mut c:: c_void ;
3022}
@@ -99,18 +91,6 @@ pub(crate) fn clock_ticks_per_second() -> u64 {
9991#[ cfg( feature = "param" ) ]
10092#[ inline]
10193pub ( 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" ) ]
11494 unsafe {
11595 let hwcap = getauxval ( AT_HWCAP ) as usize ;
11696 let hwcap2 = getauxval ( AT_HWCAP2 ) as usize ;
@@ -140,19 +120,7 @@ pub(crate) fn linux_minsigstksz() -> usize {
140120#[ cfg( feature = "param" ) ]
141121#[ inline]
142122pub ( 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 ( ) ) }
156124}
157125
158126#[ cfg( feature = "runtime" ) ]
@@ -176,19 +144,7 @@ pub(crate) fn exe_phdrs() -> (*const c::c_void, usize, usize) {
176144/// if we don't see it, this function returns a null pointer.
177145#[ inline]
178146pub ( 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 }
192148}
193149
194150#[ cfg( feature = "runtime" ) ]
@@ -214,7 +170,7 @@ pub(crate) fn vsyscall() -> *const c_void {
214170 if vsyscall. is_null ( ) {
215171 #[ cold]
216172 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 } ;
218174 VSYSCALL . store ( vsyscall, Relaxed ) ;
219175 vsyscall
220176 }
0 commit comments