Re: Fwd: Re: Thread local storage: add example

Andrew Makhorin <[email protected]>
Newsgroups gmane.comp.gnu.glpk
Message-ID <1484405352.3803.6.camel@corvax>
Hi Heinrich,

> it seems you missed the mail below.
> 
> Could you, please, add the appended README.md to tls/examples.

Done.

> I understand that you do not want to create env before checking if TLS
> is configured. But, please, do not call abort() in glp_config().
> 
> Otherwise your abort statement will stop the complete application.
> Imagine that being the webserver for a site on which a webapp is
> deployed which calls the GLPK library.
> 
> Either simply return NULL. Or define a value with signifies an error:
> 
> glpk.h:
> #define GLP_INVALID ((const void *) -1)
> 
> env/env.c:
> const char *glp_config(const char *option)
> {
> ...
>    return GLP_INVALID;
> ...
> }
> 

> I guess the best solution will be to return the empty string "" when
> an
> option is not set and NULL if the option does not exist.
> 
> Then we can use
> 
> const char *ret = get_config("TLS");
> if (!ret || !*ret) {
>         fprintf(stderr, "TLS not supported");
>         pthread_exit(NULL);
> }

I changed glp_config to return NULL for any unknown option as if this
option were disabled.

> if a multithreaded application wants to determine if GLPK supports a
> feature we now supply glp_config which does not initialize env.
> I guess we should do the same for glp_version.
> 
> This makes env smaller and can safely be called even if the library is
> not TLS enabled.
> 
> #define str(s) # s
> #define xstr(s) str(s)
> 
> const char *glp_version(void)
> {     return xstr(GLP_MAJOR_VERSION) "." xstr(GLP_MINOR_VERSION);
> }

Done.

Please see an updated version of glpk here:
http://sourceforge.net/projects/noumenon/files/tmp/
(Note that this is *not* an official release.)


Best regards,

Andrew Makhorin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.