fix special case

This commit is contained in:
quackerd 2023-03-05 15:00:11 +01:00
parent 03569479b7
commit bf02bf171f
2 changed files with 12 additions and 5 deletions

View File

@ -4,10 +4,12 @@ project(bsdtopo)
find_package(PkgConfig REQUIRED)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(LIBVER 1.1.0)
set(LIBVER 1.1.1)
pkg_check_modules(XML libxml-2.0 REQUIRED)
set(C_FLAGS -O2 -g -Wall -Wextra -Werror -Wpedantic -Wconversion -std=c17
set(C_FLAGS -O3 -g -Wall -Wextra -Werror -Wpedantic -Wconversion -std=c17
-march=native -DNDEBUG)
set(C_FLAGS_DBG -Og -g -Wall -Wextra -Werror -Wpedantic -Wconversion -std=c17
-march=native)
include_directories(${CMAKE_SOURCE_DIR}/inc)
@ -17,10 +19,15 @@ target_compile_options(bsdtopo PRIVATE ${C_FLAGS} ${XML_CFLAGS})
target_include_directories(bsdtopo PRIVATE ${XML_INCLUDE_DIRS})
target_link_libraries(bsdtopo PRIVATE ${XML_LINK_LIBRARIES})
add_library(bsdtopo_debug SHARED topo.c timestamp.c)
target_compile_options(bsdtopo_debug PRIVATE ${C_FLAGS_DBG} ${XML_CFLAGS})
target_include_directories(bsdtopo_debug PRIVATE ${XML_INCLUDE_DIRS})
target_link_libraries(bsdtopo_debug PRIVATE ${XML_LINK_LIBRARIES})
add_executable(test test/test.c)
set_target_properties(test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/test)
target_link_libraries(test PRIVATE bsdtopo)
target_compile_options(test PRIVATE ${C_FLAGS})
target_link_libraries(test PRIVATE bsdtopo_debug)
target_compile_options(test PRIVATE ${C_FLAGS_DBG})
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/bsdtopo.pc.in

2
topo.c
View File

@ -353,7 +353,7 @@ tobj_get_num_numa(struct topo_obj * root)
root = root->parent;
}
if (tobj_is_node_numa(root)) {
if (tobj_is_node_numa(root) && root->num_children > 0) {
return root->num_children;
} else {
return 1;