about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-06-11 00:35:36 +0000
committerbors <bors@rust-lang.org>2023-06-11 00:35:36 +0000
commit970058e16b307e1cff01e2ddb084d2e8d14ea8be (patch)
tree8d33cb2cd310d8dcd2bc2ddf27891c2f0c848601 /library/std/src/sys
parentb8a50010de397df570b38fe67bda435b665e2d86 (diff)
parent46b64aaef097cab420311834eb58b5d05ea408a7 (diff)
downloadrust-970058e16b307e1cff01e2ddb084d2e8d14ea8be.tar.gz
rust-970058e16b307e1cff01e2ddb084d2e8d14ea8be.zip
Auto merge of #112512 - matthiaskrgr:rollup-o2jh1jx, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #112475 (Fix issue for module name when surround the struct literal with parentheses)
 - #112477 (Give more helpful progress messages in `Assemble`)
 - #112484 (Fix ntdll linkage issues on Windows UWP platforms)
 - #112492 (Migrate GUI colors test to original CSS color format)
 - #112493 (iat selection: normalize self ty & completely erase bound vars)
 - #112497 (abs_sub: fix typo 0[-:][+.]0)
 - #112498 (Update links to Rust Reference in diagnostic)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/windows/c.rs55
-rw-r--r--library/std/src/sys/windows/c/windows_sys.lst1
-rw-r--r--library/std/src/sys/windows/c/windows_sys.rs1
-rw-r--r--library/std/src/sys/windows/rand.rs5
4 files changed, 60 insertions, 2 deletions
diff --git a/library/std/src/sys/windows/c.rs b/library/std/src/sys/windows/c.rs
index 07b0610d463..5fc6136ba1f 100644
--- a/library/std/src/sys/windows/c.rs
+++ b/library/std/src/sys/windows/c.rs
@@ -19,6 +19,7 @@ pub use windows_sys::*;
 pub type DWORD = c_ulong;
 pub type NonZeroDWORD = NonZero_c_ulong;
 pub type LARGE_INTEGER = c_longlong;
+#[cfg_attr(target_vendor = "uwp", allow(unused))]
 pub type LONG = c_long;
 pub type UINT = c_uint;
 pub type WCHAR = u16;
@@ -267,6 +268,8 @@ pub unsafe fn getaddrinfo(
     windows_sys::getaddrinfo(node.cast::<u8>(), service.cast::<u8>(), hints, res)
 }
 
+cfg_if::cfg_if! {
+if #[cfg(not(target_vendor = "uwp"))] {
 pub unsafe fn NtReadFile(
     filehandle: BorrowedHandle<'_>,
     event: HANDLE,
@@ -313,6 +316,8 @@ pub unsafe fn NtWriteFile(
         key.map(|k| k as *const u32).unwrap_or(ptr::null()),
     )
 }
+}
+}
 
 // Functions that aren't available on every version of Windows that we support,
 // but we still use them and just provide some form of a fallback implementation.
@@ -376,4 +381,54 @@ compat_fn_with_fallback! {
     ) -> NTSTATUS {
         panic!("keyed events not available")
     }
