From fd5d89f2b62f08584b408c499b8f80c6c63018b7 Mon Sep 17 00:00:00 2001 From: Gabriel Majeri Date: Tue, 28 Aug 2018 20:01:16 +0300 Subject: [PATCH] Remove libc usage --- ash/Cargo.toml | 1 - ash/src/allocator.rs | 73 ++++++++--------- ash/src/device.rs | 137 ++++++++++++++++---------------- ash/src/entry.rs | 5 +- ash/src/extensions/surface.rs | 2 +- ash/src/extensions/swapchain.rs | 8 +- ash/src/instance.rs | 3 +- ash/src/lib.rs | 1 - ash/src/util.rs | 5 +- ash/src/vk.rs | 6 +- examples/src/bin/texture.rs | 3 +- examples/src/lib.rs | 17 ++-- generator/src/lib.rs | 6 +- 13 files changed, 134 insertions(+), 133 deletions(-) diff --git a/ash/Cargo.toml b/ash/Cargo.toml index 205661e..f6a2802 100644 --- a/ash/Cargo.toml +++ b/ash/Cargo.toml @@ -12,7 +12,6 @@ documentation = "https://docs.rs/ash" [dependencies] shared_library = "0.1.5" lazy_static = "0.2.1" -libc = "0.2.26" [features] default = [] diff --git a/ash/src/allocator.rs b/ash/src/allocator.rs index d0dc1a3..3cd1569 100644 --- a/ash/src/allocator.rs +++ b/ash/src/allocator.rs @@ -1,30 +1,31 @@ #![allow(dead_code)] use vk; +use std::os::raw::c_void; use std::ptr; pub trait VkAllocation { unsafe extern "system" fn allocation( *mut (), - vk::size_t, - vk::size_t, + usize, + usize, vk::SystemAllocationScope, ) -> *mut (); unsafe extern "system" fn reallocation( - *mut vk::c_void, - *mut vk::c_void, - vk::size_t, - vk::size_t, + *mut c_void, + *mut c_void, + usize, + usize, vk::SystemAllocationScope, - ) -> *mut vk::c_void; - unsafe extern "system" fn free(*mut vk::c_void, *mut vk::c_void); + ) -> *mut c_void; + unsafe extern "system" fn free(*mut c_void, *mut c_void); unsafe extern "system" fn internal_allocation( - *mut vk::c_void, - vk::size_t, + *mut c_void, + usize, vk::InternalAllocationType, vk::SystemAllocationScope, ); unsafe extern "system" fn internal_free( - *mut vk::c_void, - vk::size_t, + *mut c_void, + usize, vk::InternalAllocationType, vk::SystemAllocationScope, ); @@ -47,33 +48,33 @@ pub struct TestAlloc; impl VkAllocation for TestAlloc { unsafe extern "system" fn allocation( _: *mut (), - _: vk::size_t, - _: vk::size_t, + _: usize, + _: usize, _: vk::SystemAllocationScope, ) -> *mut () { ptr::null_mut() } unsafe extern "system" fn reallocation( - _: *mut vk::c_void, - _: *mut vk::c_void, - _: vk::size_t, - _: vk::size_t, + _: *mut c_void, + _: *mut c_void, + _: usize, + _: usize, _: vk::SystemAllocationScope, - ) -> *mut vk::c_void { + ) -> *mut c_void { ptr::null_mut() } - unsafe extern "system" fn free(_: *mut vk::c_void, _: *mut vk::c_void) {} + unsafe extern "system" fn free(_: *mut c_void, _: *mut c_void) {} unsafe extern "system" fn internal_allocation( - _: *mut vk::c_void, - _: vk::size_t, + _: *mut c_void, + _: usize, _: vk::InternalAllocationType, _: vk::SystemAllocationScope, ) { } unsafe extern "system" fn internal_free( - _: *mut vk::c_void, - _: vk::size_t, + _: *mut c_void, + _: usize, _: vk::InternalAllocationType, _: vk::SystemAllocationScope, ) { @@ -82,33 +83,33 @@ impl VkAllocation for TestAlloc { impl VkAllocation for DefaultAllocatorCallback { unsafe extern "system" fn allocation( _: *mut (), - _: vk::size_t, - _: vk::size_t, + _: usize, + _: usize, _: vk::SystemAllocationScope, ) -> *mut () { ptr::null_mut() } unsafe extern "system" fn reallocation( - _: *mut vk::c_void, - _: *mut vk::c_void, - _: vk::size_t, - _: vk::size_t, + _: *mut c_void, + _: *mut c_void, + _: usize, + _: usize, _: vk::SystemAllocationScope, - ) -> *mut vk::c_void { + ) -> *mut c_void { ptr::null_mut() } - unsafe extern "system" fn free(_: *mut vk::c_void, _: *mut vk::c_void) {} + unsafe extern "system" fn free(_: *mut c_void, _: *mut c_void) {} unsafe extern "system" fn internal_allocation( - _: *mut vk::c_void, - _: vk::size_t, + _: *mut c_void, + _: usize, _: vk::InternalAllocationType, _: vk::SystemAllocationScope, ) { } unsafe extern "system" fn internal_free( - _: *mut vk::c_void, - _: vk::size_t, + _: *mut c_void, + _: usize, _: vk::InternalAllocationType, _: vk::SystemAllocationScope, ) { diff --git a/ash/src/device.rs b/ash/src/device.rs index e562b0d..b6a2991 100644 --- a/ash/src/device.rs +++ b/ash/src/device.rs @@ -1,6 +1,7 @@ #![allow(dead_code)] use prelude::*; use std::mem; +use std::os::raw::c_void; use std::ptr; use version::{FunctionPointers, V1_0, V1_1}; use vk; @@ -36,9 +37,9 @@ pub trait DeviceV1_1: DeviceV1_0 { unsafe fn get_device_group_peer_memory_features( &self, - heap_index: vk::uint32_t, - local_device_index: vk::uint32_t, - remote_device_index: vk::uint32_t, + heap_index: u32, + local_device_index: u32, + remote_device_index: u32, ) -> vk::PeerMemoryFeatureFlags { let mut peer_memory_features = mem::uninitialized(); self.fp_v1_1().get_device_group_peer_memory_features( @@ -54,7 +55,7 @@ pub trait DeviceV1_1: DeviceV1_0 { unsafe fn cmd_set_device_mask( &self, command_buffer: vk::CommandBuffer, - device_mask: vk::uint32_t, + device_mask: u32, ) { self.fp_v1_1() .cmd_set_device_mask(command_buffer, device_mask); @@ -63,12 +64,12 @@ pub trait DeviceV1_1: DeviceV1_0 { unsafe fn cmd_dispatch_base( &self, command_buffer: vk::CommandBuffer, - base_group_x: vk::uint32_t, - base_group_y: vk::uint32_t, - base_group_z: vk::uint32_t, - group_count_x: vk::uint32_t, - group_count_y: vk::uint32_t, - group_count_z: vk::uint32_t, + base_group_x: u32, + base_group_y: u32, + base_group_z: u32, + group_count_x: u32, + group_count_y: u32, + group_count_z: u32, ) { self.fp_v1_1().cmd_dispatch_base( command_buffer, @@ -202,7 +203,7 @@ pub trait DeviceV1_1: DeviceV1_0 { &self, descriptor_set: vk::DescriptorSet, descriptor_update_template: vk::DescriptorUpdateTemplate, - data: *const vk::c_void, + data: *const c_void, ) { self.fp_v1_1().update_descriptor_set_with_template( self.handle(), @@ -261,7 +262,7 @@ pub trait DeviceV1_0 { self.fp_v1_0().free_command_buffers( self.handle(), command_pool, - command_buffers.len() as vk::uint32_t, + command_buffers.len() as u32, command_buffers.as_ptr(), ); } @@ -521,7 +522,7 @@ pub trait DeviceV1_0 { buffer: vk::Buffer, offset: vk::DeviceSize, size: vk::DeviceSize, - data: vk::uint32_t, + data: u32, ) { self.fp_v1_0() .cmd_fill_buffer(command_buffer, buffer, offset, size, data); @@ -572,7 +573,7 @@ pub trait DeviceV1_0 { src_image, src_image_layout, dst_buffer, - regions.len() as vk::uint32_t, + regions.len() as u32, regions.as_ptr(), ); } @@ -722,7 +723,7 @@ pub trait DeviceV1_0 { unsafe fn reset_fences(&self, fences: &[vk::Fence]) -> VkResult<()> { let err_code = self.fp_v1_0().reset_fences( self.handle(), - fences.len() as vk::uint32_t, + fences.len() as u32, fences.as_ptr(), ); match err_code { @@ -755,7 +756,7 @@ pub trait DeviceV1_0 { image, image_layout, clear_color_value, - ranges.len() as vk::uint32_t, + ranges.len() as u32, ranges.as_ptr(), ); } @@ -773,7 +774,7 @@ pub trait DeviceV1_0 { image, image_layout, clear_depth_stencil_value, - ranges.len() as vk::uint32_t, + ranges.len() as u32, ranges.as_ptr(), ); } @@ -786,9 +787,9 @@ pub trait DeviceV1_0 { ) { self.fp_v1_0().cmd_clear_attachments( command_buffer, - attachments.len() as vk::uint32_t, + attachments.len() as u32, attachments.as_ptr(), - rects.len() as vk::uint32_t, + rects.len() as u32, rects.as_ptr(), ); } @@ -796,11 +797,11 @@ pub trait DeviceV1_0 { unsafe fn cmd_draw_indexed( &self, command_buffer: vk::CommandBuffer, - index_count: vk::uint32_t, - instance_count: vk::uint32_t, - first_index: vk::uint32_t, - vertex_offset: vk::int32_t, - first_instance: vk::uint32_t, + index_count: u32, + instance_count: u32, + first_index: u32, + vertex_offset: i32, + first_instance: u32, ) { self.fp_v1_0().cmd_draw_indexed( command_buffer, @@ -817,8 +818,8 @@ pub trait DeviceV1_0 { command_buffer: vk::CommandBuffer, buffer: vk::Buffer, offset: vk::DeviceSize, - draw_count: vk::uint32_t, - stride: vk::uint32_t, + draw_count: u32, + stride: u32, ) { self.fp_v1_0().cmd_draw_indexed_indirect( command_buffer, @@ -836,7 +837,7 @@ pub trait DeviceV1_0 { ) { self.fp_v1_0().cmd_execute_commands( primary_command_buffer, - secondary_command_buffers.len() as vk::uint32_t, + secondary_command_buffers.len() as u32, secondary_command_buffers.as_ptr(), ); } @@ -846,18 +847,18 @@ pub trait DeviceV1_0 { command_buffer: vk::CommandBuffer, pipeline_bind_point: vk::PipelineBindPoint, layout: vk::PipelineLayout, - first_set: vk::uint32_t, + first_set: u32, descriptor_sets: &[vk::DescriptorSet], - dynamic_offsets: &[vk::uint32_t], + dynamic_offsets: &[u32], ) { self.fp_v1_0().cmd_bind_descriptor_sets( command_buffer, pipeline_bind_point, layout, first_set, - descriptor_sets.len() as vk::uint32_t, + descriptor_sets.len() as u32, descriptor_sets.as_ptr(), - dynamic_offsets.len() as vk::uint32_t, + dynamic_offsets.len() as u32, dynamic_offsets.as_ptr(), ); } @@ -866,8 +867,8 @@ pub trait DeviceV1_0 { &self, command_buffer: vk::CommandBuffer, query_pool: vk::QueryPool, - first_query: vk::uint32_t, - query_count: vk::uint32_t, + first_query: u32, + query_count: u32, dst_buffer: vk::Buffer, dst_offset: vk::DeviceSize, stride: vk::DeviceSize, @@ -890,7 +891,7 @@ pub trait DeviceV1_0 { command_buffer: vk::CommandBuffer, layout: vk::PipelineLayout, stage_flags: vk::ShaderStageFlags, - offset: vk::uint32_t, + offset: u32, constants: &[u8], ) { self.fp_v1_0().cmd_push_constants( @@ -934,13 +935,13 @@ pub trait DeviceV1_0 { unsafe fn cmd_set_scissor( &self, command_buffer: vk::CommandBuffer, - first_scissor: vk::uint32_t, + first_scissor: u32, scissors: &[vk::Rect2D], ) { self.fp_v1_0().cmd_set_scissor( command_buffer, first_scissor, - scissors.len() as vk::uint32_t, + scissors.len() as u32, scissors.as_ptr(), ); } @@ -953,7 +954,7 @@ pub trait DeviceV1_0 { unsafe fn cmd_bind_vertex_buffers( &self, command_buffer: vk::CommandBuffer, - first_binding: vk::uint32_t, + first_binding: u32, buffers: &[vk::Buffer], offsets: &[vk::DeviceSize], ) { @@ -961,7 +962,7 @@ pub trait DeviceV1_0 { self.fp_v1_0().cmd_bind_vertex_buffers( command_buffer, first_binding, - buffers.len() as vk::uint32_t, + buffers.len() as u32, buffers.as_ptr(), offsets.as_ptr(), ); @@ -974,10 +975,10 @@ pub trait DeviceV1_0 { unsafe fn cmd_draw( &self, command_buffer: vk::CommandBuffer, - vertex_count: vk::uint32_t, - instance_count: vk::uint32_t, - first_vertex: vk::uint32_t, - first_instance: vk::uint32_t, + vertex_count: u32, + instance_count: u32, + first_vertex: u32, + first_instance: u32, ) { self.fp_v1_0().cmd_draw( command_buffer, @@ -993,8 +994,8 @@ pub trait DeviceV1_0 { command_buffer: vk::CommandBuffer, buffer: vk::Buffer, offset: vk::DeviceSize, - draw_count: vk::uint32_t, - stride: vk::uint32_t, + draw_count: u32, + stride: u32, ) { self.fp_v1_0() .cmd_draw_indirect(command_buffer, buffer, offset, draw_count, stride); @@ -1003,9 +1004,9 @@ pub trait DeviceV1_0 { unsafe fn cmd_dispatch( &self, command_buffer: vk::CommandBuffer, - group_count_x: vk::uint32_t, - group_count_y: vk::uint32_t, - group_count_z: vk::uint32_t, + group_count_x: u32, + group_count_y: u32, + group_count_z: u32, ) { self.fp_v1_0() .cmd_dispatch(command_buffer, group_count_x, group_count_y, group_count_z); @@ -1024,13 +1025,13 @@ pub trait DeviceV1_0 { unsafe fn cmd_set_viewport( &self, command_buffer: vk::CommandBuffer, - first_viewport: vk::uint32_t, + first_viewport: u32, viewports: &[vk::Viewport], ) { self.fp_v1_0().cmd_set_viewport( command_buffer, first_viewport, - viewports.len() as vk::uint32_t, + viewports.len() as u32, viewports.as_ptr(), ); } @@ -1098,8 +1099,8 @@ pub trait DeviceV1_0 { unsafe fn get_query_pool_results( &self, query_pool: vk::QueryPool, - first_query: vk::uint32_t, - query_count: vk::uint32_t, + first_query: u32, + query_count: u32, data: &mut [T], flags: vk::QueryResultFlags, ) -> VkResult<()> { @@ -1201,7 +1202,7 @@ pub trait DeviceV1_0 { let err_code = self.fp_v1_0().create_graphics_pipelines( self.handle(), pipeline_cache, - create_infos.len() as vk::uint32_t, + create_infos.len() as u32, create_infos.as_ptr(), allocation_callbacks.as_raw_ptr(), pipelines.as_mut_ptr(), @@ -1223,7 +1224,7 @@ pub trait DeviceV1_0 { let err_code = self.fp_v1_0().create_compute_pipelines( self.handle(), pipeline_cache, - create_infos.len() as vk::uint32_t, + create_infos.len() as u32, create_infos.as_ptr(), allocation_callbacks.as_raw_ptr(), pipelines.as_mut_ptr(), @@ -1296,8 +1297,8 @@ pub trait DeviceV1_0 { offset: vk::DeviceSize, size: vk::DeviceSize, flags: vk::MemoryMapFlags, - ) -> VkResult<*mut vk::c_void> { - let mut data: *mut vk::c_void = mem::uninitialized(); + ) -> VkResult<*mut c_void> { + let mut data: *mut c_void = mem::uninitialized(); let err_code = self.fp_v1_0() .map_memory(self.handle(), memory, offset, size, flags, &mut data); @@ -1317,7 +1318,7 @@ pub trait DeviceV1_0 { ) -> VkResult<()> { let err_code = self.fp_v1_0().invalidate_mapped_memory_ranges( self.handle(), - ranges.len() as vk::uint32_t, + ranges.len() as u32, ranges.as_ptr(), ); match err_code { @@ -1329,7 +1330,7 @@ pub trait DeviceV1_0 { unsafe fn flush_mapped_memory_ranges(&self, ranges: &[vk::MappedMemoryRange]) -> VkResult<()> { let err_code = self.fp_v1_0().flush_mapped_memory_ranges( self.handle(), - ranges.len() as vk::uint32_t, + ranges.len() as u32, ranges.as_ptr(), ); match err_code { @@ -1358,8 +1359,8 @@ pub trait DeviceV1_0 { unsafe fn get_device_queue( &self, - queue_family_index: vk::uint32_t, - queue_index: vk::uint32_t, + queue_family_index: u32, + queue_index: u32, ) -> vk::Queue { let mut queue = mem::uninitialized(); self.fp_v1_0() @@ -1382,11 +1383,11 @@ pub trait DeviceV1_0 { src_stage_mask, dst_stage_mask, dependency_flags, - memory_barriers.len() as vk::uint32_t, + memory_barriers.len() as u32, memory_barriers.as_ptr(), - buffer_memory_barriers.len() as vk::uint32_t, + buffer_memory_barriers.len() as u32, buffer_memory_barriers.as_ptr(), - image_memory_barriers.len() as vk::uint32_t, + image_memory_barriers.len() as u32, image_memory_barriers.as_ptr(), ); } @@ -1435,13 +1436,13 @@ pub trait DeviceV1_0 { &self, fences: &[vk::Fence], wait_all: bool, - timeout: vk::uint64_t, + timeout: u64, ) -> VkResult<()> { let err_code = self.fp_v1_0().wait_for_fences( self.handle(), - fences.len() as vk::uint32_t, + fences.len() as u32, fences.as_ptr(), - wait_all as vk::uint32_t, + wait_all as u32, timeout, ); match err_code { @@ -1474,7 +1475,7 @@ pub trait DeviceV1_0 { ) -> VkResult<()> { let err_code = self.fp_v1_0().queue_submit( queue, - submits.len() as vk::uint32_t, + submits.len() as u32, submits.as_ptr(), fence, ); @@ -1536,13 +1537,13 @@ pub trait DeviceV1_0 { &self, create_info: &vk::CommandBufferAllocateInfo, ) -> VkResult> { - let mut buffers = Vec::with_capacity(create_info.command_buffer_count as vk::size_t); + let mut buffers = Vec::with_capacity(create_info.command_buffer_count as usize); let err_code = self.fp_v1_0().allocate_command_buffers( self.handle(), create_info, buffers.as_mut_ptr(), ); - buffers.set_len(create_info.command_buffer_count as vk::size_t); + buffers.set_len(create_info.command_buffer_count as usize); match err_code { vk::Result::SUCCESS => Ok(buffers), _ => Err(err_code), diff --git a/ash/src/entry.rs b/ash/src/entry.rs index 3552ab6..7fdefbe 100644 --- a/ash/src/entry.rs +++ b/ash/src/entry.rs @@ -4,6 +4,7 @@ use shared_library::dynamic_library::DynamicLibrary; use std::error::Error; use std::fmt; use std::mem; +use std::os::raw::c_char; use std::path::Path; use std::ptr; use version::{EntryLoader, FunctionPointers, InstanceLoader, V1_0, V1_1}; @@ -134,7 +135,7 @@ pub trait EntryV1_0 { fn get_instance_proc_addr( &self, instance: vk::Instance, - p_name: *const vk::c_char, + p_name: *const c_char, ) -> vk::PFN_vkVoidFunction { unsafe { self.static_fn().get_instance_proc_addr(instance, p_name) } } @@ -191,7 +192,7 @@ impl Entry { pub trait EntryV1_1: EntryV1_0 { fn fp_v1_1(&self) -> &vk::EntryFnV1_1; - fn enumerate_instance_version(&self) -> VkResult { + fn enumerate_instance_version(&self) -> VkResult { unsafe { let mut api_version = 0; let err_code = self.fp_v1_1().enumerate_instance_version(&mut api_version); diff --git a/ash/src/extensions/surface.rs b/ash/src/extensions/surface.rs index 22e8b23..ce8cfd2 100644 --- a/ash/src/extensions/surface.rs +++ b/ash/src/extensions/surface.rs @@ -34,7 +34,7 @@ impl Surface { pub fn get_physical_device_surface_support_khr( &self, physical_device: vk::PhysicalDevice, - queue_index: vk::uint32_t, + queue_index: u32, surface: vk::SurfaceKHR, ) -> bool { unsafe { diff --git a/ash/src/extensions/swapchain.rs b/ash/src/extensions/swapchain.rs index 2488d6e..0a99708 100644 --- a/ash/src/extensions/swapchain.rs +++ b/ash/src/extensions/swapchain.rs @@ -46,10 +46,10 @@ impl Swapchain { pub unsafe fn acquire_next_image_khr( &self, swapchain: vk::SwapchainKHR, - timeout: vk::uint64_t, + timeout: u64, semaphore: vk::Semaphore, fence: vk::Fence, - ) -> VkResult { + ) -> VkResult { let mut index = mem::uninitialized(); let err_code = self.swapchain_fn.acquire_next_image_khr( self.handle, @@ -108,14 +108,14 @@ impl Swapchain { ptr::null_mut(), ); - let mut v = Vec::with_capacity(count as vk::size_t); + let mut v = Vec::with_capacity(count as usize); let err_code = self.swapchain_fn.get_swapchain_images_khr( self.handle, swapchain, &mut count, v.as_mut_ptr(), ); - v.set_len(count as vk::size_t); + v.set_len(count as usize); match err_code { vk::Result::SUCCESS => Ok(v), _ => Err(err_code), diff --git a/ash/src/instance.rs b/ash/src/instance.rs index 50c459a..f799fe9 100644 --- a/ash/src/instance.rs +++ b/ash/src/instance.rs @@ -4,6 +4,7 @@ use prelude::*; use std::error::Error; use std::fmt; use std::mem; +use std::os::raw::c_char; use std::ptr; use version::DeviceLoader; use version::{FunctionPointers, V1_0, V1_1}; @@ -290,7 +291,7 @@ pub trait InstanceV1_0 { fn get_device_proc_addr( &self, device: vk::Device, - p_name: *const vk::c_char, + p_name: *const c_char, ) -> vk::PFN_vkVoidFunction { unsafe { self.fp_v1_0().get_device_proc_addr(device, p_name) } } diff --git a/ash/src/lib.rs b/ash/src/lib.rs index 7e75782..bb9b464 100644 --- a/ash/src/lib.rs +++ b/ash/src/lib.rs @@ -1,6 +1,5 @@ #[macro_use] extern crate lazy_static; -extern crate libc; extern crate shared_library; pub use device::Device; pub use entry::{Entry, InstanceError, LoadingError}; diff --git a/ash/src/util.rs b/ash/src/util.rs index 917333a..173d2da 100644 --- a/ash/src/util.rs +++ b/ash/src/util.rs @@ -1,6 +1,7 @@ use std::iter::Iterator; use std::marker::PhantomData; use std::mem::size_of; +use std::os::raw::c_void; use vk; /// `Align` handles dynamic alignment. The is useful for dynamic uniform buffers where @@ -12,7 +13,7 @@ use vk; /// an additional allocation and with the correct alignment. #[derive(Debug, Clone)] pub struct Align { - ptr: *mut vk::c_void, + ptr: *mut c_void, elem_size: vk::DeviceSize, size: vk::DeviceSize, _m: PhantomData, @@ -46,7 +47,7 @@ fn calc_padding(adr: vk::DeviceSize, align: vk::DeviceSize) -> vk::DeviceSize { impl Align { pub unsafe fn new( - ptr: *mut vk::c_void, + ptr: *mut c_void, alignment: vk::DeviceSize, size: vk::DeviceSize, ) -> Self { diff --git a/ash/src/vk.rs b/ash/src/vk.rs index 5c548a2..d2c8903 100644 --- a/ash/src/vk.rs +++ b/ash/src/vk.rs @@ -2,9 +2,8 @@ pub use self::bitflags::*; #[doc(hidden)] pub use self::extensions::*; -#[doc(hidden)] -pub use libc::*; use std::fmt; +use std::os::raw::*; pub trait Handle { const TYPE: ObjectType; fn as_raw(self) -> u64; @@ -54,8 +53,7 @@ pub type wl_display = *const c_void; pub type wl_surface = *const c_void; pub type HANDLE = *mut c_void; pub type DWORD = c_ulong; -pub type WCHAR = wchar_t; -pub type LPCWSTR = *const WCHAR; +pub type LPCWSTR = *const u16; #[allow(non_camel_case_types)] pub type SECURITY_ATTRIBUTES = (); pub type ANativeWindow = c_void; diff --git a/examples/src/bin/texture.rs b/examples/src/bin/texture.rs index e089bc0..d87df89 100644 --- a/examples/src/bin/texture.rs +++ b/examples/src/bin/texture.rs @@ -8,6 +8,7 @@ use std::ffi::CString; use std::fs::File; use std::io::Read; use std::mem::{self, align_of}; +use std::os::raw::c_void; use std::path::Path; use std::ptr; @@ -152,7 +153,7 @@ fn main() { .device .allocate_memory(&index_allocate_info, None) .unwrap(); - let index_ptr: *mut vk::c_void = base + let index_ptr: *mut c_void = base .device .map_memory( index_buffer_memory, diff --git a/examples/src/lib.rs b/examples/src/lib.rs index a197f4c..5d0db7f 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -18,6 +18,7 @@ use std::cell::RefCell; use std::default::Default; use std::ffi::{CStr, CString}; use std::ops::Drop; +use std::os::raw::{c_char, c_void}; use std::ptr; // Simple offset_of macro akin to C++ offsetof @@ -121,13 +122,13 @@ unsafe fn create_surface( use winit::os::windows::WindowExt; let hwnd = window.get_hwnd() as HWND; - let hinstance = GetWindow(hwnd, 0) as *const vk::c_void; + let hinstance = GetWindow(hwnd, 0) as *const c_void; let win32_create_info = vk::Win32SurfaceCreateInfoKHR { s_type: vk::StructureType::WIN32_SURFACE_CREATE_INFO_KHR, p_next: ptr::null(), flags: Default::default(), hinstance: hinstance, - hwnd: hwnd as *const vk::c_void, + hwnd: hwnd as *const c_void, }; let win32_surface_loader = Win32Surface::new(entry, instance).expect("Unable to load win32 surface"); @@ -155,12 +156,12 @@ fn extension_names() -> Vec<*const i8> { unsafe extern "system" fn vulkan_debug_callback( _: vk::DebugReportFlagsEXT, _: vk::DebugReportObjectTypeEXT, - _: vk::uint64_t, - _: vk::size_t, - _: vk::int32_t, - _: *const vk::c_char, - p_message: *const vk::c_char, - _: *mut vk::c_void, + _: u64, + _: usize, + _: i32, + _: *const c_char, + p_message: *const c_char, + _: *mut c_void, ) -> u32 { println!("{:?}", CStr::from_ptr(p_message)); 1 diff --git a/generator/src/lib.rs b/generator/src/lib.rs index 142d22a..955d364 100644 --- a/generator/src/lib.rs +++ b/generator/src/lib.rs @@ -349,8 +349,7 @@ pub fn platform_specific_types() -> Tokens { pub type wl_surface = *const c_void; pub type HANDLE = *mut c_void; pub type DWORD = c_ulong; - pub type WCHAR = wchar_t; - pub type LPCWSTR = *const WCHAR; + pub type LPCWSTR = *const u16; // FIXME: Platform specific types that should come from a library // typedefs are only here so that the code compiles for now @@ -1687,8 +1686,7 @@ pub fn write_source_code(path: &Path) { let platform_specific_types = platform_specific_types(); let source_code = quote!{ use std::fmt; - #[doc(hidden)] - pub use libc::*; + use std::os::raw::*; #[doc(hidden)] pub use self::extensions::*; #[doc(hidden)]