Skip to content

Commit

Permalink
Goofy ahh TryAcquireSRWLock workaround (I forgor to commit)
Browse files Browse the repository at this point in the history
  • Loading branch information
K4sum1 committed Jul 27, 2024
1 parent 70acf29 commit a824ab0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
13 changes: 13 additions & 0 deletions library/std/src/sys/pal/windows/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ pub type WORD = u16;
pub type CHAR = c_char;
pub type ULONG = c_ulong;
pub type ACCESS_MASK = DWORD;
pub type BOOLEAN = i32;
pub const TRUE: BOOLEAN = 1;
pub const FALSE: BOOLEAN = 0;

pub type LPCVOID = *const c_void;
pub type LPHANDLE = *mut HANDLE;
Expand Down Expand Up @@ -234,6 +237,16 @@ pub unsafe extern "system" fn ReadFileEx(
)
}

pub unsafe fn TryAcquireSRWLockExclusive(srwlock: *mut SRWLOCK) -> BOOLEAN {
AcquireSRWLockExclusive(srwlock);
TRUE // Always return TRUE for blocking lock
}

pub unsafe fn TryAcquireSRWLockShared(srwlock: *mut SRWLOCK) -> BOOLEAN {
AcquireSRWLockShared(srwlock);
TRUE // Always return TRUE for blocking lock
}

// POSIX compatibility shims.
pub unsafe fn recv(socket: SOCKET, buf: *mut c_void, len: c_int, flags: c_int) -> c_int {
windows_sys::recv(socket, buf.cast::<u8>(), len, flags)
Expand Down
8 changes: 0 additions & 8 deletions library/std/src/sys/pal/windows/c/windows_sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,14 +569,6 @@ extern "system" {
pub fn TlsSetValue(dwtlsindex: u32, lptlsvalue: *const ::core::ffi::c_void) -> BOOL;
}
#[link(name = "kernel32")]
extern "system" {
pub fn TryAcquireSRWLockExclusive(srwlock: *mut SRWLOCK) -> BOOLEAN;
}
#[link(name = "kernel32")]
extern "system" {
pub fn TryAcquireSRWLockShared(srwlock: *mut SRWLOCK) -> BOOLEAN;
}
#[link(name = "kernel32")]
extern "system" {
pub fn UpdateProcThreadAttribute(
lpattributelist: LPPROC_THREAD_ATTRIBUTE_LIST,
Expand Down

0 comments on commit a824ab0

Please sign in to comment.