File: print_system_info.c

package info (click to toggle)
aws-crt-python 0.20.4%2Bdfsg-1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 72,656 kB
  • sloc: ansic: 381,805; python: 23,008; makefile: 6,251; sh: 4,536; cpp: 699; ruby: 208; java: 77; perl: 73; javascript: 46; xml: 11
file content (48 lines) | stat: -rw-r--r-- 1,681 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48


#include <aws/common/byte_buf.h>
#include <aws/common/logging.h>
#include <aws/common/system_info.h>

int main(void) {
    struct aws_allocator *allocator = aws_default_allocator();
    aws_common_library_init(allocator);
    struct aws_logger_standard_options options = {
        .file = stderr,
        .level = AWS_LOG_LEVEL_TRACE,
    };

    struct aws_logger logger;
    aws_logger_init_standard(&logger, allocator, &options);
    aws_logger_set(&logger);

    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);
    struct aws_byte_cursor product_name = aws_system_environment_get_virtualization_product_name(env);
    fprintf(stdout, "  'product name': '" PRInSTR "',\n", (int)product_name.len, product_name.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_release(env);
    aws_logger_clean_up(&logger);

    aws_common_library_clean_up();
    return 0;
}