Skip to content

Commit

Permalink
Add enum value from newest Windows SDK (#1859)
Browse files Browse the repository at this point in the history
* Add enum value from newest Windows SDK

Windows SDK version 10.0.26100.0 adds a cache type value, `CacheUnknown`. This adds a case for that type to `sysinfo.cc`, which will otherwise complain about the switch statement being non-exhaustive when building with the new SDK.

Since the value doesn't exist in prior SDK versions, we only add the case conditionally. The condition can be removed if we ever decide to bump up the required SDK version.

* Fix SDK version macro

Make sure the version macro we're using for the SDK is properly indicative of version 10.0.26100.0. Also fix formatting complains from the linter.

* Add space to satisfy formatter

Formatter insists on two space before a comment after a macro...

* Change preprocessor condition

Try detecting the current SDK version in a slightly different way.

* Replace NTDDI_WIN11_GE with its value

Undefined constants are treated as 0 by the preprocessor, which causes the check to trivially return true for previous SDK versions. Replace the constant with its value (from the newest SDK version) instead,
  • Loading branch information
DKLoehr authored Oct 2, 2024
1 parent 23d8c1e commit 24e0bd8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/sysinfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,12 @@ std::vector<CPUInfo::CacheInfo> GetCacheSizesWindows() {
C.size = static_cast<int>(cache.Size);
C.type = "Unknown";
switch (cache.Type) {
// Windows SDK version >= 10.0.26100.0
// 0x0A000010 is the value of NTDDI_WIN11_GE
#if NTDDI_VERSION >= 0x0A000010
case CacheUnknown:
break;
#endif
case CacheUnified:
C.type = "Unified";
break;
Expand Down

0 comments on commit 24e0bd8

Please sign in to comment.