relibc/header/sys_un/mod.rs
1//! `sys/un.h` implementation.
2//!
3//! See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_un.h.html>.
4
5use crate::{header::bits_safamily_t::sa_family_t, platform::types::c_char};
6
7/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_un.h.html>.
8///
9/// # Implementation
10/// Size of `sun_path` is `108` bytes.
11#[repr(C)]
12pub struct sockaddr_un {
13 /// Address family.
14 pub sun_family: sa_family_t,
15 /// Socket pathname storage.
16 pub sun_path: [c_char; 108],
17}
18
19impl sockaddr_un {
20 pub fn path_offset(&self) -> usize {
21 let base = core::ptr::from_ref(self) as usize;
22 let path = &raw const self.sun_path as usize;
23 log::trace!("base: {:#X}, path: {:#X}", base, path);
24 path - base
25 }
26}