The thread model in newlib

Leif Ekblad
Fri Dec 16 18:55:00 GMT 2005

I'm trying to use GCC + newlib for my OS (RDOS, I 
did try to
do a port 2002, but as I've studied my sources it turns out the patches for 
thread / reentrance
support were quite ugly.

RDOS only runs on i386, so portability is not a concern. I already have a 
working environment
with BCC 4.52 + TD32, which works since a couple of years ago. However, I 
like the open
environment better, and Borland no longer develops this compiler. With 
PE-executables, the
thread issue has a rather elegant solution for i386. You simply load a 
segment register (FS in
the case of PE), and let each thread have it's own selector. This way it is 
easy to implement
TLS and provide each thread with it's own data. It doesn't seem like it is 
easy to implement
this in newlib, at least not in version 1.10. I would rather only implement 
the non _r function-calls.
There is no need to provide an extra parameter, especially since every 
function call in RDOS
is reentrant. However, it is essential that the run-time library also is 

Any suggestions?

Leif Ekblad

More information about the Newlib mailing list