Skip to content

Commit a824ab0

Browse files
committed
Goofy ahh TryAcquireSRWLock workaround (I forgor to commit)
1 parent 70acf29 commit a824ab0

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

library/std/src/sys/pal/windows/c.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ pub type WORD = u16;
2929
pub type CHAR = c_char;
3030
pub type ULONG = c_ulong;
3131
pub type ACCESS_MASK = DWORD;
32+
pub type BOOLEAN = i32;
33+
pub const TRUE: BOOLEAN = 1;
34+
pub const FALSE: BOOLEAN = 0;
3235

3336
pub type LPCVOID = *const c_void;
3437
pub type LPHANDLE = *mut HANDLE;
@@ -234,6 +237,16 @@ pub unsafe extern "system" fn ReadFileEx(
234237
)
235238
}
236239

240+
pub unsafe fn TryAcquireSRWLockExclusive(srwlock: *mut SRWLOCK) -> BOOLEAN {
241+
AcquireSRWLockExclusive(srwlock);
242+
TRUE // Always return TRUE for blocking lock
243+
}
244+
245+
pub unsafe fn TryAcquireSRWLockShared(srwlock: *mut SRWLOCK) -> BOOLEAN {
246+
AcquireSRWLockShared(srwlock);
247+
TRUE // Always return TRUE for blocking lock
248+
}
249+
237250
// POSIX compatibility shims.
238251
pub unsafe fn recv(socket: SOCKET, buf: *mut c_void, len: c_int, flags: c_int) -> c_int {
239252
windows_sys::recv(socket, buf.cast::<u8>(), len, flags)

library/std/src/sys/pal/windows/c/windows_sys.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -569,14 +569,6 @@ extern "system" {
569569
pub fn TlsSetValue(dwtlsindex: u32, lptlsvalue: *const ::core::ffi::c_void) -> BOOL;
570570
}
571571
#[link(name = "kernel32")]
572-
extern "system" {
573-
pub fn TryAcquireSRWLockExclusive(srwlock: *mut SRWLOCK) -> BOOLEAN;
574-
}
575-
#[link(name = "kernel32")]
576-
extern "system" {
577-
pub fn TryAcquireSRWLockShared(srwlock: *mut SRWLOCK) -> BOOLEAN;
578-
}
579-
#[link(name = "kernel32")]
580572
extern "system" {
581573
pub fn UpdateProcThreadAttribute(
582574
lpattributelist: LPPROC_THREAD_ATTRIBUTE_LIST,

0 commit comments

Comments
 (0)