help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] Fwd: Re: Thread local storage: add example


From: Heinrich Schuchardt
Subject: Re: [Help-glpk] Fwd: Re: Thread local storage: add example
Date: Sat, 14 Jan 2017 21:38:02 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0

Hello Andrew,

in the appended multiseed.c I have added a test to check if the GLPK
library supports thread local memory.

Further I added more comments and completed the error handling.

Best regards

Heinrich Schuchardt

On 01/14/2017 03:49 PM, Andrew Makhorin wrote:
> 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
> 
> 

Attachment: multiseed.c
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]