diff --git a/src/gallium/frontends/rusticl/api/icd.rs b/src/gallium/frontends/rusticl/api/icd.rs index 5f341cbd2ad..89ca4f66e63 100644 --- a/src/gallium/frontends/rusticl/api/icd.rs +++ b/src/gallium/frontends/rusticl/api/icd.rs @@ -412,7 +412,7 @@ macro_rules! impl_cl_type_trait_base { return Err($err); } - let offset = ::mesa_rust_util::offset_of!($t, $($field).+); + let offset = ::std::mem::offset_of!($t, $($field).+); // SAFETY: We offset the pointer back from the ICD specified base type to our // internal type. let obj_ptr: *const $t = unsafe { self.byte_sub(offset) }.cast(); @@ -427,7 +427,7 @@ macro_rules! impl_cl_type_trait_base { if ptr.is_null() { return std::ptr::null_mut(); } - let offset = ::mesa_rust_util::offset_of!($t, $($field).+); + let offset = ::std::mem::offset_of!($t, $($field).+); // SAFETY: The resulting pointer is safe as we simply offset into the ICD specified // base type. unsafe { ptr.byte_add(offset) as Self } diff --git a/src/gallium/frontends/rusticl/util/ptr.rs b/src/gallium/frontends/rusticl/util/ptr.rs index 90f4c23a0b5..c9462c00862 100644 --- a/src/gallium/frontends/rusticl/util/ptr.rs +++ b/src/gallium/frontends/rusticl/util/ptr.rs @@ -98,28 +98,6 @@ impl CheckedPtr for *mut T { } } -// While std::mem::offset_of!() is stable from 1.77.0, support for nested fields -// (required in some rusticl cases) wasn't stabilized until 1.82.0. -// from https://internals.rust-lang.org/t/discussion-on-offset-of/7440/2 -#[macro_export] -macro_rules! offset_of { - ($Struct:path, $($field:ident).+ $(,)?) => {{ - // Using a separate function to minimize unhygienic hazards - // (e.g. unsafety of #[repr(packed)] field borrows). - // Uncomment `const` when `const fn`s can juggle pointers. - /*const*/ - fn offset() -> usize { - let u = std::mem::MaybeUninit::<$Struct>::uninit(); - let f = unsafe { &(*u.as_ptr()).$($field).+ }; - let o = (f as *const _ as usize).wrapping_sub(&u as *const _ as usize); - // Triple check that we are within `u` still. - assert!((0..=std::mem::size_of_val(&u)).contains(&o)); - o - } - offset() - }}; -} - // Adapted from libstd since std::ptr::is_aligned_to is still unstable // See https://github.com/rust-lang/rust/issues/96284 #[must_use]