[libcxx-commits] [libcxx] [libc++] Avoids using ENODATA. (PR #86165)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Mar 21 11:10:40 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Mark de Wever (mordante)
<details>
<summary>Changes</summary>
This macro is deprecated in C++26.
Fixes https://github.com/llvm/llvm-project/issues/81360
---
Full diff: https://github.com/llvm/llvm-project/pull/86165.diff
2 Files Affected:
- (modified) libcxx/docs/ReleaseNotes/19.rst (+4-1)
- (modified) libcxx/src/random.cpp (+1-3)
``````````diff
diff --git a/libcxx/docs/ReleaseNotes/19.rst b/libcxx/docs/ReleaseNotes/19.rst
index cac42f9c3c3f79..70cf3812d771aa 100644
--- a/libcxx/docs/ReleaseNotes/19.rst
+++ b/libcxx/docs/ReleaseNotes/19.rst
@@ -100,7 +100,10 @@ TODO
ABI Affecting Changes
---------------------
-TODO
+
+- The optional POSIX macro ``ENODATA`` has been deprecated in C++. 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");
``````````
</details>
https://github.com/llvm/llvm-project/pull/86165
More information about the libcxx-commits
mailing list