[libcxx-commits] [libcxx] cf6feff - [libc++] Avoids using ENODATA. (#86165)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Apr 9 10:13:06 PDT 2024
Author: Mark de Wever
Date: 2024-04-09T19:13:02+02:00
New Revision: cf6feff56b06b9110095ba6e20c609c9d1dfcfd3
URL: https://github.com/llvm/llvm-project/commit/cf6feff56b06b9110095ba6e20c609c9d1dfcfd3
DIFF: https://github.com/llvm/llvm-project/commit/cf6feff56b06b9110095ba6e20c609c9d1dfcfd3.diff
LOG: [libc++] Avoids using ENODATA. (#86165)
This macro is deprecated in C++26.
Fixes https://github.com/llvm/llvm-project/issues/81360
---------
Co-authored-by: Louis Dionne <ldionne.2 at gmail.com>
Added:
Modified:
libcxx/docs/ReleaseNotes/19.rst
libcxx/src/random.cpp
Removed:
################################################################################
diff --git a/libcxx/docs/ReleaseNotes/19.rst b/libcxx/docs/ReleaseNotes/19.rst
index eaba5c8d0456dc..399693f4f3e069 100644
--- a/libcxx/docs/ReleaseNotes/19.rst
+++ b/libcxx/docs/ReleaseNotes/19.rst
@@ -117,7 +117,10 @@ TODO
ABI Affecting Changes
---------------------
-TODO
+
+- The optional POSIX macro ``ENODATA`` has been deprecated in C++ and POSIX 2017. The
+ ``random_device`` could throw a ``system_error`` with this value. It now
+ throws ``ENOMSG``.
Build System Changes
diff --git a/libcxx/src/random.cpp b/libcxx/src/random.cpp
index 93590af310e51a..14c6f4473d70b9 100644
--- a/libcxx/src/random.cpp
+++ b/libcxx/src/random.cpp
@@ -79,10 +79,8 @@ unsigned random_device::operator()() {
char* p = reinterpret_cast<char*>(&r);
while (n > 0) {
ssize_t s = read(__f_, p, n);
- _LIBCPP_SUPPRESS_DEPRECATED_PUSH
if (s == 0)
- __throw_system_error(ENODATA, "random_device got EOF"); // TODO ENODATA -> ENOMSG
- _LIBCPP_SUPPRESS_DEPRECATED_POP
+ __throw_system_error(ENOMSG, "random_device got EOF");
if (s == -1) {
if (errno != EINTR)
__throw_system_error(errno, "random_device got an unexpected error");
More information about the libcxx-commits
mailing list