From ceb1b218f108f79aa78e5722c9e5d8014353de74 Mon Sep 17 00:00:00 2001 From: fryshorts Date: Wed, 6 May 2015 21:25:04 +0200 Subject: [PATCH] libobs: Implement logging processor model on bsd Implement the log_processor_info function on bsd and add ifdefs to only build the implementation specific to the platform. Also add an ifdef around the call to that function to make sure it will only be called on platforms where it is actually implemented. --- libobs/obs-nix.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/libobs/obs-nix.c b/libobs/obs-nix.c index 788618a9f..1516a78a9 100644 --- a/libobs/obs-nix.c +++ b/libobs/obs-nix.c @@ -23,6 +23,9 @@ #include #include #include +#if defined(__FreeBSD__) +#include +#endif #include #include #include @@ -87,6 +90,7 @@ static void log_processor_cores(void) sysconf(_SC_NPROCESSORS_ONLN)); } +#if defined(__linux__) static void log_processor_info(void) { FILE *fp; @@ -129,6 +133,27 @@ static void log_processor_info(void) dstr_free(&processor); free(line); } +#elif defined(__FreeBSD__) +static void log_processor_info(void) +{ + int mib[2]; + size_t len; + char *proc; + + mib[0] = CTL_HW; + mib[1] = HW_MODEL; + + sysctl(mib, 2, NULL, &len, NULL, 0); + proc = bmalloc(len); + if (!proc) + return; + + sysctl(mib, 2, proc, &len, NULL, 0); + blog(LOG_INFO, "Processor: %s", proc); + + bfree(proc); +} +#endif static void log_memory_info(void) { @@ -195,7 +220,9 @@ static void log_distribution_info(void) void log_system_info(void) { log_processor_cores(); +#if defined(__linux__) || defined(__FreeBSD__) log_processor_info(); +#endif log_memory_info(); log_kernel_version(); log_distribution_info();