More fixes for 32bit

This commit is contained in:
Andrzej Janik 2021-04-09 22:00:23 +02:00
parent 9dcfb45aa2
commit 8393dbd6e9
5 changed files with 320 additions and 320 deletions

View file

@ -1,3 +1,3 @@
bindgen /usr/local/cuda/include/cuda.h -o cuda.rs --whitelist-function="^cu.*" --size_t-is-usize --default-enum-style=newtype --no-layout-tests --no-doc-comments --no-derive-debug --new-type-alias "^CUdevice$|^CUdeviceptr$"
sed -i -e 's/extern "C" {//g' -e 's/-> CUresult;/-> CUresult { impl_::unsupported()/g' -e 's/pub fn /#[no_mangle] pub extern "C" fn /g' cuda.rs
sed -i -e 's/extern "C" {//g' -e 's/-> CUresult;/-> CUresult { impl_::unsupported()/g' -e 's/pub fn /#[no_mangle] pub extern "system" fn /g' cuda.rs
rustfmt cuda.rs

File diff suppressed because it is too large Load diff

View file

@ -88,7 +88,7 @@ pub struct ContextData {
pub cuda_manager: *mut cuda_impl::rt::ContextStateManager,
pub cuda_state: *mut cuda_impl::rt::ContextState,
pub cuda_dtor_cb: Option<
extern "C" fn(
extern "system" fn(
CUcontext,
*mut cuda_impl::rt::ContextStateManager,
*mut cuda_impl::rt::ContextState,

View file

@ -68,14 +68,14 @@ static TOOLS_RUNTIME_CALLBACK_HOOKS_VTABLE: [VTableEntry; TOOLS_RUNTIME_CALLBACK
];
static mut TOOLS_RUNTIME_CALLBACK_HOOKS_FN1_SPACE: [usize; 512] = [0; 512];
unsafe extern "C" fn runtime_callback_hooks_fn1(ptr: *mut *mut usize, size: *mut usize) {
unsafe extern "system" fn runtime_callback_hooks_fn1(ptr: *mut *mut usize, size: *mut usize) {
*ptr = TOOLS_RUNTIME_CALLBACK_HOOKS_FN1_SPACE.as_mut_ptr();
*size = TOOLS_RUNTIME_CALLBACK_HOOKS_FN1_SPACE.len();
}
static mut TOOLS_RUNTIME_CALLBACK_HOOKS_FN5_SPACE: [u8; 2] = [0; 2];
unsafe extern "C" fn runtime_callback_hooks_fn5(ptr: *mut *mut u8, size: *mut usize) -> *mut u8 {
unsafe extern "system" fn runtime_callback_hooks_fn5(ptr: *mut *mut u8, size: *mut usize) -> *mut u8 {
*ptr = TOOLS_RUNTIME_CALLBACK_HOOKS_FN5_SPACE.as_mut_ptr();
*size = TOOLS_RUNTIME_CALLBACK_HOOKS_FN5_SPACE.len();
return TOOLS_RUNTIME_CALLBACK_HOOKS_FN5_SPACE.as_mut_ptr();
@ -110,7 +110,7 @@ static CUDART_INTERFACE_VTABLE: [VTableEntry; CUDART_INTERFACE_LENGTH] = [
VTableEntry { ptr: ptr::null() },
];
unsafe extern "C" fn cudart_interface_fn1(pctx: *mut CUcontext, dev: CUdevice) -> CUresult {
unsafe extern "system" fn cudart_interface_fn1(pctx: *mut CUcontext, dev: CUdevice) -> CUresult {
cudart_interface_fn1_impl(pctx.decuda(), dev.decuda()).encuda()
}
@ -195,7 +195,7 @@ struct FatbinFileHeader {
uncompressed_payload: c_ulong,
}
unsafe extern "C" fn get_module_from_cubin(
unsafe extern "system" fn get_module_from_cubin(
result: *mut CUmodule,
fatbinc_wrapper: *const FatbincWrapper,
ptr1: *mut c_void,
@ -290,7 +290,7 @@ unsafe fn decompress_kernel_module(file: *const FatbinFileHeader) -> Option<Vec<
}
}
unsafe extern "C" fn cudart_interface_fn6(_: u64) {}
unsafe extern "system" fn cudart_interface_fn6(_: u64) {}
const TOOLS_TLS_GUID: CUuuid = CUuuid {
bytes: [
@ -321,13 +321,13 @@ static CONTEXT_LOCAL_STORAGE_INTERFACE_V0301_VTABLE: [VTableEntry; 4] = [
];
// some kind of ctor
unsafe extern "C" fn context_local_storage_ctor(
unsafe extern "system" fn context_local_storage_ctor(
cu_ctx: CUcontext, // always zero
mgr: *mut cuda_impl::rt::ContextStateManager,
ctx_state: *mut cuda_impl::rt::ContextState,
// clsContextDestroyCallback, have to be called on cuDevicePrimaryCtxReset
dtor_cb: Option<
extern "C" fn(
extern "system" fn(
CUcontext,
*mut cuda_impl::rt::ContextStateManager,
*mut cuda_impl::rt::ContextState,
@ -342,7 +342,7 @@ fn context_local_storage_ctor_impl(
mgr: *mut cuda_impl::rt::ContextStateManager,
ctx_state: *mut cuda_impl::rt::ContextState,
dtor_cb: Option<
extern "C" fn(
extern "system" fn(
CUcontext,
*mut cuda_impl::rt::ContextStateManager,
*mut cuda_impl::rt::ContextState,
@ -357,11 +357,11 @@ fn context_local_storage_ctor_impl(
}
// some kind of dtor
unsafe extern "C" fn context_local_storage_dtor(_: *mut usize, _: *mut ()) -> u32 {
unsafe extern "system" fn context_local_storage_dtor(_: *mut usize, _: *mut ()) -> u32 {
0
}
unsafe extern "C" fn context_local_storage_get_state(
unsafe extern "system" fn context_local_storage_get_state(
ctx_state: *mut *mut cuda_impl::rt::ContextState,
cu_ctx: CUcontext,
state_mgr: *mut cuda_impl::rt::ContextStateManager,

View file

@ -27,14 +27,14 @@ mod os;
macro_rules! extern_redirect {
(pub fn $fn_name:ident ( $($arg_id:ident: $arg_type:ty),* $(,)? ) -> $ret_type:ty ;) => {
#[no_mangle]
pub extern "stdcall" fn $fn_name ( $( $arg_id : $arg_type),* ) -> $ret_type {
pub extern "system" fn $fn_name ( $( $arg_id : $arg_type),* ) -> $ret_type {
unsafe { $crate::init_libcuda_handle() };
let name = std::ffi::CString::new(stringify!($fn_name)).unwrap();
let fn_ptr = unsafe { crate::os::get_proc_address($crate::LIBCUDA_HANDLE, &name) };
if fn_ptr == std::ptr::null_mut() {
return CUresult::CUDA_ERROR_UNKNOWN;
}
let typed_fn = unsafe { std::mem::transmute::<_, fn( $( $arg_id : $arg_type),* ) -> $ret_type>(fn_ptr) };
let typed_fn = unsafe { std::mem::transmute::<_, extern "system" fn( $( $arg_id : $arg_type),* ) -> $ret_type>(fn_ptr) };
typed_fn($( $arg_id ),*)
}
};
@ -46,7 +46,7 @@ macro_rules! extern_redirect_with {
$receiver:path ;
) => {
#[no_mangle]
pub extern "stdcall" fn $fn_name ( $( $arg_id : $arg_type),* ) -> $ret_type {
pub extern "system" fn $fn_name ( $( $arg_id : $arg_type),* ) -> $ret_type {
unsafe { $crate::init_libcuda_handle() };
let continuation = |$( $arg_id : $arg_type),* | {
let name = std::ffi::CString::new(stringify!($fn_name)).unwrap();
@ -54,7 +54,7 @@ macro_rules! extern_redirect_with {
if fn_ptr == std::ptr::null_mut() {
return CUresult::CUDA_ERROR_UNKNOWN;
}
let typed_fn = unsafe { std::mem::transmute::<_, fn( $( $arg_id : $arg_type),* ) -> $ret_type>(fn_ptr) };
let typed_fn = unsafe { std::mem::transmute::<_, extern "system" fn( $( $arg_id : $arg_type),* ) -> $ret_type>(fn_ptr) };
typed_fn($( $arg_id ),*)
};
unsafe { $receiver($( $arg_id ),* , continuation) }
@ -511,7 +511,7 @@ const CUDART_INTERFACE_GUID: CUuuid = CUuuid {
const GET_MODULE_OFFSET: usize = 6;
static mut CUDART_INTERFACE_VTABLE: Vec<*const c_void> = Vec::new();
static mut ORIGINAL_GET_MODULE_FROM_CUBIN: Option<
unsafe extern "C" fn(
unsafe extern "system" fn(
result: *mut CUmodule,
fatbinc_wrapper: *const FatbincWrapper,
ptr1: *mut c_void,
@ -598,7 +598,7 @@ struct FatbinFileHeader {
uncompressed_payload: c_ulong,
}
unsafe extern "C" fn get_module_from_cubin(
unsafe extern "system" fn get_module_from_cubin(
module: *mut CUmodule,
fatbinc_wrapper: *const FatbincWrapper,
ptr1: *mut c_void,