Skip to content

Commit a688d85

Browse files
authored
Merge pull request DeusData#1093 from PR9000/freebsd-hw-physmem
fix(foundation): use HW_PHYSMEM for physical memory detection on FreeBSD
2 parents 5d150ea + 62808da commit a688d85

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎src/foundation/system_info.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static cbm_system_info_t detect_system_bsd(void) {
9595
info.total_cores = nprocs > 0 ? (int)nprocs : 1;
9696
info.perf_cores = info.total_cores;
9797

98-
#if defined(__OpenBSD__)
98+
#if defined(__OpenBSD__) || defined(__FreeBSD__)
9999
int mib[2] = {CTL_HW, HW_PHYSMEM};
100100
#else
101101
int mib[2] = {CTL_HW, HW_PHYSMEM64};

‎tests/test_platform.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ TEST(platform_default_workers_env_unset) {
132132
PASS();
133133
}
134134

135+
TEST(platform_system_info) {
136+
cbm_system_info_t info = cbm_system_info();
137+
ASSERT_GT(info.total_cores, 0);
138+
ASSERT_GT(info.total_ram, 0);
139+
PASS();
140+
}
141+
135142
/* ── cgroup-aware detection (Linux only) ─────────────────────────── */
136143

137144
#ifdef __linux__
@@ -316,6 +323,7 @@ SUITE(platform) {
316323
RUN_TEST(platform_default_workers_env_override);
317324
RUN_TEST(platform_default_workers_env_invalid);
318325
RUN_TEST(platform_default_workers_env_unset);
326+
RUN_TEST(platform_system_info);
319327
#ifdef __linux__
320328
RUN_TEST(cgroup_v2_cpu_quota);
321329
RUN_TEST(cgroup_v2_cpu_quota_rounds_up);

0 commit comments

Comments
 (0)