summary refs log tree commit diff stats
path: root/lib/pure/concurrency
diff options
context:
space:
mode:
authorEmery Hemingway <emery@vfemail.net>2018-05-17 12:56:18 +0200
committerEmery Hemingway <emery@vfemail.net>2018-06-07 07:21:20 +0200
commit22f714585b943d0b2457c66a78917113072f4503 (patch)
treef346be91bab4f267527043057ec3a5c5276eb7af /lib/pure/concurrency
parentbf394ed1a1d27d8d38d4bc386946e3442736cd75 (diff)
downloadNim-22f714585b943d0b2457c66a78917113072f4503.tar.gz
Native access to Genode environment
Add a 'GenodeEnv' type and a 'componentConstructHook' to the system
module. The 'componentConstructHook' allows for detection of POSIX style
programs that exit implicitly or native Genode components that
initialize to serve RPC requests and OS signals.

This hook takes a 'GenodeEnv' argument so that the environment interface
is passed cleanly to application code after globals are initialized.
This is an typed pointer to a C++ object, procedures for accessing the
environment will be available from a Nimble library and not included in
the standard library.

The standard library has an internal pointer to the environment object
but this is not for external use, the undocumented global environment
pointer has been removed.
Diffstat (limited to 'lib/pure/concurrency')
-rw-r--r--lib/pure/concurrency/cpuinfo.nim8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/pure/concurrency/cpuinfo.nim b/lib/pure/concurrency/cpuinfo.nim
index f01488811..6d41aa1b2 100644
--- a/lib/pure/concurrency/cpuinfo.nim
+++ b/lib/pure/concurrency/cpuinfo.nim
@@ -38,8 +38,10 @@ when defined(macosx) or defined(bsd):
               importc: "sysctl", nodecl.}
 
 when defined(genode):
-  proc affinitySpaceTotal(): cuint {.
-    importcpp: "genodeEnv->cpu().affinity_space().total()".}
+  include genode/env
+
+  proc affinitySpaceTotal(env: GenodeEnvPtr): cuint {.
+    importcpp: "@->cpu().affinity_space().total()".}
 
 proc countProcessors*(): int {.rtl, extern: "ncpi$1".} =
   ## returns the numer of the processors/cores the machine has.
@@ -83,7 +85,7 @@ proc countProcessors*(): int {.rtl, extern: "ncpi$1".} =
     var SC_NPROC_ONLN {.importc: "_SC_NPROC_ONLN", header: "<unistd.h>".}: cint
     result = sysconf(SC_NPROC_ONLN)
   elif defined(genode):
-    result = affinitySpaceTotal().int
+    result = runtimeEnv.affinitySpaceTotal().int
   else:
     result = sysconf(SC_NPROCESSORS_ONLN)
   if result <= 0: result = 0