Skip to content

Commit 3465c60

Browse files
committed
Fix build with windows-sys 0.61
BOOL was removed from Win32::Foundation; use i32 instead. HANDLE and HMODULE are now *mut c_void so null checks must use .is_null(). Add Send/Sync impls for OwnedLibrary since it wraps a raw pointer.
1 parent 23abf81 commit 3465c60

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎src/rt_win.rs‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ mod avrt_lib {
7474
use windows_sys::{
7575
core::PCWSTR,
7676
s, w,
77-
Win32::Foundation::{BOOL, FALSE, HANDLE, WIN32_ERROR},
77+
Win32::Foundation::{FALSE, HANDLE, WIN32_ERROR},
7878
};
7979

8080
type AvSetMmThreadCharacteristicsWFn = unsafe extern "system" fn(PCWSTR, *mut u32) -> HANDLE;
81-
type AvRevertMmThreadCharacteristicsFn = unsafe extern "system" fn(HANDLE) -> BOOL;
81+
type AvRevertMmThreadCharacteristicsFn = unsafe extern "system" fn(HANDLE) -> i32;
8282

8383
#[derive(Debug)]
8484
pub(super) struct AvRtLibrary {
@@ -137,7 +137,7 @@ mod avrt_lib {
137137
let task_handle = unsafe {
138138
(self.av_set_mm_thread_characteristics_w)(task_name, &mut mmcss_task_index)
139139
};
140-
win32_error_if(task_handle == 0)?;
140+
win32_error_if(task_handle.is_null())?;
141141
Ok((mmcss_task_index, task_handle))
142142
}
143143

@@ -174,7 +174,7 @@ mod win32_utils {
174174
impl OwnedLibrary {
175175
pub(super) fn try_new(lib_file_name: PCWSTR) -> Result<Self, WIN32_ERROR> {
176176
let module = unsafe { LoadLibraryW(lib_file_name) };
177-
win32_error_if(module == 0)?;
177+
win32_error_if(module.is_null())?;
178178
Ok(Self(module))
179179
}
180180

@@ -194,6 +194,9 @@ mod win32_utils {
194194
}
195195
}
196196

197+
unsafe impl Send for OwnedLibrary {}
198+
unsafe impl Sync for OwnedLibrary {}
199+
197200
impl Drop for OwnedLibrary {
198201
fn drop(&mut self) {
199202
unsafe {

0 commit comments

Comments
 (0)