-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added program to dump system info we can determine for use with testi…
…ng, added api for detecting virt vendor.
- Loading branch information
1 parent
d09b75e
commit 43d1b92
Showing
8 changed files
with
166 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
project(print-sys-info C) | ||
|
||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_INSTALL_PREFIX}/lib/cmake") | ||
|
||
file(GLOB SI_SRC | ||
"*.c" | ||
) | ||
|
||
set(SI_PROJECT_NAME print-sys-info) | ||
add_executable(${SI_PROJECT_NAME} ${SI_SRC}) | ||
aws_set_common_properties(${SI_PROJECT_NAME}) | ||
|
||
|
||
target_include_directories(${SI_PROJECT_NAME} PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include>) | ||
|
||
target_link_libraries(${SI_PROJECT_NAME} PRIVATE aws-c-common) | ||
|
||
install(TARGETS ${SI_PROJECT_NAME} | ||
EXPORT ${SI_PROJECT_NAME}-targets | ||
COMPONENT Runtime | ||
RUNTIME | ||
DESTINATION bin | ||
COMPONENT Runtime) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
|
||
|
||
#include <aws/common/system_info.h> | ||
#include <aws/common/byte_buf.h> | ||
|
||
int main(void) { | ||
struct aws_allocator *allocator = aws_default_allocator(); | ||
struct aws_system_environment *env = aws_system_environment_load(allocator); | ||
|
||
fprintf(stdout, "crt-detected env: {\n"); | ||
|
||
struct aws_byte_cursor virtualization_vendor = aws_system_environment_get_virtualization_vendor(env); | ||
fprintf(stdout, " 'virtualization vendor': '" PRInSTR "'\n", (int)virtualization_vendor.len, virtualization_vendor.ptr); | ||
fprintf(stdout, " 'number of processors': '%lu'\n", (unsigned long)aws_system_environment_get_processor_count(env)); | ||
size_t numa_nodes = aws_system_environment_get_cpu_group_count(env); | ||
|
||
if (numa_nodes > 1) { | ||
fprintf(stdout, " 'numa architecture': 'true'\n"); | ||
fprintf(stdout, " 'number of numa nodes': '%lu'\n", (unsigned long)numa_nodes); | ||
} else { | ||
fprintf(stdout, " 'numa architecture': 'false'\n"); | ||
} | ||
|
||
fprintf(stdout, "}\n"); | ||
aws_system_environment_destroy(env); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef AWS_COMMON_SYSTEM_INFO_PRIV_H | ||
#define AWS_COMMON_SYSTEM_INFO_PRIV_H | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
|
||
#include <aws/common/system_info.h> | ||
#include <aws/common/byte_buf.h> | ||
#include <aws/common/string.h> | ||
|
||
struct aws_system_environment { | ||
struct aws_allocator *allocator; | ||
struct aws_byte_buf virtualization_vendor; | ||
enum aws_platform_os os; | ||
size_t cpu_count; | ||
size_t cpu_group_count; | ||
void *additional_impl_data; | ||
}; | ||
|
||
int aws_system_environment_load_platform_impl(struct aws_system_environment *env); | ||
void aws_system_environment_destroy_platform_impl(struct aws_system_environment *env); | ||
|
||
|
||
void aws_system_environment_load_virtualization_vendor_impl(struct aws_system_environment *env); | ||
|
||
#endif /* AWS_COMMON_SYSTEM_INFO_PRIV_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
#include <aws/common/private/system_info_priv.h> | ||
#include <aws/common/file.h> | ||
|
||
int aws_system_environment_load_platform_impl(struct aws_system_environment *env) { | ||
(void)env; | ||
|
||
return AWS_OP_SUCCESS; | ||
} | ||
|
||
void aws_system_environment_destroy_platform_impl(struct aws_system_environment *env) { | ||
(void)env; | ||
} | ||
|
||
void aws_system_environment_load_virtualization_vendor_impl(struct aws_system_environment *env) { | ||
aws_byte_buf_init_from_file(&env->virtualization_vendor, env->allocator, "/sys/devices/virtual/dmi/id/sys_vendor"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
#include <aws/common/private/system_info_priv.h> | ||
|
||
struct aws_system_environment *aws_system_environment_load(struct aws_allocator *allocator) { | ||
struct aws_system_environment *env = aws_mem_calloc(allocator, 1, sizeof(struct aws_system_environment)); | ||
env->allocator = allocator; | ||
|
||
if (aws_system_environment_load_platform_impl(env)) { | ||
goto error; | ||
} | ||
|
||
aws_system_environment_load_virtualization_vendor_impl(env); | ||
env->os = aws_get_platform_build_os(); | ||
env->cpu_count = aws_system_info_processor_count(); | ||
env->cpu_group_count = aws_get_cpu_group_count(); | ||
|
||
return env; | ||
error: | ||
aws_mem_release(allocator, env); | ||
|
||
return NULL; | ||
} | ||
|
||
void aws_system_environment_destroy(struct aws_system_environment *env) { | ||
if (env) { | ||
aws_system_environment_destroy_platform_impl(env); | ||
aws_mem_release(env->allocator, env); | ||
} | ||
|
||
} | ||
|
||
struct aws_byte_cursor aws_system_environment_get_virtualization_vendor(struct aws_system_environment *env) { | ||
return aws_byte_cursor_from_buf(&env->virtualization_vendor); | ||
} | ||
|
||
size_t aws_system_environment_get_processor_count(struct aws_system_environment *env) { | ||
return env->cpu_count; | ||
} | ||
|
||
AWS_COMMON_API | ||
size_t aws_system_environment_get_cpu_group_count(struct aws_system_environment *env) { | ||
return env->cpu_group_count; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters