• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #[cfg(not(all(target_os = "android", target_pointer_width = "32")))]
2 use super::super::c;
3 use crate::fs::Dev;
4 
5 #[cfg(not(any(target_os = "android", target_os = "emscripten")))]
6 #[inline]
makedev(maj: u32, min: u32) -> Dev7 pub(crate) fn makedev(maj: u32, min: u32) -> Dev {
8     c::makedev(maj, min)
9 }
10 
11 #[cfg(all(target_os = "android", not(target_pointer_width = "32")))]
12 #[inline]
makedev(maj: u32, min: u32) -> Dev13 pub(crate) fn makedev(maj: u32, min: u32) -> Dev {
14     // Android's `makedev` oddly has signed argument types.
15     c::makedev(maj, min)
16 }
17 
18 #[cfg(all(target_os = "android", target_pointer_width = "32"))]
19 #[inline]
makedev(maj: u32, min: u32) -> Dev20 pub(crate) fn makedev(maj: u32, min: u32) -> Dev {
21     // 32-bit Android's `dev_t` is 32-bit, but its `st_dev` is 64-bit,
22     // so we do it ourselves.
23     ((u64::from(maj) & 0xffff_f000_u64) << 32)
24         | ((u64::from(maj) & 0x0000_0fff_u64) << 8)
25         | ((u64::from(min) & 0xffff_ff00_u64) << 12)
26         | (u64::from(min) & 0x0000_00ff_u64)
27 }
28 
29 #[cfg(target_os = "emscripten")]
30 #[inline]
makedev(maj: u32, min: u32) -> Dev31 pub(crate) fn makedev(maj: u32, min: u32) -> Dev {
32     // Emscripten's `makedev` has a 32-bit return value.
33     Dev::from(c::makedev(maj, min))
34 }
35 
36 #[cfg(not(any(target_os = "android", target_os = "emscripten")))]
37 #[inline]
major(dev: Dev) -> u3238 pub(crate) fn major(dev: Dev) -> u32 {
39     unsafe { c::major(dev) }
40 }
41 
42 #[cfg(all(target_os = "android", not(target_pointer_width = "32")))]
43 #[inline]
major(dev: Dev) -> u3244 pub(crate) fn major(dev: Dev) -> u32 {
45     // Android's `major` oddly has signed return types.
46     (unsafe { c::major(dev) }) as u32
47 }
48 
49 #[cfg(all(target_os = "android", target_pointer_width = "32"))]
50 #[inline]
major(dev: Dev) -> u3251 pub(crate) fn major(dev: Dev) -> u32 {
52     // 32-bit Android's `dev_t` is 32-bit, but its `st_dev` is 64-bit,
53     // so we do it ourselves.
54     (((dev >> 31 >> 1) & 0xffff_f000) | ((dev >> 8) & 0x0000_0fff)) as u32
55 }
56 
57 #[cfg(target_os = "emscripten")]
58 #[inline]
major(dev: Dev) -> u3259 pub(crate) fn major(dev: Dev) -> u32 {
60     // Emscripten's `major` has a 32-bit argument value.
61     unsafe { c::major(dev as u32) }
62 }
63 
64 #[cfg(not(any(target_os = "android", target_os = "emscripten")))]
65 #[inline]
minor(dev: Dev) -> u3266 pub(crate) fn minor(dev: Dev) -> u32 {
67     unsafe { c::minor(dev) }
68 }
69 
70 #[cfg(all(target_os = "android", not(target_pointer_width = "32")))]
71 #[inline]
minor(dev: Dev) -> u3272 pub(crate) fn minor(dev: Dev) -> u32 {
73     // Android's `minor` oddly has signed return types.
74     (unsafe { c::minor(dev) }) as u32
75 }
76 
77 #[cfg(all(target_os = "android", target_pointer_width = "32"))]
78 #[inline]
minor(dev: Dev) -> u3279 pub(crate) fn minor(dev: Dev) -> u32 {
80     // 32-bit Android's `dev_t` is 32-bit, but its `st_dev` is 64-bit,
81     // so we do it ourselves.
82     (((dev >> 12) & 0xffff_ff00) | (dev & 0x0000_00ff)) as u32
83 }
84 
85 #[cfg(target_os = "emscripten")]
86 #[inline]
minor(dev: Dev) -> u3287 pub(crate) fn minor(dev: Dev) -> u32 {
88     // Emscripten's `minor` has a 32-bit argument value.
89     unsafe { c::minor(dev as u32) }
90 }
91