store a pointer to thread local storage to make the GC happy
This commit is contained in:
parent
67a30d8371
commit
6dd8c85051
2 changed files with 5 additions and 4 deletions
|
|
@ -106,9 +106,10 @@ when hasThreadSupport:
|
|||
PGlobals = ptr TGlobals
|
||||
|
||||
var globalsSlot = ThreadVarAlloc()
|
||||
proc CreateThreadLocalStorage*() {.inl.} =
|
||||
proc CreateThreadLocalStorage*(): pointer {.inl.} =
|
||||
isMultiThreaded = true
|
||||
ThreadVarSetValue(globalsSlot, alloc0(sizeof(TGlobals)))
|
||||
result = alloc0(sizeof(TGlobals))
|
||||
ThreadVarSetValue(globalsSlot, result)
|
||||
|
||||
proc GetGlobals(): PGlobals {.compilerRtl, inl.} =
|
||||
result = cast[PGlobals](ThreadVarGetValue(globalsSlot))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue