File tree 2 files changed +15
-2
lines changed 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ pub extern "C" fn ark_trace_back_rs() -> *const ffi::c_char {
73
73
// https://github.com/r-lib/rlang/issues/1059
74
74
unsafe {
75
75
let fun =
76
- libr :: R_GetCCallable ( c"rlang" . as_ptr ( ) , c"rlang_print_backtrace" . as_ptr ( ) ) . unwrap ( ) ;
76
+ get_c_callable_int ( c"rlang" . as_ptr ( ) , c"rlang_print_backtrace" . as_ptr ( ) ) . unwrap ( ) ;
77
77
fun ( 1 ) ;
78
78
} ;
79
79
} )
@@ -184,3 +184,16 @@ pub fn capture_console_output(cb: impl FnOnce()) -> *const ffi::c_char {
184
184
// Intentionally leaks, should only be used in the debugger
185
185
ffi:: CString :: new ( out) . unwrap ( ) . into_raw ( )
186
186
}
187
+
188
+ // Cast `DL_FUNC` to correct function type
189
+ fn get_c_callable_int (
190
+ pkg : * const std:: ffi:: c_char ,
191
+ fun : * const std:: ffi:: c_char ,
192
+ ) -> Option < unsafe extern "C-unwind" fn ( std:: ffi:: c_int ) -> * mut std:: ffi:: c_void > {
193
+ unsafe {
194
+ std:: mem:: transmute :: <
195
+ Option < unsafe extern "C-unwind" fn ( ) -> * mut std:: ffi:: c_void > ,
196
+ Option < unsafe extern "C-unwind" fn ( std:: ffi:: c_int ) -> * mut std:: ffi:: c_void > ,
197
+ > ( libr:: R_GetCCallable ( pkg, fun) )
198
+ }
199
+ }
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ functions::generate! {
42
42
) -> std:: ffi:: c_int;
43
43
44
44
pub fn R_GetCCallable ( pkg: * const std:: ffi:: c_char, fun: * const std:: ffi:: c_char) ->
45
- Option < unsafe extern "C-unwind" fn ( std :: ffi :: c_int ) -> * mut std :: ffi :: c_void> ;
45
+ DL_FUNC ;
46
46
47
47
pub fn vmaxget( ) -> * mut std:: ffi:: c_void;
48
48
You can’t perform that action at this time.
0 commit comments