Merge branch 'devel' of github.com:nim-lang/Nim into devel

This commit is contained in:
Andreas Rumpf 2017-09-16 10:11:42 +02:00
commit 28bdf0ac80
5 changed files with 20 additions and 12 deletions

View file

@ -570,8 +570,7 @@ order. The *names* of the fields also have to be identical.
The assignment operator for tuples copies each component. The assignment operator for tuples copies each component.
The default assignment operator for objects copies each component. Overloading The default assignment operator for objects copies each component. Overloading
of the assignment operator for objects is not possible, but this will change of the assignment operator is described in `type-bound-operations-operator`_.
in future versions of the compiler.
.. code-block:: nim .. code-block:: nim

View file

@ -185,9 +185,8 @@ to a storage location:
var x = "abc" # introduces a new variable `x` and assigns a value to it var x = "abc" # introduces a new variable `x` and assigns a value to it
x = "xyz" # assigns a new value to `x` x = "xyz" # assigns a new value to `x`
``=`` is the *assignment operator*. The assignment operator cannot be ``=`` is the *assignment operator*. The assignment operator can be
overloaded, overwritten or forbidden, but this might change in a future version overloaded. You can declare multiple variables with a single assignment
of Nim. You can declare multiple variables with a single assignment
statement and all the variables will have the same value: statement and all the variables will have the same value:
.. code-block:: .. code-block::

View file

@ -31,8 +31,12 @@ struct Nim::SysThread
void entry() override { void entry() override {
(_func)(_arg); } (_func)(_arg); }
Thread(Genode::Env &env, Genode::size_t stack_size, Entry func, void *arg) Thread(Genode::Env &env, Genode::size_t stack_size, Entry func, void *arg, int affinity)
: Genode::Thread(env, "nim-thread", stack_size), _func(func), _arg(arg) : Genode::Thread(env, "nim-thread", stack_size,
env.cpu().affinity_space().location_of_index(affinity),
Genode::Cpu_session::Weight(Genode::Cpu_session::Weight::DEFAULT_WEIGHT-1),
env.cpu()),
_func(func), _arg(arg)
{ {
Genode::Thread::start(); Genode::Thread::start();
} }
@ -40,8 +44,8 @@ struct Nim::SysThread
Genode::Constructible<Thread> _thread; Genode::Constructible<Thread> _thread;
void initThread(Genode::Env *env, Genode::size_t stack_size, Entry func, void *arg) { void initThread(Genode::Env *env, Genode::size_t stack_size, Entry func, void *arg, int aff) {
_thread.construct(*env, stack_size, func, arg); } _thread.construct(*env, stack_size, func, arg, aff); }
void joinThread() { void joinThread() {
_thread->join(); } _thread->join(); }

View file

@ -1435,7 +1435,8 @@ when defined(nimdoc):
elif defined(genode): elif defined(genode):
proc quit*(errorcode: int = QuitSuccess) {.magic: "Exit", noreturn, proc quit*(errorcode: int = QuitSuccess) {.magic: "Exit", noreturn,
importcpp: "genodeEnv->parent().exit(@)", header: "<base/env.h>".} importcpp: "genodeEnv->parent().exit(@); Genode::sleep_forever()",
header: "<base/sleep.h>".}
else: else:
proc quit*(errorcode: int = QuitSuccess) {. proc quit*(errorcode: int = QuitSuccess) {.

View file

@ -127,7 +127,8 @@ elif defined(genode):
proc initThread(s: var SysThread, proc initThread(s: var SysThread,
stackSize: culonglong, stackSize: culonglong,
entry: GenodeThreadProc, entry: GenodeThreadProc,
arg: pointer) {. arg: pointer,
affinity: cuint) {.
importcpp: "#.initThread(genodeEnv, @)".} importcpp: "#.initThread(genodeEnv, @)".}
proc threadVarAlloc(): ThreadVarSlot = 0 proc threadVarAlloc(): ThreadVarSlot = 0
@ -567,6 +568,9 @@ when hostOS == "windows":
setThreadAffinityMask(t.sys, uint(1 shl cpu)) setThreadAffinityMask(t.sys, uint(1 shl cpu))
elif defined(genode): elif defined(genode):
var affinityOffset: cuint = 1
# CPU affinity offset for next thread, safe to roll-over
proc createThread*[TArg](t: var Thread[TArg], proc createThread*[TArg](t: var Thread[TArg],
tp: proc (arg: TArg) {.thread, nimcall.}, tp: proc (arg: TArg) {.thread, nimcall.},
param: TArg) = param: TArg) =
@ -577,7 +581,8 @@ elif defined(genode):
when hasSharedHeap: t.stackSize = ThreadStackSize when hasSharedHeap: t.stackSize = ThreadStackSize
t.sys.initThread( t.sys.initThread(
ThreadStackSize.culonglong, ThreadStackSize.culonglong,
threadProcWrapper[TArg], addr(t)) threadProcWrapper[TArg], addr(t), affinityOffset)
inc affinityOffset
proc pinToCpu*[Arg](t: var Thread[Arg]; cpu: Natural) = proc pinToCpu*[Arg](t: var Thread[Arg]; cpu: Natural) =
{.hint: "cannot change Genode thread CPU affinity after initialization".} {.hint: "cannot change Genode thread CPU affinity after initialization".}