rusticl/util: rename Properties::from_ptr to new

Reviewed-by: @LingMan
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32268>
This commit is contained in:
Karol Herbst 2024-12-03 01:01:51 +01:00 committed by Marge Bot
parent d791135df1
commit 12752228db
4 changed files with 7 additions and 7 deletions

View file

@ -78,7 +78,7 @@ pub fn get_gl_context_info_khr(
// CL_INVALID_PROPERTY [...] if the same property name is specified more than once.
// SAFETY: properties is a 0 terminated array by spec.
let props = unsafe { Properties::from_ptr(properties) }.ok_or(CL_INVALID_PROPERTY)?;
let props = unsafe { Properties::new(properties) }.ok_or(CL_INVALID_PROPERTY)?;
for (&key, &val) in props.iter() {
match key as u32 {
// CL_INVALID_PLATFORM [...] if platform value specified in properties is not a valid platform.
@ -141,7 +141,7 @@ fn create_context(
// CL_INVALID_PROPERTY [...] if the same property name is specified more than once.
// SAFETY: properties is a 0 terminated array by spec.
let props = unsafe { Properties::from_ptr(properties) }.ok_or(CL_INVALID_PROPERTY)?;
let props = unsafe { Properties::new(properties) }.ok_or(CL_INVALID_PROPERTY)?;
for (&key, &val) in props.iter() {
match key as u32 {
// CL_INVALID_PLATFORM [...] if platform value specified in properties is not a valid platform.

View file

@ -296,7 +296,7 @@ fn create_buffer_with_properties(
}
// CL_INVALID_PROPERTY [...] if the same property name is specified more than once.
let props = unsafe { Properties::from_ptr(properties) }.ok_or(CL_INVALID_PROPERTY)?;
let props = unsafe { Properties::new(properties) }.ok_or(CL_INVALID_PROPERTY)?;
// CL_INVALID_PROPERTY if a property name in properties is not a supported property name, if
// the value specified for a supported property name is not valid, or if the same property name
@ -801,7 +801,7 @@ fn create_image_with_properties(
.ok_or(CL_IMAGE_FORMAT_NOT_SUPPORTED)?;
// CL_INVALID_PROPERTY [...] if the same property name is specified more than once.
let props = unsafe { Properties::from_ptr(properties) }.ok_or(CL_INVALID_PROPERTY)?;
let props = unsafe { Properties::new(properties) }.ok_or(CL_INVALID_PROPERTY)?;
// CL_INVALID_PROPERTY if a property name in properties is not a supported property name, if
// the value specified for a supported property name is not valid, or if the same property name
@ -1014,7 +1014,7 @@ fn create_sampler_with_properties(
// CL_INVALID_VALUE if the same property name is specified more than once.
// SAFETY: sampler_properties is a 0 terminated array by spec.
let sampler_properties =
unsafe { Properties::from_ptr(sampler_properties) }.ok_or(CL_INVALID_VALUE)?;
unsafe { Properties::new(sampler_properties) }.ok_or(CL_INVALID_VALUE)?;
for (&key, &val) in sampler_properties.iter() {
match key as u32 {
CL_SAMPLER_ADDRESSING_MODE => addressing_mode = val as u32,

View file

@ -131,7 +131,7 @@ fn create_command_queue_with_properties(
let mut queue_properties = cl_command_queue_properties::default();
// SAFETY: properties is a 0 terminated array by spec.
let properties = unsafe { Properties::from_ptr(properties) }.ok_or(CL_INVALID_PROPERTY)?;
let properties = unsafe { Properties::new(properties) }.ok_or(CL_INVALID_PROPERTY)?;
for (k, v) in properties.iter() {
match *k as cl_uint {
CL_QUEUE_PROPERTIES => queue_properties = *v,

View file

@ -16,7 +16,7 @@ impl<T> Properties<T> {
///
/// Besides `p` being valid to be dereferenced, it also needs to point to a `T::default()`
/// terminated array of `T`.
pub unsafe fn from_ptr(mut p: *const T) -> Option<Self>
pub unsafe fn new(mut p: *const T) -> Option<Self>
where
T: Copy + Default + PartialEq,
{