| |||
| Home > The C and C++ Libraries > Writing reentrant and thread-safe code > Thread-safety in the ARM C++ libraries | |||
The following list summarizes thread-safety in the C++ libraries:
The function std::set_new_handler() is
not thread-safe. This means that some forms of operator
new and operator delete are not thread-safe
with respect to std::set_new_handler():
The default C++ runtime library implementations
of the following use malloc() and free() and
are thread-safe with respect to each other, malloc(),
and free(). They are not thread-safe with respect
to std::set_new_handler(). You are allowed
to replace them.:
::operator new(std::size_t)
::operator new[](std::size_t)
::operator new(std::size_t, const std::nothrow_t&)
::operator new[](std::size_t, const std::nothrow_t)
::operator delete(void*)
::operator delete[](void*)
::operator delete(void*, const std::nothrow_t&)
::operator delete[](void*, const std::nothrow_t&)
The following placement forms are also thread-safe. You are not allowed to replace them:
::operator new(std::size_t, void*)
::operator new[](std::size_t, void*)
::operator delete(void*, void*)
::operator delete[](void*, void*)
Construction and destruction of global objects is not thread-safe.
Construction of local static objects can be made
thread-safe, if you re-implement the functions __cxa_guard_acquire(), __cxa_guard_release(), __cxa_guard_abort(), __cxa_atexit() and __aeabi_atexit() appropriately.
For example, with appropriate re-implementing, the following construction
of lsobj can be made thread-safe:
struct T { T(); };
void f() { static T lsobj; }
The __cxa_ and __aeabi_ functions
are documented in the C++ ABI for the ARM Architecture specification.
Throwing an exception is thread-safe if any user constructors and destructors that get called, are also thread-safe. See the Exception Handling ABI for the ARM Architecture specification.
The ARM C++ library uses the ARM C library. To use the ARM C++ library in a multi-threaded environment, you must provide the functions described in Using the ARM C libraries with a multithreaded application.