What about replacing
static void *tls = NULL;
thread_local void *tls = NULL;
The "thread_local" is certainly supported in C++ from C++11
and C11 has the _Thread_local.
and so it should be portable and address the issue cleanly.
Now, my second question would be for the "tls".
The variable "tls" is used by tls_set_ptr and tls_get_ptr which
are only used by glp_init_env, glp_free_env and get_env_ptr.
--- As of now the glp_init_env and glp_free_env are taking
a void. But we get very simply put a ENV *env as part of
their input. The "env" would then no longer be a global variable
but instead be a scope variable in the frame where the solver
--- several function glpapi06.c / glpapi08.c and glpapi09.c
are using get_env_ptr to get the pointer. Instead we could add
the env variable as part of their input.
I may be very naive but the only negative impact I see from
this solution is API breaks.