[fpc-devel] threadvar implementation

Michael Schnell mschnell at lumino.de
Mon Jul 26 15:55:42 CEST 2010

  On 07/26/2010 02:51 PM, Sergei Gorelkin wrote:
> Michael Schnell wrote:
>> ...
>> This is essentially the same code as with Delphi. Supposedly as with 
>> Delphi [__tls_index (417328h) ] is always 0 with normal applications. 
>> (no idea what this is useful for)
> The TLS index is allocated by a call to TlsAlloc at application 
> startup. It will be zero for the first call and increasing for 
> subsequent calls. The subsequent calls are typically done by libraries 
> that use threadvars. This approach ensures that threadvar blocks of 
> each module in process do not clash.
I see. So in a DLL that implements it's own thread system, the TLS index 
will be non-zero. (The purpose being, that the Thread variables of each 
library can have it's own address space, which is necessary for 
non-statical linking.)

In Linux .so's this seems to be done in some other ways.


More information about the fpc-devel mailing list