Conversation
|
Some changes occurred in a NetBSD-like module cc @semarie |
- added `kinfo_pcb` struct and related constants - added `kinfo_file` struct and related constants
just to note that the PR is properly rebased to NetBSD only 👍 |
| impl Eq for __c_anonymous_pcb_sockaddr_src {} | ||
| impl PartialEq for __c_anonymous_pcb_sockaddr_src { | ||
| fn eq(&self, other: &__c_anonymous_pcb_sockaddr_src) -> bool { | ||
| unsafe { self._kis_src == other._kis_src || self._kis_pad == other._kis_pad } | ||
| } | ||
| } | ||
| impl hash::Hash for __c_anonymous_pcb_sockaddr_src { | ||
| fn hash<H: hash::Hasher>(&self, state: &mut H) { | ||
| unsafe { | ||
| self._kis_src.hash(state); | ||
| self._kis_pad.hash(state); | ||
| } | ||
| } | ||
| } | ||
| impl Eq for __c_anonymous_pcb_sockaddr_dst {} | ||
| impl PartialEq for __c_anonymous_pcb_sockaddr_dst { | ||
| fn eq(&self, other: &__c_anonymous_pcb_sockaddr_dst) -> bool { | ||
| unsafe { self._kid_dst == other._kid_dst || self._kid_pad == other._kid_pad } | ||
| } | ||
| } | ||
| impl hash::Hash for __c_anonymous_pcb_sockaddr_dst { | ||
| fn hash<H: hash::Hasher>(&self, state: &mut H) { | ||
| unsafe { | ||
| self._kid_dst.hash(state); | ||
| self._kid_pad.hash(state); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
No more unsound trait impls please. Any new structs containing unions need to be in s_no_extra_traits
| // sys/file.h | ||
| pub const DTYPE_VNODE: c_int = 1; | ||
| pub const DTYPE_SOCKET: c_int = 2; | ||
| pub const DTYPE_PIPE: c_int = 3; | ||
| pub const DTYPE_KQUEUE: c_int = 4; | ||
| pub const DTYPE_MISC: c_int = 5; | ||
| pub const DTYPE_CRYPTO: c_int = 6; | ||
| pub const DTYPE_MQUEUE: c_int = 7; | ||
| pub const DTYPE_SEM: c_int = 8; | ||
| pub const DTYPE_EVENTFD: c_int = 9; | ||
| pub const DTYPE_TIMERFD: c_int = 10; |
There was a problem hiding this comment.
For anything that is a new header, could you instead add it as a new module in https://github.com/rust-lang/libc/blob/0a15ee8898875514c3f1e372d9e2c604ab721d27/src/new/netbsd/sys/mod.rs? We're trying to (slowly) migrate to a new structure
| pub ki_pid: u32, | ||
| pub ki_fd: i32, | ||
| pub ki_ofileflags: u32, | ||
| pub _ki_padto64bits: u32, |
There was a problem hiding this comment.
Padding fields should be private and wrapped in Padding<...>
| impl kinfo_pcb { | ||
| pub unsafe fn ki_src(&self) -> crate::sockaddr { | ||
| self.ki_s._kis_src | ||
| } | ||
|
|
||
| pub unsafe fn ki_dst(&self) -> crate::sockaddr { | ||
| self.ki_d._kid_dst | ||
| } | ||
|
|
||
| pub unsafe fn ki_spad(&self) -> &[c_char; 256 + 8] { | ||
| &self.ki_s._kis_pad | ||
| } | ||
|
|
||
| pub unsafe fn ki_dpad(&self) -> &[c_char; 256 + 8] { | ||
| &self.ki_d._kid_pad | ||
| } | ||
| } |
There was a problem hiding this comment.
I think these can be dropped. It's a bit unfortunate that we can't exactly match the source, but the fields aren't especially useful without *mut T setters (for use via MaybeUninit) which is more API than we provide elsewhere.
|
Reminder, once the PR becomes ready for a review, use |
Description
This PR extends NetBSD support with updates to kernel information structures and file descriptor types.
1. Added
kinfo_pcbPCB_SLOPPCB_ALL2.
kinfo_filestructureKERN_FILE_BYFILEKERN_FILE_BYPIDKERN_FILESLOP3. File descriptor types
DTYPE_VNODEDTYPE_SOCKETDTYPE_PIPEDTYPE_MISCDTYPE_CRYPTODTYPE_MQUEUEDTYPE_SEMDTYPE_EVENTFDDTYPE_TIMERFDSources
Checklist
libc-test/semverhave been updated*LASTor*MAXareincluded (see #3131)
cd libc-test && cargo test --target mytarget);especially relevant for platforms that may not be checked in CI
@rustbot label +stable-nominated
Of all the file descriptor types, I’ve been having trouble with
DTYPE_MEMFD. Even though it exists in the NetBSD source code, the corresponding header on an actual installation seems to be missing this definition. I’m not sure how to handle this properly—whether to ignore it during tests or not include it at all.