mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "罗勇刚(Yonggang Luo) " <luoyonggang@gmail.com>
To: musl@lists.openwall.com
Subject: thread local should be used
Date: Fri, 8 May 2015 15:36:40 +0800	[thread overview]
Message-ID: <CAE2XoE95OZbt07CvcXB6YvEz8UrjkXuQcEErye8g+Q8UbFDKCw@mail.gmail.com> (raw)

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) {

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


             reply	other threads:[~2015-05-08  7:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-08  7:36 罗勇刚(Yonggang Luo)  [this message]
2015-05-08  7:51 ` Jens Gustedt
2015-05-08  7:53   ` 罗勇刚(Yonggang Luo) 
2015-05-08  7:56     ` 罗勇刚(Yonggang Luo) 
2015-05-08  8:26       ` Jens Gustedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAE2XoE95OZbt07CvcXB6YvEz8UrjkXuQcEErye8g+Q8UbFDKCw@mail.gmail.com \
    --to=luoyonggang@gmail.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).