[fpc-devel] OO rewrite - technical questions
Sven Barth
pascaldragon at googlemail.com
Tue Jul 20 20:46:24 CEST 2010
Hi!
Am 20.07.2010 14:35, schrieb Michael Schnell:
> On 07/20/2010 02:07 PM, Florian Klaempfl wrote:
>> It is probably reverse engineered guesswork but no official
>> documentation.
> Hmm. I think M$ wants us to do decent Applications and this includes
> multithreaded applications that use threadvars ("__thread" in C).
>
> Thus I can't believe they did not document how a compiler is supposed to
> handle threadvars.
>
> Also, I suppose there is a documentation for M$'s own C compiler and for
> GNU C how they do it on the appropriate arch, as same should be able to
> call ASM functions that define their own threadvars in a way compatible
> to the main program written in C. Maybe this is even true for Delphi.
For this purpose the TLS-API is to be used. The segment registers that
point to the TLS array are undocumented and part of the internal
bookkeeping of a NT system (and yes, Windows Vista and 7 are NT systems
as well).
But because many applications rely on this undocumented TEB Microsoft
doesn't dare to change anything regarding this. But please no fight
about this topic; I've read the blog and the book of a Microsoft
developer who reports to what lengths Microsoft went to ensure
application compatibility (it's called "The old new thing" and I'm
suggesting it to everyone who wants to know something about Windows
internals in a humorous way).
Btw: if you are really curious you might take a look at the TLS
implementation of ReactOS, which is an NT OS after all:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/thread/tls.c?revision=45018&view=markup
Regards,
Sven
More information about the fpc-devel
mailing list