11
11
12
12
use crate :: fmt;
13
13
use crate :: marker:: PhantomData ;
14
- use crate :: num:: * ;
15
14
use crate :: ops:: { Deref , DerefMut } ;
16
15
17
16
#[ stable( feature = "core_c_str" , since = "1.64.0" ) ]
18
17
pub use self :: c_str:: { CStr , FromBytesUntilNulError , FromBytesWithNulError } ;
19
18
20
19
mod c_str;
21
20
22
- macro_rules! type_alias_no_nz {
21
+ macro_rules! type_alias {
23
22
{
24
23
$Docfile: tt, $Alias: ident = $Real: ty;
25
24
$( $Cfg: tt ) *
@@ -31,49 +30,24 @@ macro_rules! type_alias_no_nz {
31
30
}
32
31
}
33
32
34
- // To verify that the NonZero types in this file's macro invocations correspond
35
- //
36
- // perl -n < library/std/src/os/raw/mod.rs -e 'next unless m/type_alias\!/; die "$_ ?" unless m/, (c_\w+) = (\w+), NonZero_(\w+) = NonZero(\w+)/; die "$_ ?" unless $3 eq $1 and $4 eq ucfirst $2'
37
- //
38
- // NB this does not check that the main c_* types are right.
39
-
40
- macro_rules! type_alias {
41
- {
42
- $Docfile: tt, $Alias: ident = $Real: ty, $NZAlias: ident = $NZReal: ty;
43
- $( $Cfg: tt ) *
44
- } => {
45
- type_alias_no_nz! { $Docfile, $Alias = $Real; $( $Cfg ) * }
46
-
47
- #[ doc = concat!( "Type alias for `NonZero` version of [`" , stringify!( $Alias) , "`]" ) ]
48
- #[ unstable( feature = "raw_os_nonzero" , issue = "82363" ) ]
49
- $( $Cfg ) *
50
- pub type $NZAlias = $NZReal;
51
- }
52
- }
53
-
54
- type_alias ! { "c_char.md" , c_char = c_char_definition:: c_char, NonZero_c_char = c_char_definition:: NonZero_c_char ;
55
- #[ doc( cfg( all( ) ) ) ] }
33
+ type_alias ! { "c_char.md" , c_char = c_char_definition:: c_char; #[ doc( cfg( all( ) ) ) ] }
56
34
57
- type_alias ! { "c_schar.md" , c_schar = i8 , NonZero_c_schar = NonZeroI8 ; }
58
- type_alias ! { "c_uchar.md" , c_uchar = u8 , NonZero_c_uchar = NonZeroU8 ; }
59
- type_alias ! { "c_short.md" , c_short = i16 , NonZero_c_short = NonZeroI16 ; }
60
- type_alias ! { "c_ushort.md" , c_ushort = u16 , NonZero_c_ushort = NonZeroU16 ; }
35
+ type_alias ! { "c_schar.md" , c_schar = i8 ; }
36
+ type_alias ! { "c_uchar.md" , c_uchar = u8 ; }
37
+ type_alias ! { "c_short.md" , c_short = i16 ; }
38
+ type_alias ! { "c_ushort.md" , c_ushort = u16 ; }
61
39
62
- type_alias ! { "c_int.md" , c_int = c_int_definition:: c_int, NonZero_c_int = c_int_definition:: NonZero_c_int ;
63
- #[ doc( cfg( all( ) ) ) ] }
64
- type_alias ! { "c_uint.md" , c_uint = c_int_definition:: c_uint, NonZero_c_uint = c_int_definition:: NonZero_c_uint ;
65
- #[ doc( cfg( all( ) ) ) ] }
40
+ type_alias ! { "c_int.md" , c_int = c_int_definition:: c_int; #[ doc( cfg( all( ) ) ) ] }
41
+ type_alias ! { "c_uint.md" , c_uint = c_int_definition:: c_uint; #[ doc( cfg( all( ) ) ) ] }
66
42
67
- type_alias ! { "c_long.md" , c_long = c_long_definition:: c_long, NonZero_c_long = c_long_definition:: NonZero_c_long ;
68
- #[ doc( cfg( all( ) ) ) ] }
69
- type_alias ! { "c_ulong.md" , c_ulong = c_long_definition:: c_ulong, NonZero_c_ulong = c_long_definition:: NonZero_c_ulong ;
70
- #[ doc( cfg( all( ) ) ) ] }
43
+ type_alias ! { "c_long.md" , c_long = c_long_definition:: c_long; #[ doc( cfg( all( ) ) ) ] }
44
+ type_alias ! { "c_ulong.md" , c_ulong = c_long_definition:: c_ulong; #[ doc( cfg( all( ) ) ) ] }
71
45
72
- type_alias ! { "c_longlong.md" , c_longlong = i64 , NonZero_c_longlong = NonZeroI64 ; }
73
- type_alias ! { "c_ulonglong.md" , c_ulonglong = u64 , NonZero_c_ulonglong = NonZeroU64 ; }
46
+ type_alias ! { "c_longlong.md" , c_longlong = i64 ; }
47
+ type_alias ! { "c_ulonglong.md" , c_ulonglong = u64 ; }
74
48
75
- type_alias_no_nz ! { "c_float.md" , c_float = f32 ; }
76
- type_alias_no_nz ! { "c_double.md" , c_double = f64 ; }
49
+ type_alias ! { "c_float.md" , c_float = f32 ; }
50
+ type_alias ! { "c_double.md" , c_double = f64 ; }
77
51
78
52
/// Equivalent to C's `size_t` type, from `stddef.h` (or `cstddef` for C++).
79
53
///
@@ -152,11 +126,9 @@ mod c_char_definition {
152
126
target_os = "horizon"
153
127
) ) ] {
154
128
pub type c_char = u8 ;
155
- pub type NonZero_c_char = crate :: num:: NonZeroU8 ;
156
129
} else {
157
130
// On every other target, c_char is signed.
158
131
pub type c_char = i8 ;
159
- pub type NonZero_c_char = crate :: num:: NonZeroI8 ;
160
132
}
161
133
}
162
134
}
@@ -165,14 +137,10 @@ mod c_int_definition {
165
137
cfg_if ! {
166
138
if #[ cfg( any( target_arch = "avr" , target_arch = "msp430" ) ) ] {
167
139
pub type c_int = i16 ;
168
- pub type NonZero_c_int = crate :: num:: NonZeroI16 ;
169
140
pub type c_uint = u16 ;
170
- pub type NonZero_c_uint = crate :: num:: NonZeroU16 ;
171
141
} else {
172
142
pub type c_int = i32 ;
173
- pub type NonZero_c_int = crate :: num:: NonZeroI32 ;
174
143
pub type c_uint = u32 ;
175
- pub type NonZero_c_uint = crate :: num:: NonZeroU32 ;
176
144
}
177
145
}
178
146
}
@@ -181,15 +149,11 @@ mod c_long_definition {
181
149
cfg_if ! {
182
150
if #[ cfg( all( target_pointer_width = "64" , not( windows) ) ) ] {
183
151
pub type c_long = i64 ;
184
- pub type NonZero_c_long = crate :: num:: NonZeroI64 ;
185
152
pub type c_ulong = u64 ;
186
- pub type NonZero_c_ulong = crate :: num:: NonZeroU64 ;
187
153
} else {
188
154
// The minimal size of `long` in the C standard is 32 bits
189
155
pub type c_long = i32 ;
190
- pub type NonZero_c_long = crate :: num:: NonZeroI32 ;
191
156
pub type c_ulong = u32 ;
192
- pub type NonZero_c_ulong = crate :: num:: NonZeroU32 ;
193
157
}
194
158
}
195
159
}
0 commit comments