diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2023-11-03 13:59:48 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2023-11-04 08:31:45 +0000 |
commit | 51f94778b45514992a716b0b2d7a87244e6f0018 (patch) | |
tree | 5953c1d8bdbcfd56a59d5a65c5ea0bd0ba3dfab7 /gcc | |
parent | 6933c05ade7cf9872e2c953339a5d2867e81bdcb (diff) | |
download | gcc-51f94778b45514992a716b0b2d7a87244e6f0018.zip gcc-51f94778b45514992a716b0b2d7a87244e6f0018.tar.gz gcc-51f94778b45514992a716b0b2d7a87244e6f0018.tar.bz2 |
libstdc++: Use strerror_r in std::generic_category()::message(int) [PR110133]
Use strerror_r instead of strerror when available, due to the latter not
being thread-safe. This is complicated by Glibc providing a GNU-specific
strerror_r which is not compatible with POSIX strerror_r, so we need to
dispatch on the return type.
We can use the recently-added std::string::__resize_and_overwrite to
write directly into the string buffer when possible. Because we estimate
the initial buffer size we might end up with excess capacity in the
returned std::string. We can slightly tweak the std::system_error
constructors to make use of that excess capacity, so that in some cases
we require fewer allocations to construct the std::system_error::what()
string.
libstdc++-v3/ChangeLog:
PR libstdc++/110133
* include/std/system_error (system_error::system_error): Group
arguments so that concatenation can reuse rvalue's capacity.
* src/c++11/system_error.cc (strerror_string): New function.
[_GLIBCXX_HAVE_STRERROR_R] (use_strerror_result): New functions.
(generic_error_category::message): Use strerror_string.
(system_error_category::message): Likewise.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions