@@ -45,94 +45,8 @@ macro_rules! type_alias {
45
45
}
46
46
}
47
47
48
- type_alias ! { "char.md" , c_char = u8 , NonZero_c_char = NonZeroU8 ;
49
- #[ doc( cfg( all( ) ) ) ]
50
- #[ cfg( any(
51
- all(
52
- target_os = "linux" ,
53
- any(
54
- target_arch = "aarch64" ,
55
- target_arch = "arm" ,
56
- target_arch = "hexagon" ,
57
- target_arch = "powerpc" ,
58
- target_arch = "powerpc64" ,
59
- target_arch = "s390x" ,
60
- target_arch = "riscv64" ,
61
- target_arch = "riscv32"
62
- )
63
- ) ,
64
- all( target_os = "android" , any( target_arch = "aarch64" , target_arch = "arm" ) ) ,
65
- all( target_os = "l4re" , target_arch = "x86_64" ) ,
66
- all(
67
- target_os = "freebsd" ,
68
- any(
69
- target_arch = "aarch64" ,
70
- target_arch = "arm" ,
71
- target_arch = "powerpc" ,
72
- target_arch = "powerpc64" ,
73
- target_arch = "riscv64"
74
- )
75
- ) ,
76
- all(
77
- target_os = "netbsd" ,
78
- any( target_arch = "aarch64" , target_arch = "arm" , target_arch = "powerpc" )
79
- ) ,
80
- all( target_os = "openbsd" , target_arch = "aarch64" ) ,
81
- all(
82
- target_os = "vxworks" ,
83
- any(
84
- target_arch = "aarch64" ,
85
- target_arch = "arm" ,
86
- target_arch = "powerpc64" ,
87
- target_arch = "powerpc"
88
- )
89
- ) ,
90
- all( target_os = "fuchsia" , target_arch = "aarch64" )
91
- ) ) ] }
92
- type_alias ! { "char.md" , c_char = i8 , NonZero_c_char = NonZeroI8 ;
93
- #[ doc( cfg( all( ) ) ) ]
94
- #[ cfg( not( any(
95
- all(
96
- target_os = "linux" ,
97
- any(
98
- target_arch = "aarch64" ,
99
- target_arch = "arm" ,
100
- target_arch = "hexagon" ,
101
- target_arch = "powerpc" ,
102
- target_arch = "powerpc64" ,
103
- target_arch = "s390x" ,
104
- target_arch = "riscv64" ,
105
- target_arch = "riscv32"
106
- )
107
- ) ,
108
- all( target_os = "android" , any( target_arch = "aarch64" , target_arch = "arm" ) ) ,
109
- all( target_os = "l4re" , target_arch = "x86_64" ) ,
110
- all(
111
- target_os = "freebsd" ,
112
- any(
113
- target_arch = "aarch64" ,
114
- target_arch = "arm" ,
115
- target_arch = "powerpc" ,
116
- target_arch = "powerpc64" ,
117
- target_arch = "riscv64"
118
- )
119
- ) ,
120
- all(
121
- target_os = "netbsd" ,
122
- any( target_arch = "aarch64" , target_arch = "arm" , target_arch = "powerpc" )
123
- ) ,
124
- all( target_os = "openbsd" , target_arch = "aarch64" ) ,
125
- all(
126
- target_os = "vxworks" ,
127
- any(
128
- target_arch = "aarch64" ,
129
- target_arch = "arm" ,
130
- target_arch = "powerpc64" ,
131
- target_arch = "powerpc"
132
- )
133
- ) ,
134
- all( target_os = "fuchsia" , target_arch = "aarch64" )
135
- ) ) ) ] }
48
+ type_alias ! { "char.md" , c_char = c_char_definition:: c_char, NonZero_c_char = c_char_definition:: NonZero_c_char ;
49
+ #[ doc( cfg( all( ) ) ) ] }
136
50
type_alias ! { "schar.md" , c_schar = i8 , NonZero_c_schar = NonZeroI8 ; }
137
51
type_alias ! { "uchar.md" , c_uchar = u8 , NonZero_c_uchar = NonZeroU8 ; }
138
52
type_alias ! { "short.md" , c_short = i16 , NonZero_c_short = NonZeroI16 ; }
@@ -180,3 +94,58 @@ pub type c_ptrdiff_t = isize;
180
94
/// platforms where this is not the case.
181
95
#[ unstable( feature = "c_size_t" , issue = "88345" ) ]
182
96
pub type c_ssize_t = isize ;
97
+
98
+ mod c_char_definition {
99
+ cfg_if:: cfg_if! {
100
+ // These are the targets on which c_char is unsigned.
101
+ if #[ cfg( any(
102
+ all(
103
+ target_os = "linux" ,
104
+ any(
105
+ target_arch = "aarch64" ,
106
+ target_arch = "arm" ,
107
+ target_arch = "hexagon" ,
108
+ target_arch = "powerpc" ,
109
+ target_arch = "powerpc64" ,
110
+ target_arch = "s390x" ,
111
+ target_arch = "riscv64" ,
112
+ target_arch = "riscv32"
113
+ )
114
+ ) ,
115
+ all( target_os = "android" , any( target_arch = "aarch64" , target_arch = "arm" ) ) ,
116
+ all( target_os = "l4re" , target_arch = "x86_64" ) ,
117
+ all(
118
+ target_os = "freebsd" ,
119
+ any(
120
+ target_arch = "aarch64" ,
121
+ target_arch = "arm" ,
122
+ target_arch = "powerpc" ,
123
+ target_arch = "powerpc64" ,
124
+ target_arch = "riscv64"
125
+ )
126
+ ) ,
127
+ all(
128
+ target_os = "netbsd" ,
129
+ any( target_arch = "aarch64" , target_arch = "arm" , target_arch = "powerpc" )
130
+ ) ,
131
+ all( target_os = "openbsd" , target_arch = "aarch64" ) ,
132
+ all(
133
+ target_os = "vxworks" ,
134
+ any(
135
+ target_arch = "aarch64" ,
136
+ target_arch = "arm" ,
137
+ target_arch = "powerpc64" ,
138
+ target_arch = "powerpc"
139
+ )
140
+ ) ,
141
+ all( target_os = "fuchsia" , target_arch = "aarch64" )
142
+ ) ) ] {
143
+ pub type c_char = u8 ;
144
+ pub type NonZero_c_char = core:: num:: NonZeroU8 ;
145
+ } else {
146
+ // On every other target, c_char is signed.
147
+ pub type c_char = i8 ;
148
+ pub type NonZero_c_char = core:: num:: NonZeroI8 ;
149
+ }
150
+ }
151
+ }
0 commit comments