@@ -1926,6 +1926,54 @@ impl ConversionContext {
19261926 } )
19271927 . unwrap_or ( typ) ;
19281928
1929+ // Other fixed-size types are defined without special compiler involvement, by
1930+ // standard headers and their transitive includes. In these contexts, we
1931+ // recognize these typedefs by the name of the typedef type.
1932+ let id_for_name = |name| -> Option < _ > {
1933+ let kind = match name {
1934+ "intmax_t" => CTypeKind :: IntMax ,
1935+ "uintmax_t" => CTypeKind :: UIntMax ,
1936+ "intptr_t" => CTypeKind :: IntPtr ,
1937+ "uintptr_t" => CTypeKind :: UIntPtr ,
1938+ "__uint8_t" => CTypeKind :: UInt8 ,
1939+ "__uint16_t" => CTypeKind :: UInt16 ,
1940+ "__uint32_t" => CTypeKind :: UInt32 ,
1941+ "__uint64_t" => CTypeKind :: UInt64 ,
1942+ "__uint128_t" => CTypeKind :: UInt128 ,
1943+ "__int8_t" => CTypeKind :: Int8 ,
1944+ "__int16_t" => CTypeKind :: Int16 ,
1945+ "__int32_t" => CTypeKind :: Int32 ,
1946+ "__int64_t" => CTypeKind :: Int64 ,
1947+ "__int128_t" => CTypeKind :: Int128 ,
1948+ _ => {
1949+ log:: debug!( "Unknown fixed-size type typedef {name}!" ) ;
1950+ return None ;
1951+ }
1952+ } ;
1953+ log:: trace!( "Selected kind {kind} for typedef {name}" ) ;
1954+ Some ( CQualTypeId :: new (
1955+ self . typed_context . type_for_kind ( kind) . unwrap ( ) ,
1956+ ) )
1957+ } ;
1958+ let file = self
1959+ . typed_context
1960+ . files
1961+ . get ( self . typed_context . file_map [ node. loc . fileid as usize ] ) ;
1962+ let file = file. unwrap ( ) ;
1963+ if let Some ( path) = file. path . as_ref ( ) {
1964+ if let Some ( filename) = path. file_name ( ) {
1965+ if filename == "stdint.h"
1966+ || filename == "types.h"
1967+ || filename
1968+ . to_str ( )
1969+ . map ( |s| s. starts_with ( "__stddef_" ) )
1970+ . unwrap_or ( false )
1971+ {
1972+ typ = id_for_name ( & * name) . unwrap_or ( typ) ;
1973+ }
1974+ }
1975+ }
1976+
19291977 let typdef_decl = CDeclKind :: Typedef {
19301978 name,
19311979 typ,
0 commit comments