1
1
//! Compare libc's makedev, major, minor functions against the actual C macros, for various
2
2
//! inputs.
3
3
4
+ #[ cfg( any( target_os = "solaris" , target_os = "illumos" ) ) ]
5
+ mod ret {
6
+ pub type MajorRetType = libc:: major_t ;
7
+ pub type MinorRetType = libc:: minor_t ;
8
+ }
9
+
10
+ #[ cfg( any(
11
+ target_os = "linux" ,
12
+ target_os = "l4re" ,
13
+ target_os = "emscripten" ,
14
+ target_os = "fuchsia" ,
15
+ target_os = "aix" ,
16
+ target_os = "nto" ,
17
+ target_os = "hurd" ,
18
+ target_os = "openbsd" ,
19
+ ) ) ]
20
+ mod ret {
21
+ pub type MajorRetType = libc:: c_uint ;
22
+ pub type MinorRetType = libc:: c_uint ;
23
+ }
24
+
25
+ #[ cfg( any(
26
+ target_os = "android" ,
27
+ target_os = "dragonfly" ,
28
+ target_os = "netbsd" ,
29
+ target_os = "freebsd" ,
30
+ ) ) ]
31
+ mod ret {
32
+ pub type MajorRetType = libc:: c_int ;
33
+ pub type MinorRetType = libc:: c_int ;
34
+ }
35
+
36
+ #[ cfg( any(
37
+ target_os = "macos" ,
38
+ target_os = "ios" ,
39
+ target_os = "tvos" ,
40
+ target_os = "watchos" ,
41
+ target_os = "visionos"
42
+ ) ) ]
43
+ mod ret {
44
+ pub type MajorRetType = i32 ;
45
+ pub type MinorRetType = i32 ;
46
+ }
47
+
4
48
#[ cfg( any(
5
49
target_os = "android" ,
6
50
target_os = "dragonfly" ,
14
58
mod t {
15
59
use libc:: { self , c_uint, dev_t} ;
16
60
61
+ use super :: ret:: * ;
62
+
17
63
extern "C" {
18
64
pub fn makedev_ffi ( major : c_uint , minor : c_uint ) -> dev_t ;
19
65
pub fn major_ffi ( dev : dev_t ) -> c_uint ;
@@ -24,9 +70,9 @@ mod t {
24
70
let dev = unsafe { makedev_ffi ( major, minor) } ;
25
71
assert_eq ! ( libc:: makedev( major, minor) , dev) ;
26
72
let major = unsafe { major_ffi ( dev) } ;
27
- assert_eq ! ( libc:: major( dev) as i64 , major as i64 ) ;
73
+ assert_eq ! ( libc:: major( dev) , major as MajorRetType ) ;
28
74
let minor = unsafe { minor_ffi ( dev) } ;
29
- assert_eq ! ( libc:: minor( dev) as i64 , minor as i64 ) ;
75
+ assert_eq ! ( libc:: minor( dev) , minor as MinorRetType ) ;
30
76
}
31
77
32
78
// Every OS should be able to handle 8 bit major and minor numbers
0 commit comments