Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libc-test/semver/linux-gnu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ STA_PPSWANDER
STA_RONLY
STA_UNSYNC
ST_RELATIME
SUN_LEN
SYSFS_MAGIC
TCA_CHAIN
TCA_DUMP_INVISIBLE
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/linux-musl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ RWF_HIPRI
RWF_NOAPPEND
RWF_NOWAIT
RWF_SYNC
SUN_LEN
USER_PROCESS
UT_HOSTSIZE
UT_LINESIZE
Expand Down
2 changes: 1 addition & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ macro_rules! offset_of {
// SAFETY: computed address is inbounds since we have a stack alloc for T
let fptr = unsafe { core::ptr::addr_of!((*ptr).$field) };
let off = (fptr as usize).checked_sub(ptr as usize).unwrap();
assert!(off <= core::mem::size_of::<$Ty>());
core::assert!(off <= core::mem::size_of::<$Ty>());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you could split macro changes to a separate commit that would be ideal (distinct changes in separate commits makes the backporting easier)

off
}};
}
Expand Down
11 changes: 11 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5877,6 +5877,17 @@ f! {
pub fn ELF64_R_INFO(sym: Elf64_Xword, t: Elf64_Xword) -> Elf64_Xword {
sym << (32 + t)
}

#[cfg(target_env = "gnu")]
#[allow(unused_unsafe)]
pub fn SUN_LEN(s: crate::sockaddr_un) -> usize {
offset_of!(crate::sockaddr_un, sun_path) + crate::strlen(s.sun_path.as_ptr())
}
Comment on lines 5881 to 5884
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add #[allow(unused_unsafe)] in the macro instead? There isn't any unsafe here.


#[cfg(target_env = "musl")]
pub fn SUN_LEN(s: crate::sockaddr_un) -> usize {
2 * crate::strlen(s.sun_path.as_ptr())
}
}

safe_f! {
Expand Down
Loading