From 7e351fc7fa96b4d560c5a51118bab22abb590585 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Fri, 31 Mar 2017 16:13:06 -0500 Subject: support for the Genode OS framework (#5560) --- lib/pure/concurrency/cpuinfo.nim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/pure/concurrency') diff --git a/lib/pure/concurrency/cpuinfo.nim b/lib/pure/concurrency/cpuinfo.nim index 8c87c77df..c3390573a 100644 --- a/lib/pure/concurrency/cpuinfo.nim +++ b/lib/pure/concurrency/cpuinfo.nim @@ -37,6 +37,10 @@ when defined(macosx) or defined(bsd): a: var csize, b: pointer, c: int): cint {. importc: "sysctl", nodecl.} +when defined(genode): + proc affinitySpaceTotal(): cuint {. + importcpp: "genodeEnv->cpu().affinity_space().total()".} + proc countProcessors*(): int {.rtl, extern: "ncpi$1".} = ## returns the numer of the processors/cores the machine has. ## Returns 0 if it cannot be detected. @@ -61,7 +65,8 @@ proc countProcessors*(): int {.rtl, extern: "ncpi$1".} = elif defined(irix): var SC_NPROC_ONLN {.importc: "_SC_NPROC_ONLN", header: "".}: cint result = sysconf(SC_NPROC_ONLN) + elif defined(genode): + result = affinitySpaceTotal().int else: result = sysconf(SC_NPROCESSORS_ONLN) if result <= 0: result = 1 - -- cgit 1.4.1-2-gfad0