This happens so the XyzCB names can be used for structs containing both the function pointer and
the provided user data. Since these aliases represent raw unsafe function pointers the `Func`
prefix was chosen over `Fn`, which is generally used for safe functions.
Unfortunately it is not possible to concatinate identifiers to create new ones without a proc macro.
Thus, specify the new alias manually instead of generating them from the existing XyzCB names.
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25669>
properties: *const cl_context_properties,
num_devices: cl_uint,
devices: *const cl_device_id,
- pfn_notify: Option<CreateContextCB>,
+ pfn_notify: Option<FuncCreateContextCB>,
user_data: *mut ::std::os::raw::c_void,
) -> CLResult<cl_context> {
check_cb(&pfn_notify, user_data)?;
fn create_context_from_type(
properties: *const cl_context_properties,
device_type: cl_device_type,
- pfn_notify: Option<CreateContextCB>,
+ pfn_notify: Option<FuncCreateContextCB>,
user_data: *mut ::std::os::raw::c_void,
) -> CLResult<cl_context> {
// CL_INVALID_DEVICE_TYPE if device_type is not a valid value.
#[cl_entrypoint]
fn set_context_destructor_callback(
context: cl_context,
- pfn_notify: ::std::option::Option<DeleteContextCB>,
+ pfn_notify: ::std::option::Option<FuncDeleteContextCB>,
user_data: *mut ::std::os::raw::c_void,
) -> CLResult<()> {
let c = context.get_ref()?;
fn set_event_callback(
event: cl_event,
command_exec_callback_type: cl_int,
- pfn_event_notify: Option<EventCB>,
+ pfn_event_notify: Option<FuncEventCB>,
user_data: *mut ::std::os::raw::c_void,
) -> CLResult<()> {
let e = event.get_ref()?;
options: *const ::std::os::raw::c_char,
num_input_programs: cl_uint,
input_programs: *const cl_program,
- pfn_notify: Option<ProgramCB>,
+ pfn_notify: Option<FuncProgramCB>,
user_data: *mut ::std::os::raw::c_void,
errcode_ret: *mut cl_int,
) -> cl_program {
#[cl_entrypoint]
fn set_mem_object_destructor_callback(
memobj: cl_mem,
- pfn_notify: Option<MemCB>,
+ pfn_notify: Option<FuncMemCB>,
user_data: *mut ::std::os::raw::c_void,
) -> CLResult<()> {
let m = memobj.get_ref()?;
command_queue: cl_command_queue,
num_svm_pointers: cl_uint,
svm_pointers: *mut *mut c_void,
- pfn_free_func: Option<SVMFreeCb>,
+ pfn_free_func: Option<FuncSVMFreeCb>,
user_data: *mut c_void,
num_events_in_wait_list: cl_uint,
event_wait_list: *const cl_event,
command_queue: cl_command_queue,
num_svm_pointers: cl_uint,
svm_pointers: *mut *mut c_void,
- pfn_free_func: Option<SVMFreeCb>,
+ pfn_free_func: Option<FuncSVMFreeCb>,
user_data: *mut c_void,
num_events_in_wait_list: cl_uint,
event_wait_list: *const cl_event,
command_queue: cl_command_queue,
num_svm_pointers: cl_uint,
svm_pointers: *mut *mut c_void,
- pfn_free_func: Option<SVMFreeCb>,
+ pfn_free_func: Option<FuncSVMFreeCb>,
user_data: *mut c_void,
num_events_in_wait_list: cl_uint,
event_wait_list: *const cl_event,
}
fn call_cb(
- pfn_notify: Option<ProgramCB>,
+ pfn_notify: Option<FuncProgramCB>,
program: cl_program,
user_data: *mut ::std::os::raw::c_void,
) {
num_devices: cl_uint,
device_list: *const cl_device_id,
options: *const c_char,
- pfn_notify: Option<ProgramCB>,
+ pfn_notify: Option<FuncProgramCB>,
user_data: *mut ::std::os::raw::c_void,
) -> CLResult<()> {
let mut res = true;
num_input_headers: cl_uint,
input_headers: *const cl_program,
header_include_names: *mut *const c_char,
- pfn_notify: Option<ProgramCB>,
+ pfn_notify: Option<FuncProgramCB>,
user_data: *mut ::std::os::raw::c_void,
) -> CLResult<()> {
let mut res = true;
options: *const ::std::os::raw::c_char,
num_input_programs: cl_uint,
input_programs: *const cl_program,
- pfn_notify: Option<ProgramCB>,
+ pfn_notify: Option<FuncProgramCB>,
user_data: *mut ::std::os::raw::c_void,
) -> CLResult<(cl_program, cl_int)> {
let c = context.get_arc()?;
#[cl_entrypoint]
fn set_program_release_callback(
_program: cl_program,
- _pfn_notify: ::std::option::Option<ProgramCB>,
+ _pfn_notify: ::std::option::Option<FuncProgramCB>,
_user_data: *mut ::std::os::raw::c_void,
) -> CLResult<()> {
Err(CL_INVALID_OPERATION)
}
macro_rules! cl_callback {
- ($cb:ident {
+ ($cb:ident($fn_alias:ident) {
$($p:ident : $ty:ty,)*
}) => {
#[allow(dead_code)]
- pub type $cb = unsafe extern "C" fn(
+ pub type $fn_alias = unsafe extern "C" fn(
$($p: $ty,)*
);
}
}
cl_callback!(
- CreateContextCB {
+ CreateContextCB(FuncCreateContextCB) {
errinfo: *const ::std::os::raw::c_char,
private_info: *const ::std::ffi::c_void,
cb: usize,
);
cl_callback!(
- DeleteContextCB {
+ DeleteContextCB(FuncDeleteContextCB) {
context: cl_context,
user_data: *mut ::std::os::raw::c_void,
}
);
cl_callback!(
- EventCB {
+ EventCB(FuncEventCB) {
event: cl_event,
event_command_status: cl_int,
user_data: *mut ::std::os::raw::c_void,
);
cl_callback!(
- MemCB {
+ MemCB(FuncMemCB) {
memobj: cl_mem,
user_data: *mut ::std::os::raw::c_void,
}
);
cl_callback!(
- ProgramCB {
+ ProgramCB(FuncProgramCB) {
program: cl_program,
user_data: *mut ::std::os::raw::c_void,
}
);
cl_callback!(
- SVMFreeCb {
+ SVMFreeCb(FuncSVMFreeCb) {
queue: cl_command_queue,
num_svm_pointers: cl_uint,
svm_pointers: *mut *mut ::std::os::raw::c_void,
#[derive(Default)]
struct EventMutState {
status: cl_int,
- cbs: [Vec<(EventCB, *mut c_void)>; 3],
+ cbs: [Vec<(FuncEventCB, *mut c_void)>; 3],
work: Option<EventSig>,
time_queued: cl_ulong,
time_submit: cl_ulong,
}
}
- pub fn add_cb(&self, state: cl_int, cb: EventCB, data: *mut c_void) {
+ pub fn add_cb(&self, state: cl_int, cb: FuncEventCB, data: *mut c_void) {
let mut lock = self.state();
let status = lock.status;