Skip to content

Commit 198beb0

Browse files
committed
Auto merge of #2937 - SteveLauC:add-major-minor-makedev-on-apple-oses, r=JohnTitor
add major/minor/makedev on apple OSes This impl corresponds to the macros in [`sys/types.h`](https://opensource.apple.com/source/xnu/xnu-7195.81.3/bsd/sys/types.h.auto.html): ```c #define major(x) ((int32_t)(((u_int32_t)(x) >> 24) & 0xff)) #define minor(x) ((int32_t)((x) & 0xffffff)) #define makedev(x, y) ((dev_t)(((x) << 24) | (y))) ```
2 parents d99a59d + 11a1ffe commit 198beb0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/unix/bsd/apple/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4976,6 +4976,18 @@ f! {
49764976
pub {const} fn VM_MAKE_TAG(id: u8) -> u32 {
49774977
(id as u32) << 24u32
49784978
}
4979+
4980+
pub fn major(dev: dev_t) -> i32 {
4981+
(dev >> 24) & 0xff
4982+
}
4983+
4984+
pub fn minor(dev: dev_t) -> i32 {
4985+
dev & 0xffffff
4986+
}
4987+
4988+
pub fn makedev(major: i32, minor: i32) -> dev_t {
4989+
(major << 24) | minor
4990+
}
49794991
}
49804992

49814993
safe_f! {

0 commit comments

Comments
 (0)