MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / init_from_auxp

Function init_from_auxp

src/backend/linux_raw/param/init.rs:144–175  ·  view source on GitHub ↗

Process auxv entries from the auxv array pointed to by `auxp`. # Safety This must be passed a pointer to an auxv array. The buffer contains `Elf_aux_t` elements, though it need not be aligned; function uses `read_unaligned` to read from it.

(mut auxp: *const Elf_auxv_t)

Source from the content-addressed store, hash-verified

142/// The buffer contains `Elf_aux_t` elements, though it need not be aligned;
143/// function uses `read_unaligned` to read from it.
144unsafe fn init_from_auxp(mut auxp: *const Elf_auxv_t) {
145 loop {
146 let Elf_auxv_t { a_type, a_val } = read(auxp);
147
148 match a_type as _ {
149 AT_PAGESZ => PAGE_SIZE.store(a_val as usize, Ordering::Relaxed),
150 AT_CLKTCK => CLOCK_TICKS_PER_SECOND.store(a_val as usize, Ordering::Relaxed),
151 AT_HWCAP => HWCAP.store(a_val as usize, Ordering::Relaxed),
152 AT_HWCAP2 => HWCAP2.store(a_val as usize, Ordering::Relaxed),
153 AT_MINSIGSTKSZ => MINSIGSTKSZ.store(a_val as usize, Ordering::Relaxed),
154 AT_EXECFN => EXECFN.store(a_val.cast::<c::c_char>(), Ordering::Relaxed),
155 AT_SYSINFO_EHDR => SYSINFO_EHDR.store(a_val.cast::<Elf_Ehdr>(), Ordering::Relaxed),
156
157 #[cfg(feature = "runtime")]
158 AT_SECURE => SECURE.store(a_val as usize != 0, Ordering::Relaxed),
159 #[cfg(feature = "runtime")]
160 AT_PHDR => PHDR.store(a_val.cast::<Elf_Phdr>(), Ordering::Relaxed),
161 #[cfg(feature = "runtime")]
162 AT_PHNUM => PHNUM.store(a_val as usize, Ordering::Relaxed),
163 #[cfg(feature = "runtime")]
164 AT_PHENT => PHENT.store(a_val as usize, Ordering::Relaxed),
165 #[cfg(feature = "runtime")]
166 AT_ENTRY => ENTRY.store(a_val as usize, Ordering::Relaxed),
167 #[cfg(feature = "runtime")]
168 AT_RANDOM => RANDOM.store(a_val.cast::<[u8; 16]>(), Ordering::Relaxed),
169
170 AT_NULL => break,
171 _ => (),
172 }
173 auxp = auxp.add(1);
174 }
175}

Callers 1

init_from_envpFunction · 0.85

Calls 2

addMethod · 0.80
readFunction · 0.50

Tested by

no test coverage detected