Allow to configure tls size (#6171)

This commit is contained in:
Ruslan Mustakov
2017-08-05 21:34:31 +07:00
committed by Andreas Rumpf
parent 7be896a75a
commit 03fc7f3941

View File

@@ -256,8 +256,9 @@ when emulatedThreadVars:
# we preallocate a fixed size for thread local storage, so that no heap
# allocations are needed. Currently less than 7K are used on a 64bit machine.
# We use ``float`` for proper alignment:
const nimTlsSize {.intdefine.} = 8000
type
ThreadLocalStorage = array[0..1_000, float]
ThreadLocalStorage = array[0..(nimTlsSize div sizeof(float)), float]
PGcThread = ptr GcThread
GcThread {.pure, inheritable.} = object
@@ -323,7 +324,11 @@ when not defined(useNimRtl):
when emulatedThreadVars:
if nimThreadVarsSize() > sizeof(ThreadLocalStorage):
echo "too large thread local storage size requested"
echo "too large thread local storage size requested ",
"(", nimThreadVarsSize(), "/", sizeof(ThreadLocalStorage), "). ",
"Use -d:\"nimTlsSize=", nimThreadVarsSize(),
"\" to preallocate sufficient storage."
quit 1
when hasSharedHeap and not defined(boehmgc) and not defined(gogc) and not defined(nogc):