[Proj] libproj4 thread safety
Gerald Evenden
gerald.evenden at verizon.net
Mon Feb 28 09:25:04 EST 2005
Thank-you very much. Now I must retreat to my cave and assume a
position
for deep meditation. Some uses of pointers in C are designed by and for
Zen masters and *really* stain limited minds.. ;-)
On Feb 28, 2005, at 5:07 AM, Glynn Clements wrote:
>
> Gerald Evenden wrote:
> .....
>
> The way in which the GNU C library implements errno is to use a
> preprocessor macro to give each thread its own copy:
>
> /* Function to get address of global `errno' variable. */
> extern int *__errno_location (void) __THROW __attribute__
> ((__const__));
>
> /* When using threads, errno is a per-thread value. */
> # define errno (*__errno_location ())
>
> The __errno_location() function returns a pointer to thread-specific
> memory (via pthread_getspecific()).
>
> The reason for the indirection is that errno must behave as a
> variable, in the sense that assignments must be supported, e.g.:
>
> errno = 0;
> somefunc();
> if (errno != 0)
> ...
>> How are error flags handled for the math library in the threaded
>> environment? Close to the same issue. I do not do much checking here
>> as the code does so much manipulation to avoid math library
>> problems.
>
> The defined interface (in <fenv.h>) uses functions to test and modify
> the flags. The flags themselves are stored in the FPU's status
> registers, which are automatically saved and restored across a context
> switch, so each thread has its own set of flags.
>
> --
> Glynn Clements <glynn at gclements.plus.com>
> ...
> _____________________________________
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