[PATCH] libc++: Make support for thread-unsafe C functions optional
Ed Schouten
ed at nuxi.nl
Mon Mar 30 07:35:31 PDT 2015
Hi jroelofs, mclow.lists,
One of the aspects of CloudABI is that it aims to help you write code that is thread-safe out of the box. This is very important if you want to write libraries that are easy to reuse. For CloudABI we decided to not provide the thread-unsafe functions. So far this is working out pretty well, as thread-unsafety issues are detected really early on.
The following patch adds a knob to libc++, _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS, that can be set to disable thread-unsafe functions that can easily be avoided in practice. The following functions are not thread-safe:
- `<clocale>`: locale handles should be preferred over `setlocale()`.
- `<cstdlib>`: `mbrlen()`, `mbrtowc()` and `wcrtomb()` should be preferred over their non-restartable counterparts.
- `<ctime>`: `asctime()`, `ctime()`, `gmtime()` and `localtime()` are not thread-safe. The first two are also deprecated by POSIX.
REPOSITORY
rL LLVM
http://reviews.llvm.org/D8703
Files:
CMakeLists.txt
include/__config
include/clocale
include/cstdlib
include/cstring
include/ctime
src/locale.cpp
test/CMakeLists.txt
test/libcxx/test/config.py
test/lit.site.cfg.in
test/std/depr/depr.c.headers/stdlib_h.pass.cpp
test/std/depr/depr.c.headers/string_h.pass.cpp
test/std/language.support/support.runtime/cstdlib.pass.cpp
test/std/language.support/support.runtime/ctime.pass.cpp
test/std/localization/c.locales/clocale.pass.cpp
test/std/strings/c.strings/cstring.pass.cpp
test/std/utilities/date.time/no.thread.unsafe.c.functions/asctime.fail.cpp
test/std/utilities/date.time/no.thread.unsafe.c.functions/ctime.fail.cpp
test/std/utilities/date.time/no.thread.unsafe.c.functions/gmtime.fail.cpp
test/std/utilities/date.time/no.thread.unsafe.c.functions/lit.local.cfg
test/std/utilities/date.time/no.thread.unsafe.c.functions/localtime.fail.cpp
test/std/utilities/date.time/tested_elsewhere.pass.cpp
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8703.22881.patch
Type: text/x-patch
Size: 16535 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150330/60bd4d16/attachment.bin>
More information about the cfe-commits
mailing list