public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Tom Honermann <tom@honermann.net>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	Florian Weimer <fweimer@redhat.com>,
	Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
Cc: Joseph Myers <joseph@codesourcery.com>
Subject: Re: [PATCH 2/3]: C++20 P0482R6 and C2X N2653: Implement mbrtoc8, c8rtomb, char8_t
Date: Wed, 18 May 2022 13:26:55 -0400	[thread overview]
Message-ID: <ccdfa0b5-87f0-8ab2-35d7-c2e5e280f934@honermann.net> (raw)
In-Reply-To: <6b3dd2a0-80b9-a1bd-b157-c6f92cdf7fb2@linaro.org>

On 5/18/22 12:17 PM, Adhemerval Zanella wrote:
>
> On 18/05/2022 12:32, Tom Honermann wrote:
>> On 5/17/22 5:33 PM, Florian Weimer wrote:
>>> * Adhemerval Zanella via Libc-alpha:
>>>
>>>> On 17/05/2022 15:12, Joseph Myers wrote:
>>>>> On Tue, 17 May 2022, Adhemerval Zanella wrote:
>>>>>
>>>>>>> +/* This is the private state used if PS is NULL.  */
>>>>>>> +static mbstate_t state;
>>>>>> Although it was done for other convertion interfaces, I wonder if we should
>>>>>> keep supporting this mt-unsafe usage for newer ones.  It was not clear from
>>>>> In C23 it's implementation-defined whether the internal state for such
>>>>> functions has static or thread storage duration (see the general
>>>>> introduction to the uchar.h functions).
>>>>>
>>>> Right, so glibc still need to support either mode.
>>> No, I think we can and should switch.  Maybe with new symbol versions
>>> (but the same implementation) if we want to play it conservative.
>>>
>>> The intent in POSIX and C has been for a long time that thread-local
>>> state is permitted for these functions, only the wording did not
>>> technically allow it.  The phrase was “not required to avoid data
>>> races”.  The problem is that it's possible to tell the difference
>>> without data races (with external synchronization).  Many libcs already
>>> use thread-local state for these functions, without any apparent ill
>>> effects.
>> I would err on the side of maintaining consistency across these functions for now and then transition them all at once if there is a desire to do so.
> Do we need to keep distinct states for each one or can use the a shared
> one?

Each is required to maintain its own state. The relevant wording from 
C17 7.28.1 (Restartable multibyte/wide character conversion functions) 
paragraph 1 states:

These functions have a parameter, ps, of type pointer to mbstate_t that 
points to an object that can completely describe the current conversion 
state of the associated multibyte character sequence, which the 
functions alter as necessary. *If ps is a null pointer, each function 
uses its own internal **mbstate_t**object instead, which is initialized 
at program startup to the initial conversion state; the****functions are 
not required to avoid data races with other calls to the same function 
in this case. The **implementation behaves as if no library function 
calls these functions with a null pointer for ps.*

Tom.

  reply	other threads:[~2022-05-18 17:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-27 16:53 Tom Honermann
2022-02-28 23:01 ` Joseph Myers
2022-03-01  3:40   ` Tom Honermann
2022-05-17 15:57     ` Carlos O'Donell
2022-05-17 18:05     ` Adhemerval Zanella
2022-05-17 18:12       ` Joseph Myers
2022-05-17 18:17         ` Adhemerval Zanella
2022-05-17 21:33           ` Florian Weimer
2022-05-18 15:32             ` Tom Honermann
2022-05-18 16:17               ` Adhemerval Zanella
2022-05-18 17:26                 ` Tom Honermann [this message]
2022-05-18 17:39                   ` Adhemerval Zanella
2022-05-18 17:40                 ` Florian Weimer
2022-05-18 17:57                   ` Adhemerval Zanella
  -- strict thread matches above, loose matches on Subject: below --
2022-01-08  0:39 Tom Honermann
2022-01-11  0:53 ` Joseph Myers
2022-01-11 19:23   ` Tom Honermann
2022-01-20 23:17     ` Tom Honermann
2022-01-21 20:01       ` Adhemerval Zanella
2022-01-22 12:24         ` Tom Honermann
2022-02-16 18:29           ` Joseph Myers
2022-02-16 19:14             ` tom
2021-06-07  2:08 Tom Honermann
2021-06-07 18:53 ` Joseph Myers
2021-06-11 11:25   ` Tom Honermann
2021-06-11 16:28     ` Joseph Myers
2021-06-13 15:35       ` Tom Honermann

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=ccdfa0b5-87f0-8ab2-35d7-c2e5e280f934@honermann.net \
    --to=tom@honermann.net \
    --cc=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).