@@ -22,7 +22,7 @@ pub(crate) mod _struct {
2222 use std:: convert:: TryFrom ;
2323 use std:: io:: { Cursor , Read , Write } ;
2424 use std:: iter:: Peekable ;
25- use std:: { fmt, mem} ;
25+ use std:: { fmt, mem, os :: raw } ;
2626
2727 use crate :: builtins:: {
2828 bytes:: PyBytesRef , float:: IntoPyFloat , int:: try_to_primitive, pybool:: IntoPyBool ,
@@ -83,11 +83,14 @@ pub(crate) mod _struct {
8383 }
8484 }
8585
86+ type PackFunc = fn ( & VirtualMachine , & PyObjectRef , & mut dyn Write ) -> PyResult < ( ) > ;
87+ type UnpackFunc = fn ( & VirtualMachine , & mut dyn Read ) -> PyResult ;
88+
8689 struct FormatInfo {
8790 size : usize ,
8891 align : usize ,
89- pack : Option < fn ( & VirtualMachine , & PyObjectRef , & mut dyn Write ) -> PyResult < ( ) > > ,
90- unpack : Option < fn ( & VirtualMachine , & mut dyn Read ) -> PyResult > ,
92+ pack : Option < PackFunc > ,
93+ unpack : Option < UnpackFunc > ,
9194 }
9295 impl fmt:: Debug for FormatInfo {
9396 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
@@ -155,33 +158,33 @@ pub(crate) mod _struct {
155158 match e {
156159 Endianness :: Native => match self {
157160 Pad | Str | Pascal => & FormatInfo {
158- size : size_of :: < libc :: c_char > ( ) ,
161+ size : size_of :: < raw :: c_char > ( ) ,
159162 align : 0 ,
160163 pack : None ,
161164 unpack : None ,
162165 } ,
163- SByte => native_info ! ( libc :: c_schar) ,
164- UByte => native_info ! ( libc :: c_uchar) ,
166+ SByte => native_info ! ( raw :: c_schar) ,
167+ UByte => native_info ! ( raw :: c_uchar) ,
165168 Char => & FormatInfo {
166- size : size_of :: < libc :: c_char > ( ) ,
169+ size : size_of :: < raw :: c_char > ( ) ,
167170 align : 0 ,
168171 pack : Some ( pack_char) ,
169172 unpack : Some ( unpack_char) ,
170173 } ,
171- Short => native_info ! ( libc :: c_short) ,
172- UShort => native_info ! ( libc :: c_ushort) ,
173- Int => native_info ! ( libc :: c_int) ,
174- UInt => native_info ! ( libc :: c_uint) ,
175- Long => native_info ! ( libc :: c_long) ,
176- ULong => native_info ! ( libc :: c_ulong) ,
177- SSizeT => native_info ! ( libc :: ssize_t ) ,
178- SizeT => native_info ! ( libc :: size_t ) ,
179- LongLong => native_info ! ( libc :: c_longlong) ,
180- ULongLong => native_info ! ( libc :: c_ulonglong) ,
174+ Short => native_info ! ( raw :: c_short) ,
175+ UShort => native_info ! ( raw :: c_ushort) ,
176+ Int => native_info ! ( raw :: c_int) ,
177+ UInt => native_info ! ( raw :: c_uint) ,
178+ Long => native_info ! ( raw :: c_long) ,
179+ ULong => native_info ! ( raw :: c_ulong) ,
180+ SSizeT => native_info ! ( isize ) , // ssize_t == isize
181+ SizeT => native_info ! ( usize ) , // size_t == usize
182+ LongLong => native_info ! ( raw :: c_longlong) ,
183+ ULongLong => native_info ! ( raw :: c_ulonglong) ,
181184 Bool => native_info ! ( bool ) ,
182- Float => native_info ! ( libc :: c_float) ,
183- Double => native_info ! ( libc :: c_double) ,
184- VoidP => native_info ! ( * mut libc :: c_void) ,
185+ Float => native_info ! ( raw :: c_float) ,
186+ Double => native_info ! ( raw :: c_double) ,
187+ VoidP => native_info ! ( * mut raw :: c_void) ,
185188 } ,
186189 Endianness :: Big => match_nonnative ! ( self , byteorder:: BigEndian ) ,
187190 Endianness :: Little => match_nonnative ! ( self , byteorder:: LittleEndian ) ,
@@ -564,7 +567,7 @@ pub(crate) mod _struct {
564567 make_pack_with_endianess ! ( f32 , get_float) ;
565568 make_pack_with_endianess ! ( f64 , get_float) ;
566569
567- impl Packable for * mut libc :: c_void {
570+ impl Packable for * mut raw :: c_void {
568571 fn pack < Endianness : ByteOrder > (
569572 vm : & VirtualMachine ,
570573 arg : & PyObjectRef ,
0 commit comments