[Proj] libproj4 thread safety

Gerald Evenden gerald.evenden at verizon.net
Sun Apr 24 13:34:17 EDT 2005


A couple of solutions have been offered to solve the problem of make
either a thread safe or unsafe library but all of them force a 
recompilation
of the entire library.

As libproj4 now sits on my machine the *only* module affected with
pthread references is pj_errno.c.  *All* other procedures do not have
any <phread.h> or  other reference to threads including lib_proj.h.

What would be a clean, but somewhat complicated, solution at compile
time would be two supplementary libraries libpj_errno.a and 
libpj_errno_p.a
so that two compile/link lines are possible and solve all cases:

gcc myprog -lproj4 -lpj_errno              #for non threads
gcc myprog -lproj4 -lpj_errno_p -lpthread  # for threads

For some reason, a single module library seems a bit -- er  -- 
rediculous.
Of course, pj_errno.o is not is the above libproj4.a.

In the case of the system's errno I suspect that a thread version of the
equivalent of pj_errno.o is in libpthread.a which is loaded prior to the
linker seeing the version in libc.a.  Just a guess.  What would happen
if I did -lc -lpthread?

The only changes I made in libproj4 was to pj_errno.c and dropped the
reference to the global 'extern int pj_errno' in lib_proj.h and added 
the
two lines referring to *pj_errno_loc() and defining pj_errno.

The bottom line is that I would strongly prefer *not* to make any 
conditional
compile statements in lib_proj.h and keep this whole process identical 
to
C library custom of handling errno.
_____________________________________
Jerry and the low riders: Daisy Mae and Joshua.
"The whole religious complexion of the modern world is due to the
absence from Jerusalem of a lunatic asylum." Havelock Ellis, 1914




More information about the Proj mailing list