[libcxx-commits] [libcxx] [libc++] Add FreeBSD-specific EINTEGRITY errc value (PR #76364)
Dimitry Andric via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Dec 25 08:45:50 PST 2023
https://github.com/DimitryAndric created https://github.com/llvm/llvm-project/pull/76364
Since ~2019 we have been carrying a libc++ patch in FreeBSD, that adds the `EINTEGRITY` errno value. At the time, I submitted https://reviews.llvm.org/D56398 for this, but due to the complicated `ELAST` handling in `errno.h`, which that patch made even more complicated, it was put on hold.
I would like to try this again, but much simplified: there is no need to modify `errno.h`, since all supported versions of FreeBSD define both `EOWNERDEAD` and `ENOTRECOVERABLE`, so the part that attempts to redefine `ELAST` is effectively never used, and for FreeBSD we can simply ignore it.
The only proposed changes will now be to optionally add `EINTEGRITY` as an `enum errc` value, and add a corresponding test to `errc.pass.cpp`.
>From a04b4649945bdec40e51b4d70ddf46481c2623f2 Mon Sep 17 00:00:00 2001
From: Dimitry Andric <dimitry at andric.com>
Date: Mon, 25 Dec 2023 17:43:32 +0100
Subject: [PATCH] [libc++] Add FreeBSD-specific EINTEGRITY errc value
Since ~2019 we have been carrying a libc++ patch in FreeBSD, that adds
the `EINTEGRITY` errno value. At the time, I submitted
https://reviews.llvm.org/D56398 for this, but due to the complicated
`ELAST` handling in `errno.h`, which that patch made even more
complicated, it was put on hold.
I would like to try this again, but much simplified: there is no need to
modify `errno.h`, since all supported versions of FreeBSD define both
`EOWNERDEAD` and `ENOTRECOVERABLE`, so the part that attempts to
redefine `ELAST` is effectively never used, and for FreeBSD we can
simply ignore it.
The only proposed changes will now be to optionally add `EINTEGRITY` as
an `enum errc` value, and add a corresponding test to `errc.pass.cpp`.
---
libcxx/include/__system_error/errc.h | 30 +++++++++++--------
.../test/std/diagnostics/syserr/errc.pass.cpp | 3 ++
2 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/libcxx/include/__system_error/errc.h b/libcxx/include/__system_error/errc.h
index f87df86a71e15a..9a84b478b36b12 100644
--- a/libcxx/include/__system_error/errc.h
+++ b/libcxx/include/__system_error/errc.h
@@ -45,6 +45,7 @@ enum class errc
identifier_removed, // EIDRM
illegal_byte_sequence, // EILSEQ
inappropriate_io_control_operation, // ENOTTY
+ integrity_check_failed, // EINTEGRITY
interrupted, // EINTR
invalid_argument, // EINVAL
invalid_seek, // ESPIPE
@@ -141,19 +142,22 @@ _LIBCPP_DECLARE_STRONG_ENUM(errc){
identifier_removed = EIDRM,
illegal_byte_sequence = EILSEQ,
inappropriate_io_control_operation = ENOTTY,
- interrupted = EINTR,
- invalid_argument = EINVAL,
- invalid_seek = ESPIPE,
- io_error = EIO,
- is_a_directory = EISDIR,
- message_size = EMSGSIZE,
- network_down = ENETDOWN,
- network_reset = ENETRESET,
- network_unreachable = ENETUNREACH,
- no_buffer_space = ENOBUFS,
- no_child_process = ECHILD,
- no_link = ENOLINK,
- no_lock_available = ENOLCK,
+#ifdef EINTEGRITY
+ integrity_check_failed = EINTEGRITY,
+#endif
+ interrupted = EINTR,
+ invalid_argument = EINVAL,
+ invalid_seek = ESPIPE,
+ io_error = EIO,
+ is_a_directory = EISDIR,
+ message_size = EMSGSIZE,
+ network_down = ENETDOWN,
+ network_reset = ENETRESET,
+ network_unreachable = ENETUNREACH,
+ no_buffer_space = ENOBUFS,
+ no_child_process = ECHILD,
+ no_link = ENOLINK,
+ no_lock_available = ENOLCK,
#ifdef ENODATA
no_message_available = ENODATA,
#else
diff --git a/libcxx/test/std/diagnostics/syserr/errc.pass.cpp b/libcxx/test/std/diagnostics/syserr/errc.pass.cpp
index e44cb50102e3e1..ef18904864b371 100644
--- a/libcxx/test/std/diagnostics/syserr/errc.pass.cpp
+++ b/libcxx/test/std/diagnostics/syserr/errc.pass.cpp
@@ -44,6 +44,9 @@ int main(int, char**)
static_assert(static_cast<int>(std::errc::identifier_removed) == EIDRM, "");
static_assert(static_cast<int>(std::errc::illegal_byte_sequence) == EILSEQ, "");
static_assert(static_cast<int>(std::errc::inappropriate_io_control_operation) == ENOTTY, "");
+#ifdef EINTEGRITY
+ static_assert(static_cast<int>(std::errc::integrity_check_failed) == EINTEGRITY, "");
+#endif
static_assert(static_cast<int>(std::errc::interrupted) == EINTR, "");
static_assert(static_cast<int>(std::errc::invalid_argument) == EINVAL, "");
static_assert(static_cast<int>(std::errc::invalid_seek) == ESPIPE, "");
More information about the libcxx-commits
mailing list