From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7584 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:56:28 +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 1431071828 23394 80.91.229.3 (8 May 2015 07:57:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 8 May 2015 07:57:08 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-7597-gllmg-musl=m.gmane.org@lists.openwall.com Fri May 08 09:57:03 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 1Yqd9b-00015y-0q for gllmg-musl@m.gmane.org; Fri, 08 May 2015 09:57:03 +0200 Original-Received: (qmail 30143 invoked by uid 550); 8 May 2015 07:57:01 -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 30112 invoked from network); 8 May 2015 07:57:01 -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=bJZDmf8qlXtMSn+kYWl4KBfEEhGGQD34NcLYcgeNSjc=; b=J/AQhqMt5kvIxUwFfzmp7GOdbUDm4bxtgKAeFcwy5UNDwBb2YgWevs6lUagTlH8yWP sBvL2ArQHHL1vQv3232I1eP0TNnzlC+QkbRpLj7r/SOT8Zqamo7VemfzJufbNfJAYjBI cWhjQp3+xkkANDUEe/7iw+sOHvk1RfDtfjeckkCGbP5a4SQmlTW/hJtyuxZ2lU1PwIIq 5s4/WWcJwFbHzeXqXUReVJD41hjdSC/sOuHulv38N/+MWUPiDnz6yecoxSMBP/Yqo4Al yFaI6use0Apqeb9NrOFhJYSVKHx+ajgtF1+NaBRixW4uDCsJEo71J5FwbS4ac+9cMuum /LXA== X-Received: by 10.43.133.137 with SMTP id hy9mr2701471icc.74.1431071809172; Fri, 08 May 2015 00:56:49 -0700 (PDT) In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:7584 Archived-At: OK, I understand, cause the pst doesn't return, so the value in it doesn't matter. 2015-05-08 15:53 GMT+08:00 =E7=BD=97=E5=8B=87=E5=88=9A(Yonggang Luo) : > 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 :: >> >> >> > > > > -- > =E6=AD=A4=E8=87=B4 > =E7=A4=BC > =E7=BD=97=E5=8B=87=E5=88=9A > Yours > sincerely, > Yonggang Luo --=20 =E6=AD=A4=E8=87=B4 =E7=A4=BC =E7=BD=97=E5=8B=87=E5=88=9A Yours sincerely, Yonggang Luo