Add support for FreeBSD and NetBSD
(cherry picked from commit 546fe60d327886265d3d14b447123010621013f6)
This commit is contained in:
parent
8f4222916f
commit
76626f2fd4
|
@ -560,6 +560,16 @@ public @property uint logicalProcessorCount()
|
||||||
size_t count_len = count.sizeof;
|
size_t count_len = count.sizeof;
|
||||||
sysctlbyname("hw.logicalcpu", &count, &count_len, null, 0);
|
sysctlbyname("hw.logicalcpu", &count, &count_len, null, 0);
|
||||||
return cast(uint)count_len;
|
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) {
|
} else version (Windows) {
|
||||||
import core.sys.windows.windows;
|
import core.sys.windows.windows;
|
||||||
SYSTEM_INFO sysinfo;
|
SYSTEM_INFO sysinfo;
|
||||||
|
@ -568,6 +578,9 @@ public @property uint logicalProcessorCount()
|
||||||
} else static assert(false, "Unsupported OS!");
|
} 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 (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
|
Suspends the execution of the calling task to let other tasks and events be
|
||||||
|
|
Loading…
Reference in a new issue