Page MenuHomePhabricator

Remove mblen(), mbtowc() and wctomb() from the thread-unsafe functions.
ClosedPublic

Authored by ed on Jun 16 2016, 8:06 AM.

Details

Summary

Back in r240527 I added a knob to prevent thread-unsafe functions from
being exposed. mblen(), mbtowc() and wctomb() were also added to this
list, as the latest issue of POSIX doesn't require these functions to be
thread-safe.

It turns out that the only circumstance in which these functions are not
thread-safe is in case they are used in combination with state-dependent
character sets (e.g., Shift-JIS). According to Austin Group Bug 708,
these character sets "[...] are mostly a relic of the past and which
were never supported on most POSIX systems".

Though in many cases the use of these functions can be prevented by
using the reentrant counterparts, they are the only functions that allow
you to query whether the locale's character set is state-dependent. This
means that omitting these functions removes actual functionality.

Let's be a bit less pedantic and drop the guards around these functions.

Links:
http://austingroupbugs.net/view.php?id=708
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2037.htm

Diff Detail

Repository
rL LLVM

Event Timeline

ed updated this revision to Diff 60979.Jun 16 2016, 8:06 AM
ed retitled this revision from to Remove mblen(), mbtowc() and wctomb() from the thread-unsafe functions..
ed updated this object.
ed added reviewers: jroelofs, EricWF.
ed updated this object.Jun 16 2016, 8:07 AM
ed added a comment.Jul 2 2016, 2:12 AM

Friendly ping. :-)

EricWF accepted this revision.Dec 30 2016, 2:50 AM
EricWF edited edge metadata.
This revision is now accepted and ready to land.Dec 30 2016, 2:50 AM
This revision was automatically updated to reflect the committed changes.