summaryrefslogtreecommitdiff
path: root/src/unix/bsd/freebsdlike/dragonfly/mod.rs
diff options
context:
space:
mode:
authorAlan Somers <asomers@gmail.com>2022-08-26 14:15:53 -0600
committerAlan Somers <asomers@gmail.com>2022-09-07 06:50:04 -0600
commit5e6d9c4a92fd563f7e2e58a1e2889ccc4a87ff44 (patch)
tree299539f0a439c19986d7a57607d16e0948478671 /src/unix/bsd/freebsdlike/dragonfly/mod.rs
parent75dd59edacd4251a7c9e8e5cc748192adcf708aa (diff)
downloadrust-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/dragonfly/mod.rs')
-rw-r--r--src/unix/bsd/freebsdlike/dragonfly/mod.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs
index df7719b4b9..2935534f0d 100644
--- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs
+++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs
@@ -1571,6 +1571,15 @@ safe_f! {
pub {const} fn WIFSIGNALED(status: ::c_int) -> bool {
(status & 0o177) != 0o177 && (status & 0o177) != 0
}
+
+ pub {const} fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t {
+ let major = major as ::dev_t;
+ let minor = minor as ::dev_t;
+ let mut dev = 0;
+ dev |= major << 8;
+ dev |= minor;
+ dev
+ }
}
extern "C" {