File tree Expand file tree Collapse file tree 3 files changed +12
-12
lines changed
library/std/src/sys/windows Expand file tree Collapse file tree 3 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -2477,11 +2477,11 @@ Windows.Win32.System.Pipes.PIPE_TYPE_BYTE
24772477Windows.Win32.System.Pipes.PIPE_TYPE_MESSAGE
24782478Windows.Win32.System.Pipes.PIPE_WAIT
24792479Windows.Win32.System.SystemInformation.GetSystemDirectoryW
2480- Windows.Win32.System.SystemInformation.GetSystemInfo
24812480Windows.Win32.System.SystemInformation.GetSystemTimeAsFileTime
24822481Windows.Win32.System.SystemInformation.GetWindowsDirectoryW
24832482Windows.Win32.System.SystemInformation.PROCESSOR_ARCHITECTURE
24842483Windows.Win32.System.SystemInformation.SYSTEM_INFO
2484+ Windows.Win32.System.SystemServices.ALL_PROCESSOR_GROUPS
24852485Windows.Win32.System.SystemServices.DLL_PROCESS_DETACH
24862486Windows.Win32.System.SystemServices.DLL_THREAD_DETACH
24872487Windows.Win32.System.SystemServices.EXCEPTION_MAXIMUM_PARAMETERS
@@ -2513,6 +2513,7 @@ Windows.Win32.System.Threading.DEBUG_PROCESS
25132513Windows.Win32.System.Threading.DETACHED_PROCESS
25142514Windows.Win32.System.Threading.ExitProcess
25152515Windows.Win32.System.Threading.EXTENDED_STARTUPINFO_PRESENT
2516+ Windows.Win32.System.Threading.GetActiveProcessorCount
25162517Windows.Win32.System.Threading.GetCurrentProcess
25172518Windows.Win32.System.Threading.GetCurrentProcessId
25182519Windows.Win32.System.Threading.GetCurrentThread
Original file line number Diff line number Diff line change @@ -219,6 +219,10 @@ extern "system" {
219219 pub fn FreeEnvironmentStringsW ( penv : PCWSTR ) -> BOOL ;
220220}
221221#[ link( name = "kernel32" ) ]
222+ extern "system" {
223+ pub fn GetActiveProcessorCount ( groupnumber : u16 ) -> u32 ;
224+ }
225+ #[ link( name = "kernel32" ) ]
222226extern "system" {
223227 pub fn GetCommandLineW ( ) -> PCWSTR ;
224228}
@@ -338,10 +342,6 @@ extern "system" {
338342 pub fn GetSystemDirectoryW ( lpbuffer : PWSTR , usize : u32 ) -> u32 ;
339343}
340344#[ link( name = "kernel32" ) ]
341- extern "system" {
342- pub fn GetSystemInfo ( lpsysteminfo : * mut SYSTEM_INFO ) -> ( ) ;
343- }
344- #[ link( name = "kernel32" ) ]
345345extern "system" {
346346 pub fn GetSystemTimeAsFileTime ( lpsystemtimeasfiletime : * mut FILETIME ) -> ( ) ;
347347}
@@ -822,6 +822,7 @@ impl ::core::clone::Clone for ADDRINFOA {
822822pub const AF_INET : ADDRESS_FAMILY = 2u16 ;
823823pub const AF_INET6 : ADDRESS_FAMILY = 23u16 ;
824824pub const AF_UNSPEC : ADDRESS_FAMILY = 0u16 ;
825+ pub const ALL_PROCESSOR_GROUPS : u32 = 65535u32 ;
825826#[ repr( C ) ]
826827pub union ARM64_NT_NEON128 {
827828 pub Anonymous : ARM64_NT_NEON128_0 ,
Original file line number Diff line number Diff line change @@ -101,15 +101,13 @@ impl Thread {
101101
102102pub fn available_parallelism ( ) -> io:: Result < NonZeroUsize > {
103103 let res = unsafe {
104- let mut sysinfo: c:: SYSTEM_INFO = crate :: mem:: zeroed ( ) ;
105- c:: GetSystemInfo ( & mut sysinfo) ;
106- sysinfo. dwNumberOfProcessors as usize
104+ // FIXME: windows::Win32::System::SystemServices::ALL_PROCESSOR_GROUPS should be u16, not u32
105+ // FIXME: if you need even more accurate result on 32-bit Windows with more, than 64 cores,
106+ // consider implementing this using GetLogicalProcessorInformationEx
107+ c:: GetActiveProcessorCount ( c:: ALL_PROCESSOR_GROUPS as u16 ) as usize
107108 } ;
108109 match res {
109- 0 => Err ( io:: const_io_error!(
110- io:: ErrorKind :: NotFound ,
111- "The number of hardware threads is not known for the target platform" ,
112- ) ) ,
110+ 0 => Err ( io:: Error :: last_os_error ( ) ) ,
113111 cpus => Ok ( unsafe { NonZeroUsize :: new_unchecked ( cpus) } ) ,
114112 }
115113}
You can’t perform that action at this time.
0 commit comments