git: 1ff41cad716a - main - Minimize libc++ errno-related header diffs with upstream

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Mon, 25 Dec 2023 17:20:02 UTC
The branch main has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=1ff41cad716adeba0d408652c92c81e59e3ba316

commit 1ff41cad716adeba0d408652c92c81e59e3ba316
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-12-25 17:18:31 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-12-25 17:19:12 +0000

    Minimize libc++ errno-related header diffs with upstream
    
    In commit 88640c0e8b6f5 the new EINTEGRITY errno value was added, and
    this caused us to carry a patch for upstream libc++ since that time.
    Because it can cause merge conflicts when importing libc++ code from
    upstream, I have submitted an upstream pull request to get most of that
    patch integrated.
    
    It turns out that we do not need the errno.h part of it at all, since
    all supported FreeBSD versions define EOWNERDEAD and ENOTRECOVERABLE,
    and therefore the block that juggles with ELAST values is never used in
    FreeBSD. At the moment it only applies to older versions of Linux, or
    possibly other platforms.
    
    Therefore the only part that needs to stay is the definition of a enum
    errc value for EINTEGRITY, and this is made optional upon EINTEGRITY
    being defined, to make it suitable for upstreaming.
    
    No functional change is intended.
    
    MFC after:      1 week
---
 .../libcxx/include/__system_error/errc.h           |  2 +
 contrib/llvm-project/libcxx/include/errno.h        | 62 +++++-----------------
 2 files changed, 16 insertions(+), 48 deletions(-)

diff --git a/contrib/llvm-project/libcxx/include/__system_error/errc.h b/contrib/llvm-project/libcxx/include/__system_error/errc.h
index f0c27b1c60a1..f939c99f7ed6 100644
--- a/contrib/llvm-project/libcxx/include/__system_error/errc.h
+++ b/contrib/llvm-project/libcxx/include/__system_error/errc.h
@@ -143,7 +143,9 @@ _LIBCPP_DECLARE_STRONG_ENUM(errc)
     identifier_removed                  = EIDRM,
     illegal_byte_sequence               = EILSEQ,
     inappropriate_io_control_operation  = ENOTTY,
+#ifdef EINTEGRITY
     integrity_check_failed              = EINTEGRITY,
+#endif
     interrupted                         = EINTR,
     invalid_argument                    = EINVAL,
     invalid_seek                        = ESPIPE,
diff --git a/contrib/llvm-project/libcxx/include/errno.h b/contrib/llvm-project/libcxx/include/errno.h
index ea96c3a0f004..7b02d2b47953 100644
--- a/contrib/llvm-project/libcxx/include/errno.h
+++ b/contrib/llvm-project/libcxx/include/errno.h
@@ -34,79 +34,49 @@ Macros:
 
 #ifdef __cplusplus
 
-#if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) || !defined(EINTEGRITY)
+#if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
 
-#if defined(ELAST)
+#ifdef ELAST
 
 static const int __elast1 = ELAST+1;
 static const int __elast2 = ELAST+2;
-static const int __elast3 = ELAST+3;
 
 #else
 
 static const int __elast1 = 104;
 static const int __elast2 = 105;
-static const int __elast3 = 106;
 
 #endif
 
-#if !defined(EOWNERDEAD) && !defined(ENOTRECOVERABLE) && !defined(EINTEGRITY)
-#define ENOTRECOVERABLE __elast1
-#define EOWNERDEAD __elast2
-#define EINTEGRITY __elast3
-#if defined(ELAST)
-#undef ELAST
-#define ELAST EINTEGRITY
-#endif
-
-#elif !defined(EOWNERDEAD) && !defined(ENOTRECOVERABLE) && defined(EINTEGRITY)
-#define ENOTRECOVERABLE __elast1
-#define EOWNERDEAD __elast2
-#if defined(ELAST)
-#undef ELAST
-#define ELAST EOWNERDEAD
-#endif
+#ifdef ENOTRECOVERABLE
 
-#elif !defined(EOWNERDEAD) && defined(ENOTRECOVERABLE) && !defined(EINTEGRITY)
 #define EOWNERDEAD __elast1
-#define EINTEGRITY __elast2
-#if defined(ELAST)
-#undef ELAST
-#define ELAST EINTEGRITY
-#endif
 
-#elif !defined(EOWNERDEAD) && defined(ENOTRECOVERABLE) && defined(EINTEGRITY)
-#define EOWNERDEAD __elast1
-#if defined(ELAST)
+#ifdef ELAST
 #undef ELAST
 #define ELAST EOWNERDEAD
 #endif
 
-#elif defined(EOWNERDEAD) && !defined(ENOTRECOVERABLE) && !defined(EINTEGRITY)
-#define ENOTRECOVERABLE __elast1
-#define EINTEGRITY __elast2
-#if defined(ELAST)
-#undef ELAST
-#define ELAST EINTEGRITY
-#endif
+#elif defined(EOWNERDEAD)
 
-#elif defined(EOWNERDEAD) && !defined(ENOTRECOVERABLE) && defined(EINTEGRITY)
 #define ENOTRECOVERABLE __elast1
-#if defined(ELAST)
+#ifdef ELAST
 #undef ELAST
 #define ELAST ENOTRECOVERABLE
 #endif
 
-#elif defined(EOWNERDEAD) && defined(ENOTRECOVERABLE) && !defined(EINTEGRITY)
-#define EINTEGRITY __elast1
-#if defined(ELAST)
+#else  // defined(EOWNERDEAD)
+
+#define EOWNERDEAD __elast1
+#define ENOTRECOVERABLE __elast2
+#ifdef ELAST
 #undef ELAST
-#define ELAST EINTEGRITY
+#define ELAST ENOTRECOVERABLE
 #endif
 
-#endif // !defined(OWNERDEAD) && !defined(NOTRECOVERABLE) && !defined(INTEGRITY)
+#endif // defined(EOWNERDEAD)
 
-#endif // !defined(OWNERDEAD) || !defined(NOTRECOVERABLE) || !defined(INTEGRITY)
+#endif // !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE)
 
 //  supply errno values likely to be missing, particularly on Windows
 
@@ -424,10 +394,6 @@ static const int __elast3 = 106;
 #define EMLINK 9979
 #endif
 
-#ifndef EINTEGRITY
-#define EINTEGRITY 9980
-#endif
-
 #endif // __cplusplus
 
 #endif // _LIBCPP_ERRNO_H