[libcxx-commits] [libcxx] [libc++] Add FreeBSD-specific EINTEGRITY errc value (PR #76364)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 25 08:46:16 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Dimitry Andric (DimitryAndric)

<details>
<summary>Changes</summary>

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`.


---
Full diff: https://github.com/llvm/llvm-project/pull/76364.diff


2 Files Affected:

- (modified) libcxx/include/__system_error/errc.h (+17-13) 
- (modified) libcxx/test/std/diagnostics/syserr/errc.pass.cpp (+3) 


``````````diff
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, "");

``````````

</details>


https://github.com/llvm/llvm-project/pull/76364


More information about the libcxx-commits mailing list