Skip to content

Commit

Permalink
Auto merge of #2937 - SteveLauC:add-major-minor-makedev-on-apple-oses…
Browse files Browse the repository at this point in the history
…, 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)))
```
  • Loading branch information
bors committed Oct 2, 2022
2 parents d99a59d + 11a1ffe commit 198beb0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/unix/bsd/apple/mod.rs
Expand Up @@ -4976,6 +4976,18 @@ f! {
pub {const} fn VM_MAKE_TAG(id: u8) -> u32 {
(id as u32) << 24u32
}

pub fn major(dev: dev_t) -> i32 {
(dev >> 24) & 0xff
}

pub fn minor(dev: dev_t) -> i32 {
dev & 0xffffff
}

pub fn makedev(major: i32, minor: i32) -> dev_t {
(major << 24) | minor
}
}

safe_f! {
Expand Down

0 comments on commit 198beb0

Please sign in to comment.