@@ -17,84 +17,75 @@ pub type size_t = usize;
17
17
pub type ptrdiff_t = isize ;
18
18
pub type ssize_t = isize ;
19
19
20
- pub const INT_MIN : c_int = -2147483648 ;
21
- pub const INT_MAX : c_int = 2147483647 ;
22
-
23
20
// There are two ways that platforms (in practice) differ in their C types:
24
21
// - chars can either be signed or unsigned
25
22
// - longs can either be 32-bit or 64-bit
26
23
27
24
// Whether chars default to signed or unsigned is primarily determined by
28
25
// architecture (windows is the main exception here).
29
- pub use self :: chars:: * ;
30
- #[ cfg( any(
31
- target_arch = "aarch64" ,
32
- target_arch = "arm" ,
33
- target_arch = "armebv7r" ,
34
- target_arch = "armv5te" ,
35
- target_arch = "armv7" ,
36
- target_arch = "armv7r" ,
37
- target_arch = "armv7s" ,
38
- target_arch = "asmjs" ,
39
- target_arch = "wasm32" ,
40
- target_arch = "wasm64" ,
41
- target_arch = "powerpc" ,
42
- target_arch = "powerpc64" ,
43
- target_arch = "powerpc64le" ,
44
- target_arch = "s390x" ,
45
- target_arch = "thumbv6" ,
46
- target_arch = "thumbv6m" ,
47
- target_arch = "thummv7" ,
48
- target_arch = "thumbv7em" ,
49
- target_arch = "thumbv7m" ,
50
- target_arch = "thumbv7neon" ,
51
- target_arch = "tummbv8" ,
52
- target_arch = "thumbv8m" ,
53
- target_arch = "thumbv8m.main"
54
- ) ) ]
55
- mod chars {
56
- pub type c_char = u8 ;
57
- pub type wchar_t = u32 ;
58
- }
59
-
60
- #[ cfg( any(
61
- target_arch = "i386" ,
62
- target_arch = "i586" ,
63
- target_arch = "i686" ,
64
- target_arch = "x86" ,
65
- target_arch = "x86_64" ,
66
- target_arch = "mips" ,
67
- target_arch = "mips64" ,
68
- target_arch = "mips64el" ,
69
- target_arch = "mipsel" ,
70
- target_arch = "nvptx" ,
71
- target_arch = "nvptx64" ,
72
- target_arch = "sparc64" ,
73
- target_arch = "sparcv9" ,
74
- target_arch = "riscv64" ,
75
- target_arch = "riscv32" ,
76
- target_arch = "riscv32imac" ,
77
- target_arch = "riscv32imc"
78
- ) ) ]
79
- mod chars {
80
- pub type c_char = i8 ;
81
- pub type wchar_t = i32 ;
26
+ cfg_if ! {
27
+ if #[ cfg( any( target_arch = "aarch64" ,
28
+ target_arch = "arm" ,
29
+ target_arch = "armebv7r" ,
30
+ target_arch = "armv5te" ,
31
+ target_arch = "armv7" ,
32
+ target_arch = "armv7r" ,
33
+ target_arch = "armv7s" ,
34
+ target_arch = "asmjs" ,
35
+ target_arch = "wasm32" ,
36
+ target_arch = "wasm64" ,
37
+ target_arch = "powerpc" ,
38
+ target_arch = "powerpc64" ,
39
+ target_arch = "powerpc64le" ,
40
+ target_arch = "s390x" ,
41
+ target_arch = "thumbv6" ,
42
+ target_arch = "thumbv6m" ,
43
+ target_arch = "thummv7" ,
44
+ target_arch = "thumbv7em" ,
45
+ target_arch = "thumbv7m" ,
46
+ target_arch = "thumbv7neon" ,
47
+ target_arch = "tummbv8" ,
48
+ target_arch = "thumbv8m" ,
49
+ target_arch = "thumbv8m.main" ) ) ] {
50
+ pub type c_char = u8 ;
51
+ pub type wchar_t = u32 ;
52
+ } else if #[ cfg( any( target_arch = "i386" ,
53
+ target_arch = "i586" ,
54
+ target_arch = "i686" ,
55
+ target_arch = "x86" ,
56
+ target_arch = "x86_64" ,
57
+ target_arch = "mips" ,
58
+ target_arch = "mips64" ,
59
+ target_arch = "mips64el" ,
60
+ target_arch = "mipsel" ,
61
+ target_arch = "nvptx" ,
62
+ target_arch = "nvptx64" ,
63
+ target_arch = "sparc64" ,
64
+ target_arch = "sparcv9" ,
65
+ target_arch = "riscv64" ,
66
+ target_arch = "riscv32" ,
67
+ target_arch = "riscv32imac" ,
68
+ target_arch = "riscv32imc" ) ) ] {
69
+ pub type c_char = i8 ;
70
+ pub type wchar_t = i32 ;
71
+ }
82
72
}
83
73
84
74
// On all platforms but Windows, longs are the same size as a pointer.
85
- pub use self :: long:: * ;
86
- #[ cfg( target_pointer_width = "64" ) ]
87
- mod long {
88
- pub type c_long = i64 ;
89
- pub type c_ulong = u64 ;
90
- }
91
-
92
- #[ cfg( any( target_pointer_width = "16" , target_pointer_width = "32" ) ) ]
93
- mod long {
94
- pub type c_long = i32 ;
95
- pub type c_ulong = u32 ;
75
+ cfg_if ! {
76
+ if #[ cfg( target_pointer_width = "64" ) ] {
77
+ pub type c_long = i64 ;
78
+ pub type c_ulong = u64 ;
79
+ } else {
80
+ pub type c_long = i32 ;
81
+ pub type c_ulong = u32 ;
82
+ }
96
83
}
97
84
98
85
// POSIX specifications make no guarantees that off_t == long int, but this is
99
86
// what GNU and others always do.
100
87
pub type off_t = :: c_long ;
88
+
89
+ // These follow directly from the definition of c_int
90
+ pub const INT_MIN : c_int = -2147483648 ;
91
+ pub const INT_MAX : c_int = 2147483647 ;
0 commit comments