diff options
author | Alan Somers <asomers@gmail.com> | 2022-08-26 14:15:53 -0600 |
---|---|---|
committer | Alan Somers <asomers@gmail.com> | 2022-09-07 06:50:04 -0600 |
commit | 5e6d9c4a92fd563f7e2e58a1e2889ccc4a87ff44 (patch) | |
tree | 299539f0a439c19986d7a57607d16e0948478671 /src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs | |
parent | 75dd59edacd4251a7c9e8e5cc748192adcf708aa (diff) | |
download | rust-libc-5e6d9c4a92fd563f7e2e58a1e2889ccc4a87ff44.tar.gz |
Add makedev for the BSDs
Also, make makedev function safe and const on all platforms.
On Android, change the arguments from signed to unsigned integers to
match the other platforms. The C makedev is a macro, so the
signededness is undefined.
Add an integration test for makedev, too, since it's a macro that we
must reimplement.
Diffstat (limited to 'src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs')
-rw-r--r-- | src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs index 1af555fa36..aaa0435847 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -434,6 +434,14 @@ pub const MINCORE_SUPER: ::c_int = 0x20; /// max length of devicename pub const SPECNAMELEN: ::c_int = 63; +safe_f! { + pub {const} fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t { + let major = major as ::dev_t; + let minor = minor as ::dev_t; + (major << 8) | minor + } +} + extern "C" { // Return type ::c_int was removed in FreeBSD 12 pub fn setgrent() -> ::c_int; |