Hmm, while thread saftey is a pain in the butt when moving from unix
to windows, in php 3 we came up with a (as yet unfinish and untested)
seemingly easy way to do it. While you would have to look at the
code to get all the specifics, we put our globals and static vars
into a structure, did a number of ifdefs, used the TLS api in msvc5,
and put a define GLOBAL() around all our globals. Now, when it is
compiled in vc5, it should be thread safe (except we still have work
to do on the flex generated stuff), and when compiled on unix it is
just its regular old unchanged self. We then use DllMain to set up
our thread local index, and allocate memory per thread for the global
structure. Of course we'll take a little performance hit on the
windows side (a call to get the thread index in each function that
uses a global), and c++ would probably be better, but it saves us
from a ground up rewrite of what has been done so far, and keeps
compilability across platforms.
Shane
|