The unix implementation of Tcl threading support
is built on the pthread library, and the routine
pthread_create() is at the core of all Tcl thread
creation on unix.
pthread_create() documents how it manages the
initialization of the floating point environment in
the created thread:
"The floating-point environment shall be inherited from the creating
This is a very useful default behavior for programs
performing multi-threaded calculations, keeping all
threads computing in a consistent way.
Empirically, we do not see this desirable behavior
from Tcl_CreateThread() on Windows. In particular,
when the master thread is computing using
80-bit extended precision computations, all
threads created by T_CT() do their computations
using only the default 64-bit precision operations.
Even code explicitly written using C "long double"
variables gets only 64-bit precision function when
run in a Tcl non-master thread. The consequence
is that computed results are not portable.
Tcl_CreateThread() takes an argument for a thread
initialization procedure, so those programs that care
about this detail have the ability to use that routine
to workaround this problem. The disadvantage is that
the code to query and set the floating point environment
is a nonportable mess, depending on hardware and
OS and compiler and other details. Coding a portable
solution to forcing fp environment inheritence is a big,
thorny problem. It's exactly the kind of portability
chore that programs rely on the Tcl library to solve
in other scenarios.
It's a tall order, but I'd like it if Tcl_CreateThread() aimed
at making the fp environment inheritance of pthread_create()
a cross-platform feature as much as possible.