[fpc-devel] OO rewrite - technical questions

Michael Schnell mschnell at lumino.de
Tue Aug 10 11:00:39 CEST 2010


  On 08/10/2010 10:23 AM, Michael Van Canneyt wrote:
>
> This is an extension to C which is specific to GCC; it is in no way an
> official spec except maybe for GCC (and probably linux-only, at that). 
> Microsoft for example doesn't use ELF; as I understand his remark, Jonas
> wanted an official Microsoft spec.
>
> Other than that, it's of course useful to know.
>
Finally I think that there is a decent chance to modify the compiler and 
the RTL in a way that threadvars can be used fast and without needing a 
libc binding, as well reading and writing them and constructing a 
pointer to them (which seemed impossible to me recently):

Linux X86/64: using this document
Linux X86/32: using this document (*),
Windows X86/32: using the document mentioned in another contribution, 
based on reverse-engineering of the Microsoft C compiler (*)
Linux ARM: tbd, but seemingly quite obvious
WinCE ARM. tbd, but I suppose this is not really "on the list".

(*) as both archs provide a TCB, the implementation can be done very 
similar, first constructing the DS-relative pointer to a threadvar and 
then doing the access:

Windows: the pointer to the threadvar is constructed by
   MOV EAX, FS:Windows_TCB-element_offset
   MOV EAX, threadvaroffset[EAX]

Linux: the pointer to the threadvar is constructed by
   MOV EAX, GS:Linux_TCB-element_offset
   MOV EAX, threadvaroffset[EAX]

-Michael



More information about the fpc-devel mailing list