Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAE2XoE_15AkOGXAqmaAhT1gBQpbvoc062WdXJiDcS3HLDcjvmA@mail.gmail.com>
Date: Fri, 8 May 2015 15:53:16 +0800
From: 罗勇刚(Yonggang Luo)  <luoyonggang@...il.com>
To: musl@...ts.openwall.com
Subject: Re: thread local should be used

Does that need to be thread safe for the static state?

2015-05-08 15:51 GMT+08:00 Jens Gustedt <jens.gustedt@...ia.fr>:
> Hello,
> certainly not.
>
> First of all _Thread_local is a C11 feature, out of reach for a
> portable library implementation still for some years.
>
> Then the requirement that this is a static state per function is a
> fixed requirement in the standard. No way out of that.
>
> Jens
>
> Am Freitag, den 08.05.2015, 15:36 +0800 schrieb 罗勇刚(Yonggang Luo) :
>> 218933012b1f0f052f91ac39ee5cc6daba99237d
>>  src/multibyte/mbrtowc.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/multibyte/mbrtowc.c b/src/multibyte/mbrtowc.c
>> index e7b3654..de8d5ae 100644
>> --- a/src/multibyte/mbrtowc.c
>> +++ b/src/multibyte/mbrtowc.c
>> @@ -8,15 +8,15 @@
>>  #include <errno.h>
>>  #include "internal.h"
>>
>> +_Thread_local static mbstate_t internal_state;
>>  size_t mbrtowc(wchar_t *restrict wc, const char *restrict src, size_t
>> n, mbstate_t *restrict st)
>>  {
>> - static unsigned internal_state;
>>   unsigned c;
>>   const unsigned char *s = (const void *)src;
>>   const unsigned N = n;
>>   wchar_t dummy;
>>
>> - if (!st) st = (void *)&internal_state;
>> + if (!st) st = &internal_state;
>>   c = *(unsigned *)st;
>>
>>   if (!s) {
>>
>
>
> --
> :: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
> :: ::::::::::::::: office Strasbourg : +33 368854536   ::
> :: :::::::::::::::::::::: gsm France : +33 651400183   ::
> :: ::::::::::::::: gsm international : +49 15737185122 ::
> :: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::
>
>
>



-- 
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.