File tree 4 files changed +27
-0
lines changed
library/std/src/sys/windows
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
2623
2623
Windows.Win32.Networking.WinSock.WSAPROTOCOL_INFOA
2624
2624
Windows.Win32.Networking.WinSock.WSASocketA
2625
2625
Windows.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" {
401
401
pub fn GetTickCount ( ) -> u32 ;
402
402
}
403
403
#[ link( name = "kernel32" ) ]
404
+ extern "system" {
405
+ pub fn GetVersion ( ) -> u32 ;
406
+ }
407
+ #[ link( name = "kernel32" ) ]
404
408
extern "system" {
405
409
pub fn GetWindowsDirectoryW ( lpbuffer : PWSTR , usize : u32 ) -> u32 ;
406
410
}
Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ use crate::ptr::NonNull;
24
24
use crate :: sync:: atomic:: Ordering ;
25
25
use crate :: sys:: c;
26
26
27
+ mod version;
28
+ pub use version:: is_windows_nt;
29
+
27
30
// This uses a static initializer to preload some imported functions.
28
31
// The CRT (C runtime) executes static initializers before `main`
29
32
// is called (for binaries) and before `DllMain` is called (for DLLs).
@@ -63,6 +66,8 @@ unsafe extern "C" fn init() {
63
66
// because this function runs during global initialization. For example, DO NOT
64
67
// do any dynamic allocation, don't call LoadLibrary, etc.
65
68
69
+ version:: init_windows_version_check ( ) ;
70
+
66
71
// check all the different synchronization primitives ...
67
72
load_try_enter_critical_section_function ( ) ;
68
73
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