[fpc-devel] threadvar implementation

Michael Schnell mschnell at lumino.de
Mon Aug 2 13:06:33 CEST 2010

  On 07/30/2010 08:01 PM, Hans-Peter Diettrich wrote:
> Only FS and GS can add an non-zero offset, to the *offset* given in 
> the instruction. The sum of both is the flat "address" (effectively 
> another offset), that can be stored in a pointer variable. In 32/64 
> bit flat memory models all pointers are "near", i.e. they don't 
> include an segment selector, and a zero-based segment is implied (DS...).
The segment ("Selector") content is not an offset (any more), but it 
uses a table of offsets that is managed by the OS. The user land 
software never sees this, so the pointer can't hold a "flat address", 
but when using a pointer some selector register needs to be used. if 
none is given, this is DS. As Pascal does not provide means to define a 
pointer type as being a pointer to a threadvar, it _always_ uses DS and 
thus a pointer to a threadvar is not possible with X86/32-Linux. Of 
course this is not true with a flat memory model. But is it possible to 
do "flat" software with FP on X86/32 Linux (or Windows) ?


More information about the fpc-devel mailing list