Add support for FreeBSD and NetBSD

(cherry picked from commit 546fe60d327886265d3d14b447123010621013f6)
This commit is contained in:
Sönke Ludwig 2016-04-10 14:20:51 +02:00
parent 8f4222916f
commit 76626f2fd4

View file

@ -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