diff --git a/library/std/src/sys/pal/windows/c.rs b/library/std/src/sys/pal/windows/c.rs index 1a59ac9a9cadf..21000033e47bc 100644 --- a/library/std/src/sys/pal/windows/c.rs +++ b/library/std/src/sys/pal/windows/c.rs @@ -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; @@ -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::(), len, flags) diff --git a/library/std/src/sys/pal/windows/c/windows_sys.rs b/library/std/src/sys/pal/windows/c/windows_sys.rs index b38b70c8983e6..ed4c17b98248f 100644 --- a/library/std/src/sys/pal/windows/c/windows_sys.rs +++ b/library/std/src/sys/pal/windows/c/windows_sys.rs @@ -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,