From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7583 Path: news.gmane.org!not-for-mail From: =?UTF-8?B?572X5YuH5YiaKFlvbmdnYW5nIEx1bykg?= Newsgroups: gmane.linux.lib.musl.general Subject: Re: thread local should be used Date: Fri, 8 May 2015 15:53:16 +0800 Message-ID: References: <1431071502.3668.4.camel@inria.fr> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1431071636 20083 80.91.229.3 (8 May 2015 07:53:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 8 May 2015 07:53:56 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-7596-gllmg-musl=m.gmane.org@lists.openwall.com Fri May 08 09:53:52 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Yqd6V-0008Dr-NU for gllmg-musl@m.gmane.org; Fri, 08 May 2015 09:53:51 +0200 Original-Received: (qmail 28267 invoked by uid 550); 8 May 2015 07:53:49 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 28246 invoked from network); 8 May 2015 07:53:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:content-type:content-transfer-encoding; bh=JsVWMuT3n+vE8h3/nKr4lgRcT58hl8Ls3CeSHVlQkC8=; b=tuA8trqx83m8dhDLLgmB/vXem71SeIH0mxR/AVTHR2fBVbFIdn28M6jTqLBHZ/XrWu QgcGmNeC1W4TAt15T6pE48lj+Xox7lZL31yqSrmrWzqnSa6oEaghHSyRmSYSG43XredK W0L8qm1wSANG7C3XTKJ66/dhYY2vFATOity46czdxnRYS4kwvIoTma7s6XRTMgyc5WE9 eDMxcLrq2eDBiMjBrRkbVB68/nNgYbcui8J1X3Wlo4VDhUYmkYpfh4mxa9Ihi+j/kZLF dXO9Us16JdrXiBsjzGzccCrbM7AsNChDLLWfKgzt9hzc2n2ikaH2BPAVXBB5U6jAcGF3 r2cg== X-Received: by 10.42.99.205 with SMTP id x13mr2789064icn.53.1431071617198; Fri, 08 May 2015 00:53:37 -0700 (PDT) In-Reply-To: <1431071502.3668.4.camel@inria.fr> Xref: news.gmane.org gmane.linux.lib.musl.general:7583 Archived-At: Does that need to be thread safe for the static state? 2015-05-08 15:51 GMT+08:00 Jens Gustedt : > 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 =E7=BD=97=E5=8B=87=E5=88= =9A(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 >> #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 =3D (const void *)src; >> const unsigned N =3D n; >> wchar_t dummy; >> >> - if (!st) st =3D (void *)&internal_state; >> + if (!st) st =3D &internal_state; >> c =3D *(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 :: > > > --=20 =E6=AD=A4=E8=87=B4 =E7=A4=BC =E7=BD=97=E5=8B=87=E5=88=9A Yours sincerely, Yonggang Luo