@@ -30,12 +30,6 @@ use core::mem;
3030use core:: ptr;
3131use core:: slice;
3232
33- // This is used when we're double-checking function signatures against windows-sys.
34- #[ inline( always) ]
35- fn assert_equal_types < T > ( a : T , _b : T ) -> T {
36- a
37- }
38-
3933// This macro is used to define a `Dbghelp` structure which internally contains
4034// all the function pointers that we might load.
4135macro_rules! dbghelp {
@@ -85,14 +79,23 @@ macro_rules! dbghelp {
8579 // either read the cached function pointer or load it and return the
8680 // loaded value. Loads are asserted to succeed.
8781 $( pub fn $name( & mut self ) -> Option <$name> {
82+ // Assert that windows_sys::$name is declared to have the same
83+ // argument types and return type as our declaration, although
84+ // it might be either extern "C" or extern "system".
85+ cfg_if:: cfg_if! {
86+ if #[ cfg( any( target_arch = "x86" , not( windows_raw_dylib) ) ) ] {
87+ let _: unsafe extern "system" fn ( $( $argty) ,* ) -> $ret = super :: windows_sys:: $name;
88+ } else {
89+ let _: unsafe extern "C" fn ( $( $argty) ,* ) -> $ret = super :: windows_sys:: $name;
90+ }
91+ }
92+
8893 unsafe {
8994 if self . $name == 0 {
9095 let name = concat!( stringify!( $name) , "\0 " ) ;
9196 self . $name = self . symbol( name. as_bytes( ) ) ?;
9297 }
93- let ret = mem:: transmute:: <usize , $name>( self . $name) ;
94- assert_equal_types( ret, super :: windows_sys:: $name) ;
95- Some ( ret)
98+ Some ( mem:: transmute:: <usize , $name>( self . $name) )
9699 }
97100 } ) *
98101
0 commit comments