+
+    // These functions are available on UWP when lazily loaded. They will fail WACK if loaded statically.
+    #[cfg(target_vendor = "uwp")]
+    pub fn NtCreateFile(
+        filehandle: *mut HANDLE,
+        desiredaccess: FILE_ACCESS_RIGHTS,
+        objectattributes: *const OBJECT_ATTRIBUTES,
+        iostatusblock: *mut IO_STATUS_BLOCK,
+        allocationsize: *const i64,
+        fileattributes: FILE_FLAGS_AND_ATTRIBUTES,
+        shareaccess: FILE_SHARE_MODE,
+        createdisposition: NTCREATEFILE_CREATE_DISPOSITION,
+        createoptions: NTCREATEFILE_CREATE_OPTIONS,
+        eabuffer: *const ::core::ffi::c_void,
+        ealength: u32
+    ) -> NTSTATUS {
+        STATUS_NOT_IMPLEMENTED
+    }
+    #[cfg(target_vendor = "uwp")]
+    pub fn NtReadFile(
+        filehandle: BorrowedHandle<'_>,
+        event: HANDLE,
+        apcroutine: PIO_APC_ROUTINE,
+        apccontext: *mut c_void,
+        iostatusblock: &mut IO_STATUS_BLOCK,
+        buffer: *mut crate::mem::MaybeUninit<u8>,
+        length: ULONG,
+        byteoffset: Option<&LARGE_INTEGER>,
+        key: Option<&ULONG>
+    ) -> NTSTATUS {
+        STATUS_NOT_IMPLEMENTED
+    }
+    #[cfg(target_vendor = "uwp")]
+    pub fn NtWriteFile(
+        filehandle: BorrowedHandle<'_>,
+        event: HANDLE,
+        apcroutine: PIO_APC_ROUTINE,
+        apccontext: *mut c_void,
+        iostatusblock: &mut IO_STATUS_BLOCK,
+        buffer: *const u8,
+        length: ULONG,
+        byteoffset: Option<&LARGE_INTEGER>,
+        key: Option<&ULONG>
+    ) -> NTSTATUS {
+        STATUS_NOT_IMPLEMENTED
+    }
+    #[cfg(target_vendor = "uwp")]
+    pub fn RtlNtStatusToDosError(Status: NTSTATUS) -> u32 {
+        Status as u32
+    }
 }
diff --git a/library/std/src/sys/windows/c/windows_sys.lst b/library/std/src/sys/windows/c/windows_sys.lst
index 3e454199f13..2cf1ade99ce 100644
--- a/library/std/src/sys/windows/c/windows_sys.lst
+++ b/library/std/src/sys/windows/c/windows_sys.lst
@@ -1930,6 +1930,7 @@ Windows.Win32.Foundation.SetLastError
 Windows.Win32.Foundation.STATUS_DELETE_PENDING
 Windows.Win32.Foundation.STATUS_END_OF_FILE
 Windows.Win32.Foundation.STATUS_INVALID_PARAMETER
+Windows.Win32.Foundation.STATUS_NOT_IMPLEMENTED
 Windows.Win32.Foundation.STATUS_PENDING
 Windows.Win32.Foundation.STATUS_SUCCESS
 Windows.Win32.Foundation.TRUE
diff --git a/library/std/src/sys/windows/c/windows_sys.rs b/library/std/src/sys/windows/c/windows_sys.rs
index 36a30f6ba56..8c8b006a1d3 100644
--- a/library/std/src/sys/windows/c/windows_sys.rs
+++ b/library/std/src/sys/windows/c/windows_sys.rs
@@ -3888,6 +3888,7 @@ pub type STARTUPINFOW_FLAGS = u32;
 pub const STATUS_DELETE_PENDING: NTSTATUS = -1073741738i32;
 pub const STATUS_END_OF_FILE: NTSTATUS = -1073741807i32;
 pub const STATUS_INVALID_PARAMETER: NTSTATUS = -1073741811i32;
+pub const STATUS_NOT_IMPLEMENTED: NTSTATUS = -1073741822i32;
 pub const STATUS_PENDING: NTSTATUS = 259i32;
 pub const STATUS_SUCCESS: NTSTATUS = 0i32;
 pub const STD_ERROR_HANDLE: STD_HANDLE = 4294967284u32;
diff --git a/library/std/src/sys/windows/rand.rs b/library/std/src/sys/windows/rand.rs
index bca4e38d9f6..5d8fd13785a 100644
--- a/library/std/src/sys/windows/rand.rs
+++ b/library/std/src/sys/windows/rand.rs
@@ -1,5 +1,3 @@
-use crate::ffi::c_void;
-use crate::io;
 use crate::mem;
 use crate::ptr;
 use crate::sys::c;
@@ -25,6 +23,9 @@ pub fn hashmap_random_keys() -> (u64, u64) {
 #[cfg(not(target_vendor = "uwp"))]
 #[inline(never)]
 fn fallback_rng() -> (u64, u64) {
+    use crate::ffi::c_void;
+    use crate::io;
+
     let mut v = (0, 0);
     let ret = unsafe {
         c::RtlGenRandom(&mut v as *mut _ as *mut c_void, mem::size_of_val(&v) as c::ULONG)