File tree Expand file tree Collapse file tree 4 files changed +27
-0
lines changed
library/std/src/sys/windows Expand file tree Collapse file tree 4 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -2623,3 +2623,6 @@ Windows.Win32.System.Threading.GetCurrentThreadId
26232623Windows.Win32.Networking.WinSock.WSAPROTOCOL_INFOA
26242624Windows.Win32.Networking.WinSock.WSASocketA
26252625Windows.Win32.Networking.WinSock.WSADuplicateSocketA
2626+
2627+ // NT vs 9x compat
2628+ Windows.Win32.System.SystemInformation.GetVersion
Original file line number Diff line number Diff line change @@ -401,6 +401,10 @@ extern "system" {
401401 pub fn GetTickCount ( ) -> u32 ;
402402}
403403#[ link( name = "kernel32" ) ]
404+ extern "system" {
405+ pub fn GetVersion ( ) -> u32 ;
406+ }
407+ #[ link( name = "kernel32" ) ]
404408extern "system" {
405409 pub fn GetWindowsDirectoryW ( lpbuffer : PWSTR , usize : u32 ) -> u32 ;
406410}
Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ use crate::ptr::NonNull;
2424use crate :: sync:: atomic:: Ordering ;
2525use crate :: sys:: c;
2626
27+ mod version;
28+ pub use version:: is_windows_nt;
29+
2730// This uses a static initializer to preload some imported functions.
2831// The CRT (C runtime) executes static initializers before `main`
2932// is called (for binaries) and before `DllMain` is called (for DLLs).
@@ -63,6 +66,8 @@ unsafe extern "C" fn init() {
6366 // because this function runs during global initialization. For example, DO NOT
6467 // do any dynamic allocation, don't call LoadLibrary, etc.
6568
69+ version:: init_windows_version_check ( ) ;
70+
6671 // check all the different synchronization primitives ...
6772 load_try_enter_critical_section_function ( ) ;
6873 load_srw_functions ( ) ;
Original file line number Diff line number Diff line change 1+ use crate :: sys:: c;
2+
3+ static mut IS_NT : bool = true ;
4+
5+ pub fn init_windows_version_check ( ) {
6+ // according to old MSDN info, the high-order bit is set only on 95/98/ME.
7+ unsafe { IS_NT = c:: GetVersion ( ) < 0x8000_0000 } ;
8+ }
9+
10+ /// Returns true if we are running on a Windows NT-based system. Only use this for APIs where the
11+ /// same API differs in behavior or capability on 9x/ME compared to NT.
12+ #[ inline( always) ]
13+ pub fn is_windows_nt ( ) -> bool {
14+ unsafe { IS_NT }
15+ }
You can’t perform that action at this time.
0 commit comments