From d7b2fd4213971edd09ed72f9a6541a036d016666 Mon Sep 17 00:00:00 2001 From: Geoffry Song Date: Wed, 21 Aug 2024 14:37:39 -0700 Subject: [PATCH 1/2] Clean up cfg-gating of ProcessPrng extern --- library/std/src/sys/pal/windows/c.rs | 29 +++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/library/std/src/sys/pal/windows/c.rs b/library/std/src/sys/pal/windows/c.rs index 2f5d75dc4bc23..8900410cf609b 100644 --- a/library/std/src/sys/pal/windows/c.rs +++ b/library/std/src/sys/pal/windows/c.rs @@ -109,19 +109,22 @@ if #[cfg(not(target_vendor = "uwp"))] { } // Use raw-dylib to import ProcessPrng as we can't rely on there being an import library. -cfg_if::cfg_if! { -if #[cfg(not(target_vendor = "win7"))] { - #[cfg(target_arch = "x86")] - #[link(name = "bcryptprimitives", kind = "raw-dylib", import_name_type = "undecorated")] - extern "system" { - pub fn ProcessPrng(pbdata: *mut u8, cbdata: usize) -> BOOL; - } - #[cfg(not(target_arch = "x86"))] - #[link(name = "bcryptprimitives", kind = "raw-dylib")] - extern "system" { - pub fn ProcessPrng(pbdata: *mut u8, cbdata: usize) -> BOOL; - } -}} +#[cfg(not(target_vendor = "win7"))] +#[cfg_attr( + target_arch = "x86", + link( + name = "bcryptprimitives", + kind = "raw-dylib", + import_name_type = "undecorated" + ) +)] +#[cfg_attr( + not(target_arch = "x86"), + link(name = "bcryptprimitives", kind = "raw-dylib") +)] +extern "system" { + pub fn ProcessPrng(pbdata: *mut u8, cbdata: usize) -> BOOL; +} // 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. From 40481fc70a8626f9e58242b0fb673d90ade2f084 Mon Sep 17 00:00:00 2001 From: Geoffry Song Date: Wed, 21 Aug 2024 15:34:51 -0700 Subject: [PATCH 2/2] format --- library/std/src/sys/pal/windows/c.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/library/std/src/sys/pal/windows/c.rs b/library/std/src/sys/pal/windows/c.rs index 8900410cf609b..b888eb7d95ca3 100644 --- a/library/std/src/sys/pal/windows/c.rs +++ b/library/std/src/sys/pal/windows/c.rs @@ -112,16 +112,9 @@ if #[cfg(not(target_vendor = "uwp"))] { #[cfg(not(target_vendor = "win7"))] #[cfg_attr( target_arch = "x86", - link( - name = "bcryptprimitives", - kind = "raw-dylib", - import_name_type = "undecorated" - ) -)] -#[cfg_attr( - not(target_arch = "x86"), - link(name = "bcryptprimitives", kind = "raw-dylib") + link(name = "bcryptprimitives", kind = "raw-dylib", import_name_type = "undecorated") )] +#[cfg_attr(not(target_arch = "x86"), link(name = "bcryptprimitives", kind = "raw-dylib"))] extern "system" { pub fn ProcessPrng(pbdata: *mut u8, cbdata: usize) -> BOOL; }