Skip to content

Commit 9b6b704

Browse files
committed
Get CPU model in ggml_backend_cpu_device_context on FreeBSD
1 parent 578754b commit 9b6b704

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

ggml/src/ggml-cpu/ggml-cpu.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
#include <sys/sysctl.h>
2424
#endif
2525

26+
#if defined(__FreeBSD__)
27+
#include <sys/types.h>
28+
#include <sys/sysctl.h>
29+
#include <errno.h>
30+
#include <string.h>
31+
#include <iostream>
32+
#endif
33+
2634
#if defined(_WIN32)
2735
#define WIN32_LEAN_AND_MEAN
2836
#ifndef NOMINMAX
@@ -285,6 +293,14 @@ struct ggml_backend_cpu_device_context {
285293
}
286294
fclose(f);
287295
}
296+
#elif defined(__FreeBSD__)
297+
char buf[1024];
298+
size_t size = sizeof(buf);
299+
int rc = sysctlbyname("hw.model", buf, &size, nullptr, 0);
300+
if (rc == 0)
301+
description = buf;
302+
else
303+
std::cerr << "error: sysctlbyname(hw.model) failed: " << strerror(errno) << std::endl;
288304
#elif defined(_WIN32)
289305
HKEY hKey;
290306
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,

0 commit comments

Comments
 (0)