Skip to content

[libc++] Avoids using ENODATA. #86165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion libcxx/docs/ReleaseNotes/19.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions libcxx/src/random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down