File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed
library/std/src/sys/windows Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -721,4 +721,5 @@ extern "system" {
721721
722722 pub fn GetTickCount ( ) -> DWORD ;
723723 pub fn GetCurrentThreadId ( ) -> DWORD ;
724+ pub fn GetVersion ( ) -> DWORD ;
724725}
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ use crate::ptr::NonNull;
2424use crate :: sync:: atomic:: Ordering ;
2525use crate :: sys:: c;
2626
27+ pub ( crate ) mod version;
28+
2729// This uses a static initializer to preload some imported functions.
2830// The CRT (C runtime) executes static initializers before `main`
2931// is called (for binaries) and before `DllMain` is called (for DLLs).
@@ -65,6 +67,8 @@ unsafe extern "C" fn init() {
6567
6668 // Attempt to preload the synch functions.
6769 load_synch_functions ( ) ;
70+ // Determine if running on 9x or NT
71+ version:: init ( ) ;
6872}
6973
7074/// Helper macro for creating CStrs from literals and symbol names.
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 ( super ) unsafe extern "C" fn init ( ) {
6+ // according to old MSDN info, the high-order bit is set only on 95/98/ME.
7+ 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 ( crate ) fn is_windows_nt ( ) -> bool {
14+ unsafe { IS_NT }
15+ }
You can’t perform that action at this time.
0 commit comments