@@ -30,12 +30,6 @@ use core::mem;
30
30
use core:: ptr;
31
31
use core:: slice;
32
32
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
-
39
33
// This macro is used to define a `Dbghelp` structure which internally contains
40
34
// all the function pointers that we might load.
41
35
macro_rules! dbghelp {
@@ -85,14 +79,23 @@ macro_rules! dbghelp {
85
79
// either read the cached function pointer or load it and return the
86
80
// loaded value. Loads are asserted to succeed.
87
81
$( 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
+
88
93
unsafe {
89
94
if self . $name == 0 {
90
95
let name = concat!( stringify!( $name) , "\0 " ) ;
91
96
self . $name = self . symbol( name. as_bytes( ) ) ?;
92
97
}
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) )
96
99
}
97
100
} ) *
98
101
0 commit comments