mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-09 03:10:27 +00:00
Optimise windows version checking
Added GetNtMinorVersion() and IsAtleastWindows8p1() macros which get nt version info from the peb.
This commit is contained in:
parent
5d3ed30af1
commit
1e04918663
2 changed files with 11 additions and 2 deletions
|
@ -9,6 +9,8 @@ bool32 GetVersionEx(struct NtOsVersionInfo *lpVersionInformation);
|
|||
|
||||
#if defined(__GCC_ASM_FLAG_OUTPUTS__) && !defined(__STRICT_ANSI__)
|
||||
#define IsAtLeastWindows10() (GetNtMajorVersion() >= 10)
|
||||
#define IsAtleastWindows8p1() \
|
||||
(GetNtMajorVersion() > 6 || (GetNtMajorVersion() == 6 && GetNtMinorVersion() == 3))
|
||||
#define GetNtMajorVersion() \
|
||||
({ \
|
||||
uintptr_t __x; \
|
||||
|
@ -17,6 +19,14 @@ bool32 GetVersionEx(struct NtOsVersionInfo *lpVersionInformation);
|
|||
: "=q"(__x)); \
|
||||
(unsigned char)__x; \
|
||||
})
|
||||
#define GetNtMinorVersion() \
|
||||
({ \
|
||||
uintptr_t __x; \
|
||||
asm("mov\t%%gs:96,%q0\r\n" \
|
||||
"mov\t284(%q0),%b0" \
|
||||
: "=q"(__x)); \
|
||||
(unsigned char)__x; \
|
||||
})
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/thread/tls.h"
|
||||
#include "libc/nt/version.h"
|
||||
#include "libc/nt/enum/version.h"
|
||||
#include "libc/runtime/stack.h"
|
||||
#include "libc/sysv/consts/ss.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
@ -39,7 +38,7 @@ COSMOPOLITAN_C_START_
|
|||
#define _kMem(NORMAL, WIN7) \
|
||||
(!IsWindows() || IsAtLeastWindows10() ? NORMAL : WIN7)
|
||||
#define _kMemVista(NORMAL, WINVISTA) \
|
||||
(!IsWindows() || NtGetVersion() >= kNtVersionWindows81 ? NORMAL : WINVISTA)
|
||||
(!IsWindows() || IsAtleastWindows8p1() ? NORMAL : WINVISTA)
|
||||
|
||||
struct MemoryInterval {
|
||||
int x;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue