1111
1212use crate :: fmt;
1313use crate :: marker:: PhantomData ;
14- use crate :: num:: * ;
1514use crate :: ops:: { Deref , DerefMut } ;
1615
1716#[ stable( feature = "core_c_str" , since = "1.64.0" ) ]
1817pub use self :: c_str:: { CStr , FromBytesUntilNulError , FromBytesWithNulError } ;
1918
2019mod c_str;
2120
22- macro_rules! type_alias_no_nz {
21+ macro_rules! type_alias {
2322 {
2423 $Docfile: tt, $Alias: ident = $Real: ty;
2524 $( $Cfg: tt ) *
@@ -31,49 +30,24 @@ macro_rules! type_alias_no_nz {
3130 }
3231}
3332
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( ) ) ) ] }
5634
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 ; }
6139
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( ) ) ) ] }
6642
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( ) ) ) ] }
7145
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 ; }
7448
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 ; }
7751
7852/// Equivalent to C's `size_t` type, from `stddef.h` (or `cstddef` for C++).
7953///
@@ -152,11 +126,9 @@ mod c_char_definition {
152126 target_os = "horizon"
153127 ) ) ] {
154128 pub type c_char = u8 ;
155- pub type NonZero_c_char = crate :: num:: NonZeroU8 ;
156129 } else {
157130 // On every other target, c_char is signed.
158131 pub type c_char = i8 ;
159- pub type NonZero_c_char = crate :: num:: NonZeroI8 ;
160132 }
161133 }
162134}
@@ -165,14 +137,10 @@ mod c_int_definition {
165137 cfg_if ! {
166138 if #[ cfg( any( target_arch = "avr" , target_arch = "msp430" ) ) ] {
167139 pub type c_int = i16 ;
168- pub type NonZero_c_int = crate :: num:: NonZeroI16 ;
169140 pub type c_uint = u16 ;
170- pub type NonZero_c_uint = crate :: num:: NonZeroU16 ;
171141 } else {
172142 pub type c_int = i32 ;
173- pub type NonZero_c_int = crate :: num:: NonZeroI32 ;
174143 pub type c_uint = u32 ;
175- pub type NonZero_c_uint = crate :: num:: NonZeroU32 ;
176144 }
177145 }
178146}
@@ -181,15 +149,11 @@ mod c_long_definition {
181149 cfg_if ! {
182150 if #[ cfg( all( target_pointer_width = "64" , not( windows) ) ) ] {
183151 pub type c_long = i64 ;
184- pub type NonZero_c_long = crate :: num:: NonZeroI64 ;
185152 pub type c_ulong = u64 ;
186- pub type NonZero_c_ulong = crate :: num:: NonZeroU64 ;
187153 } else {
188154 // The minimal size of `long` in the C standard is 32 bits
189155 pub type c_long = i32 ;
190- pub type NonZero_c_long = crate :: num:: NonZeroI32 ;
191156 pub type c_ulong = u32 ;
192- pub type NonZero_c_ulong = crate :: num:: NonZeroU32 ;
193157 }
194158 }
195159}
0 commit comments