diff options
author | Roland McGrath <mcgrathr@google.com> | 2023-05-06 01:35:56 -0700 |
---|---|---|
committer | Roland McGrath <mcgrathr@google.com> | 2023-05-07 17:22:21 -0700 |
commit | 46b76a54e16ac72e1c9769ce5b55774fbaaaaee2 (patch) | |
tree | 58518578d312e6392c462fb7dad1075a15c3b51a /libc | |
parent | 7770b0abfdab60e11fe26010c616ceb9b106a9ef (diff) | |
download | llvm-46b76a54e16ac72e1c9769ce5b55774fbaaaaee2.tar.gz |
[libc] Use Linux errno and signal strings for Fuchsia
The exact set of supported values is determined by the <errno.h>
and <signal.h> headers, which don't (yet) come from llvm-libc on
Fuchsia. The mappings of SIG* and E* codes to psignal/strsignal
and perror/strerror text used in Fuchsia libc today is the same
as for Linux.
Reviewed By: abrachet
Differential Revision: https://reviews.llvm.org/D150026
Diffstat (limited to 'libc')
-rw-r--r-- | libc/src/__support/StringUtil/tables/error_table.h | 21 | ||||
-rw-r--r-- | libc/src/__support/StringUtil/tables/signal_table.h | 21 |
2 files changed, 28 insertions, 14 deletions
diff --git a/libc/src/__support/StringUtil/tables/error_table.h b/libc/src/__support/StringUtil/tables/error_table.h index 78f58bc43d6a..5e8226e7d390 100644 --- a/libc/src/__support/StringUtil/tables/error_table.h +++ b/libc/src/__support/StringUtil/tables/error_table.h @@ -14,18 +14,25 @@ #include "posix_error_table.h" #include "stdc_error_table.h" -#ifdef __linux__ +#if defined(__linux__) || defined(__Fuchsia__) +#define USE_LINUX_PLATFORM_ERRORS 1 +#else +#define USE_LINUX_PLATFORM_ERRORS 0 +#endif + +#if USE_LINUX_PLATFORM_ERRORS #include "linux/error_table.h" #endif namespace __llvm_libc::internal { -#ifdef __linux__ -inline constexpr auto PLATFORM_ERRORS = - STDC_ERRORS + POSIX_ERRORS + LINUX_ERRORS; -#else -inline constexpr auto PLATFORM_ERRORS = STDC_ERRORS; -#endif +inline constexpr auto PLATFORM_ERRORS = []() { + if constexpr (USE_LINUX_PLATFORM_ERRORS) { + return STDC_ERRORS + POSIX_ERRORS + LINUX_ERRORS; + } else { + return STDC_ERRORS; + } +}(); } // namespace __llvm_libc::internal diff --git a/libc/src/__support/StringUtil/tables/signal_table.h b/libc/src/__support/StringUtil/tables/signal_table.h index b1b738abbac4..8ee8aa274813 100644 --- a/libc/src/__support/StringUtil/tables/signal_table.h +++ b/libc/src/__support/StringUtil/tables/signal_table.h @@ -14,18 +14,25 @@ #include "posix_signal_table.h" #include "stdc_signal_table.h" -#ifdef __linux__ +#if defined(__linux__) || defined(__Fuchsia__) +#define USE_LINUX_PLATFORM_SIGNALS 1 +#else +#define USE_LINUX_PLATFORM_SIGNALS 0 +#endif + +#if USE_LINUX_PLATFORM_SIGNALS #include "linux/signal_table.h" #endif namespace __llvm_libc::internal { -#ifdef __linux__ -inline constexpr auto PLATFORM_SIGNALS = - STDC_SIGNALS + POSIX_SIGNALS + LINUX_SIGNALS; -#else -inline constexpr auto PLATFORM_SIGNALS = STDC_SIGNALS; -#endif +inline constexpr auto PLATFORM_SIGNALS = []() { + if constexpr (USE_LINUX_PLATFORM_SIGNALS) { + return STDC_SIGNALS + POSIX_SIGNALS + LINUX_SIGNALS; + } else { + return STDC_SIGNALS; + } +}(); } // namespace __llvm_libc::internal |