From 17ae18614d4ee0444d39399b91dbc56fbdcc7148 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Thu, 3 Oct 2024 13:07:24 +0200 Subject: [PATCH] generator: Mark QNX `c_void` types as opaque to get raw pointers Long ago in #339 I added "opaque" types to ensure that pointers to it stay as pointers in FFI rather than get converted to `&mut` borrows which don't carry the load of an arbitrary pointer value to "something unknown" (= opaque). When the QNX types were added in #429 and #760 some time later, they weren't added to this list and turned into borrows making them impossible to be handled safely in user code. --- Changelog.md | 4 ++++ ash/src/vk/definitions.rs | 6 +++--- generator/src/lib.rs | 3 +++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Changelog.md b/Changelog.md index e3f4c3e70..263b4f529 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +### Changed + +- Treat QNX "void" type aliases as "opaque" to make them raw pointers instead of borrows in public structures (#950) + ### Added - Update Vulkan-Headers to 1.3.296 (#910) diff --git a/ash/src/vk/definitions.rs b/ash/src/vk/definitions.rs index 8ea977a51..ceea679b7 100644 --- a/ash/src/vk/definitions.rs +++ b/ash/src/vk/definitions.rs @@ -9264,12 +9264,12 @@ impl<'a> ScreenSurfaceCreateInfoQNX<'a> { self } #[inline] - pub fn context(mut self, context: &'a mut _screen_context) -> Self { + pub fn context(mut self, context: *mut _screen_context) -> Self { self.context = context; self } #[inline] - pub fn window(mut self, window: &'a mut _screen_window) -> Self { + pub fn window(mut self, window: *mut _screen_window) -> Self { self.window = window; self } @@ -56278,7 +56278,7 @@ unsafe impl<'a> TaggedStructure for ImportScreenBufferInfoQNX<'a> { unsafe impl ExtendsMemoryAllocateInfo for ImportScreenBufferInfoQNX<'_> {} impl<'a> ImportScreenBufferInfoQNX<'a> { #[inline] - pub fn buffer(mut self, buffer: &'a mut _screen_buffer) -> Self { + pub fn buffer(mut self, buffer: *mut _screen_buffer) -> Self { self.buffer = buffer; self } diff --git a/generator/src/lib.rs b/generator/src/lib.rs index ed85b3be8..55f6889f9 100644 --- a/generator/src/lib.rs +++ b/generator/src/lib.rs @@ -290,6 +290,9 @@ fn is_opaque_type(ty: &str) -> bool { | "CAMetalLayer" | "IDirectFB" | "IDirectFBSurface" + | "_screen_buffer" + | "_screen_context" + | "_screen_window" ) }