Skip to content

Commit

Permalink
shims: correct the check for newer SLPI enumerators
Browse files Browse the repository at this point in the history
The previous check did not work as the enumertors are not defines but
rather a proper enumerator.  This adds a build time check for the
support and conditionalises the compilation.
  • Loading branch information
compnerd committed Sep 11, 2021
1 parent 34f383d commit c2a57f0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
include_directories(BEFORE SYSTEM ${DISPATCH_INCLUDES})
dispatch_windows_lib_for_arch(${CMAKE_SYSTEM_PROCESSOR} DISPATCH_LIBDIR)
link_directories(${DISPATCH_LIBDIR})

include(CheckCSourceCompiles)
check_c_source_compiles([=[
#include <Windows.h>
int main(int argc, char *argv[]) {
switch ((LOGICAL_PROCESSOR_RELATIONSHIP)0) {
case RelationProcessorDie:
case RelationNumaNodeEx:
return 0;
}
return 0;
}
]=] DISPATCH_HAVE_EXTENDED_SLPI_20348)
if(DISPATCH_HAVE_EXTENDED_SLPI_20348)
add_compile_definitions(DISPATCH_HAVE_EXTENDED_SLPI_20348)
endif()
endif()

set(CMAKE_C_STANDARD 11)
Expand Down
6 changes: 6 additions & 0 deletions src/shims/hw_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,14 @@ _dispatch_hw_get_config(_dispatch_hw_config_t c)
++dwProcessorPhysicalCount;
dwProcessorLogicalCount += __popcnt64(slpiCurrent->ProcessorMask);
break;
#if defined(DISPATCH_HAVE_EXTENDED_SLPI_20348)
case RelationProcessorDie:
#endif
case RelationProcessorPackage:
case RelationNumaNode:
#if defined(DISPATCH_HAVE_EXTENDED_SLPI_20348)
case RelationNumaNodeEx:
#endif
case RelationCache:
case RelationGroup:
case RelationAll:
Expand Down

0 comments on commit c2a57f0

Please sign in to comment.