From 76626f2fd478f6245f863936fc54e693e7eed365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Sun, 10 Apr 2016 14:20:51 +0200 Subject: [PATCH] Add support for FreeBSD and NetBSD (cherry picked from commit 546fe60d327886265d3d14b447123010621013f6) --- source/vibe/core/core.d | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/vibe/core/core.d b/source/vibe/core/core.d index 486aa0b..7cce39e 100644 --- a/source/vibe/core/core.d +++ b/source/vibe/core/core.d @@ -560,6 +560,16 @@ public @property uint logicalProcessorCount() size_t count_len = count.sizeof; sysctlbyname("hw.logicalcpu", &count, &count_len, null, 0); return cast(uint)count_len; + } else version (FreeBSD) { + int count; + size_t count_len = count.sizeof; + sysctlbyname("hw.logicalcpu", &count, &count_len, null, 0); + return cast(uint)count_len; + } else version (NetBSD) { + int count; + size_t count_len = count.sizeof; + sysctlbyname("hw.logicalcpu", &count, &count_len, null, 0); + return cast(uint)count_len; } else version (Windows) { import core.sys.windows.windows; SYSTEM_INFO sysinfo; @@ -568,6 +578,9 @@ public @property uint logicalProcessorCount() } else static assert(false, "Unsupported OS!"); } version (OSX) private extern(C) int sysctlbyname(const(char)* name, void* oldp, size_t* oldlen, void* newp, size_t newlen); +version (FreeBSD) private extern(C) int sysctlbyname(const(char)* name, void* oldp, size_t* oldlen, void* newp, size_t newlen); +version (NetBSD) private extern(C) int sysctlbyname(const(char)* name, void* oldp, size_t* oldlen, void* newp, size_t newlen); +version (linux) static if (__VERSION__ <= 2066) private extern(C) int get_nprocs(); /** Suspends the execution of the calling task to let other tasks and events be