From 03fc7f3941f692de8ae995cf5415f38159b15a02 Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Sat, 5 Aug 2017 21:34:31 +0700 Subject: [PATCH] Allow to configure tls size (#6171) --- lib/system/threads.nim | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/system/threads.nim b/lib/system/threads.nim index 8041b8a8f4..754d071811 100644 --- a/lib/system/threads.nim +++ b/lib/system/threads.nim @@ -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):