HomePhabricator

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

Description

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

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

Reviewed by: ericwf
Differential Revision: https://reviews.llvm.org/D21436

Details

Committed
edDec 30 2016, 2:44 AM
Differential Revision
D21436: Remove mblen(), mbtowc() and wctomb() from the thread-unsafe functions.
Parents
rL290747: [clang-tidy] Add check 'misc-string-compare'.
Branches
Unknown
Tags
Unknown