[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@gmail.com>
This commit is contained in:
Mark de Wever 2024-04-09 19:13:02 +02:00 committed by GitHub
parent eea3bd3954
commit cf6feff56b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View File

@ -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

View File

@ -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");