File tree Expand file tree Collapse file tree 7 files changed +29
-10
lines changed Expand file tree Collapse file tree 7 files changed +29
-10
lines changed Original file line number Diff line number Diff line change @@ -152,7 +152,8 @@ pub(super) fn install() {
152152 libc:: sigaltstack ( & alt_stack, ptr:: null_mut ( ) ) ;
153153
154154 let mut sa: libc:: sigaction = mem:: zeroed ( ) ;
155- sa. sa_sigaction = print_stack_trace as libc:: sighandler_t ;
155+ sa. sa_sigaction =
156+ print_stack_trace as unsafe extern "C" fn ( libc:: c_int ) as libc:: sighandler_t ;
156157 sa. sa_flags = libc:: SA_NODEFER | libc:: SA_RESETHAND | libc:: SA_ONSTACK ;
157158 libc:: sigemptyset ( & mut sa. sa_mask ) ;
158159 for ( signum, _signame) in KILL_SIGNALS {
Original file line number Diff line number Diff line change @@ -152,7 +152,10 @@ fn current_dll_path() -> Result<PathBuf, String> {
152152 unsafe {
153153 GetModuleHandleExW (
154154 GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS ,
155- PCWSTR ( current_dll_path as * mut u16 ) ,
155+ PCWSTR (
156+ current_dll_path as fn ( ) -> Result < std:: path:: PathBuf , std:: string:: String >
157+ as * mut u16 ,
158+ ) ,
156159 & mut module,
157160 )
158161 }
Original file line number Diff line number Diff line change @@ -1429,7 +1429,7 @@ pub const fn forget<T: ?Sized>(_: T);
14291429/// // Crucially, we `as`-cast to a raw pointer before `transmute`ing to a function pointer.
14301430/// // This avoids an integer-to-pointer `transmute`, which can be problematic.
14311431/// // Transmuting between raw pointers and function pointers (i.e., two pointer types) is fine.
1432- /// let pointer = foo as *const ();
1432+ /// let pointer = foo as fn() -> i32 as *const ();
14331433/// let function = unsafe {
14341434/// std::mem::transmute::<*const (), fn() -> i32>(pointer)
14351435/// };
Original file line number Diff line number Diff line change @@ -325,9 +325,15 @@ pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
325325 // In any case, we basically need to do something like this until we can
326326 // express more operations in statics (and we may never be able to).
327327 unsafe {
328+ let exception_cleanup_cast = if cfg ! ( target_arch = "x86" ) {
329+ exception_cleanup as unsafe extern "thiscall" fn ( * mut Exception ) as * mut u8
330+ } else {
331+ exception_cleanup as unsafe extern "C" fn ( * mut Exception ) as * mut u8
332+ } ;
333+
328334 atomic_store_seqcst (
329335 ( & raw mut THROW_INFO . pmfnUnwind ) . cast ( ) ,
330- ptr_t:: new ( exception_cleanup as * mut u8 ) . raw ( ) ,
336+ ptr_t:: new ( exception_cleanup_cast ) . raw ( ) ,
331337 ) ;
332338 atomic_store_seqcst (
333339 ( & raw mut THROW_INFO . pCatchableTypeArray ) . cast ( ) ,
@@ -343,7 +349,14 @@ pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
343349 ) ;
344350 atomic_store_seqcst (
345351 ( & raw mut CATCHABLE_TYPE . copyFunction ) . cast ( ) ,
346- ptr_t:: new ( exception_copy as * mut u8 ) . raw ( ) ,
352+ ptr_t:: new (
353+ exception_copy
354+ as unsafe extern "thiscall-unwind" fn (
355+ * mut Exception ,
356+ * mut Exception ,
357+ ) -> * mut Exception as * mut u8 ,
358+ )
359+ . raw ( ) ,
347360 ) ;
348361 }
349362
Original file line number Diff line number Diff line change @@ -293,7 +293,7 @@ impl Backtrace {
293293 if !Backtrace :: enabled ( ) {
294294 return Backtrace { inner : Inner :: Disabled } ;
295295 }
296- Backtrace :: create ( Backtrace :: capture as usize )
296+ Backtrace :: create ( Backtrace :: capture as fn ( ) -> Backtrace as usize )
297297 }
298298
299299 /// Forcibly captures a full backtrace, regardless of environment variable
@@ -309,7 +309,7 @@ impl Backtrace {
309309 #[ stable( feature = "backtrace" , since = "1.65.0" ) ]
310310 #[ inline( never) ] // want to make sure there's a frame here to remove
311311 pub fn force_capture ( ) -> Backtrace {
312- Backtrace :: create ( Backtrace :: force_capture as usize )
312+ Backtrace :: create ( Backtrace :: force_capture as fn ( ) -> Backtrace as usize )
313313 }
314314
315315 /// Forcibly captures a disabled backtrace, regardless of environment
Original file line number Diff line number Diff line change @@ -169,7 +169,9 @@ mod imp {
169169 }
170170
171171 action. sa_flags = SA_SIGINFO | SA_ONSTACK ;
172- action. sa_sigaction = signal_handler as sighandler_t ;
172+ action. sa_sigaction = signal_handler
173+ as unsafe extern "C" fn ( i32 , * mut libc:: siginfo_t , * mut libc:: c_void )
174+ as sighandler_t ;
173175 // SAFETY: only overriding signals if the default is set
174176 unsafe { sigaction ( signal, & action, ptr:: null_mut ( ) ) } ;
175177 }
Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ macro_rules! compat_fn_with_fallback {
155155 /// When that is called it attempts to load the requested symbol.
156156 /// If it succeeds, `PTR` is set to the address of that symbol.
157157 /// If it fails, then `PTR` is set to `fallback`.
158- static PTR : Atomic <* mut c_void> = AtomicPtr :: new( load as * mut _) ;
158+ static PTR : Atomic <* mut c_void> = AtomicPtr :: new( load as unsafe extern "system" fn ( $ ( $argname : $argtype ) , * ) -> $rettype as * mut _) ;
159159
160160 unsafe extern "system" fn load( $( $argname: $argtype) ,* ) -> $rettype {
161161 unsafe {
@@ -171,7 +171,7 @@ macro_rules! compat_fn_with_fallback {
171171 PTR . store( f. as_ptr( ) , Ordering :: Relaxed ) ;
172172 mem:: transmute( f)
173173 } else {
174- PTR . store( fallback as * mut _, Ordering :: Relaxed ) ;
174+ PTR . store( fallback as unsafe extern "system" fn ( $ ( $argname : $argtype ) , * ) -> $rettype as * mut _, Ordering :: Relaxed ) ;
175175 fallback
176176 }
177177 }
You can’t perform that action at this time.
0 commit comments