FreeBSD: Added xfile structure and file descriptor types#5002
FreeBSD: Added xfile structure and file descriptor types#5002antoncxx wants to merge 1 commit intorust-lang:mainfrom
xfile structure and file descriptor types#5002Conversation
| pub const DTYPE_JAILDESC: c_int = 16; | ||
|
|
||
| s! { | ||
| pub struct xfile { |
There was a problem hiding this comment.
Could this whole struct just be #[cfg(not(any(freebsd10, freebsd11)))]? I don't think we really need the EOL support so that simplifies config.
There was a problem hiding this comment.
Absolutely. I will update the PR tomorrow.
src/new/freebsd/sys/file.rs
Outdated
| #[cfg(any(freebsd13, freebsd14, freebsd15))] | ||
| pub const DTYPE_EVENTFD: c_int = 13; | ||
| #[cfg(any(freebsd10, freebsd11, freebsd12))] | ||
| pub const DTYPE_LINUXEFD: c_int = 13; | ||
| #[cfg(any(freebsd14, freebsd15))] | ||
| pub const DTYPE_TIMERFD: c_int = 14; | ||
| #[cfg(any(freebsd11, freebsd12, freebsd13))] | ||
| pub const DTYPE_LINUXTFD: c_int = 14; | ||
| #[cfg(freebsd15)] | ||
| pub const DTYPE_INOTIFY: c_int = 15; | ||
| #[cfg(freebsd15)] | ||
| pub const DTYPE_JAILDESC: c_int = 16; |
There was a problem hiding this comment.
Similarly, I'd prefer to just drop anything that only exists on EOL versions (<13).
There was a problem hiding this comment.
What's the purpose of this PR? As far as I know, struct xfile is only exposed to the user via the KERN_FILE sysctl. That's fairly obscure. I would be ok if those definitions lived outside of the libc crate. It's up to Trevor if he thinks it's worthwhile to include.
And like Trevor said, you should drop everything related to FreeBSD 10 through12.
The motivation is what you described. I'm involved into development of a Rust library that performs |
| #[cfg(freebsd15)] | ||
| pub const DTYPE_INOTIFY: c_int = 15; |
There was a problem hiding this comment.
Even though DTYPE_INOTIFY didn't exist on FreeBSD 13 and 14, libc doesn't need to worry about that. It's safe to define it here for all versions. It's preferable, even, because that way Rust programs can use it without any special compiler settings for libc. Otherwise it would be off-limits, since libc always uses the FreeBSD 13 ABI. The only symbols that you need to be careful with are symbols that changed between FreeBSD versions, not symbols that got added, like struct kevent.
| #[cfg(freebsd15)] | |
| pub const DTYPE_INOTIFY: c_int = 15; | |
| pub const DTYPE_INOTIFY: c_int = 15; |
| #[cfg(freebsd13)] | ||
| pub const DTYPE_LINUXTFD: c_int = 14; | ||
| #[cfg(any(freebsd14, freebsd15))] | ||
| pub const DTYPE_TIMERFD: c_int = 14; |
There was a problem hiding this comment.
This symbol's name changed in FreeBSD 14, even though it already existed. So you might consider adding the old name as an alias. However, since there is literally zero Rust code already using the old name, it's probably better not to add a symbol that will always be deprecated.
| #[cfg(freebsd13)] | |
| pub const DTYPE_LINUXTFD: c_int = 14; | |
| #[cfg(any(freebsd14, freebsd15))] | |
| pub const DTYPE_TIMERFD: c_int = 14; | |
| pub const DTYPE_TIMERFD: c_int = 14; | |
| #[deprecated(since = "1.0.0", note = "Use DTYPE_TIMERFD instead")] | |
| pub const DTYPE_LINUXTFD: c_int = DTYPE_TIMERFD; |
| #[cfg(freebsd15)] | ||
| pub const DTYPE_JAILDESC: c_int = 16; |
There was a problem hiding this comment.
Just like DTYPE_INOTIFY, you can define this for all FreeBSD versions.
| #[cfg(freebsd15)] | |
| pub const DTYPE_JAILDESC: c_int = 16; | |
| pub const DTYPE_JAILDESC: c_int = 16; |
Description
Added binding for
xfilestructure fromsys/file.hand descriptor types.Sources
FreeBSD 15
FreeBSD 14
FreeBSD 13
FreeBSD 12xfiledescriptorsFreeBSD 11xfiledescriptorsFreeBSD 10xfiledescriptorsChecklist
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