This commit is contained in:
Araq 2015-02-26 02:04:06 +01:00
commit 3dd1ecbae4

View file

@ -84,8 +84,18 @@ when defined(windows):
importc: "TlsAlloc", stdcall, header: "<windows.h>".} importc: "TlsAlloc", stdcall, header: "<windows.h>".}
proc threadVarSetValue(dwTlsIndex: TThreadVarSlot, lpTlsValue: pointer) {. proc threadVarSetValue(dwTlsIndex: TThreadVarSlot, lpTlsValue: pointer) {.
importc: "TlsSetValue", stdcall, header: "<windows.h>".} importc: "TlsSetValue", stdcall, header: "<windows.h>".}
proc threadVarGetValue(dwTlsIndex: TThreadVarSlot): pointer {. proc tlsGetValue(dwTlsIndex: TThreadVarSlot): pointer {.
importc: "TlsGetValue", stdcall, header: "<windows.h>".} importc: "TlsGetValue", stdcall, header: "<windows.h>".}
proc getLastError(): uint32 {.
importc: "GetLastError", stdcall, header: "<windows.h>".}
proc setLastError(x: uint32) {.
importc: "SetLastError", stdcall, header: "<windows.h>".}
proc threadVarGetValue(dwTlsIndex: TThreadVarSlot): pointer =
let realLastError = getLastError()
result = tlsGetValue(dwTlsIndex)
setLastError(realLastError)
else: else:
proc threadVarAlloc(): TThreadVarSlot {. proc threadVarAlloc(): TThreadVarSlot {.
importc: "TlsAlloc", stdcall, dynlib: "kernel32".} importc: "TlsAlloc", stdcall, dynlib: "kernel32".}