From 25174976e19b2ef916bb94f4613662646c95cd46 Mon Sep 17 00:00:00 2001 From: Siva Chandra Reddy Date: Wed, 24 May 2023 07:28:50 +0000 Subject: [PATCH] [libc] Rearrange error and signal tables. This is largely a cosmetic change done with a few goals: 1. Reduce the conditionals in picking the correct set of tables for the platform. 2. Avoid exposing, for example Linux errors, when building for non-Linux platforms. This also prevents build failures when Linux errors are not defined on the target non-Linux platform. 3. Some "_table" suffixes have been removed to avoid repeated occurance of "table" like "tables/linux_error_table.h". Reviewed By: michaelrj Differential Revision: https://reviews.llvm.org/D151367 --- libc/src/__support/StringUtil/CMakeLists.txt | 30 ++++++- libc/src/__support/StringUtil/error_to_string.cpp | 8 +- libc/src/__support/StringUtil/message_mapper.h | 2 - libc/src/__support/StringUtil/platform_errors.h | 18 ++++ libc/src/__support/StringUtil/platform_signals.h | 18 ++++ libc/src/__support/StringUtil/signal_to_string.cpp | 4 +- .../src/__support/StringUtil/tables/CMakeLists.txt | 100 ++++++++++++++++----- libc/src/__support/StringUtil/tables/error_table.h | 39 -------- .../StringUtil/tables/linux/CMakeLists.txt | 17 ---- .../error_table.h => linux_extension_errors.h} | 17 ++-- .../signal_table.h => linux_extension_signals.h} | 16 ++-- .../StringUtil/tables/linux_platform_errors.h | 23 +++++ .../StringUtil/tables/linux_platform_signals.h | 23 +++++ .../StringUtil/tables/minimal_platform_errors.h | 20 +++++ .../StringUtil/tables/minimal_platform_signals.h | 20 +++++ .../tables/{posix_error_table.h => posix_errors.h} | 17 ++-- .../{posix_signal_table.h => posix_signals.h} | 16 ++-- .../tables/{stdc_error_table.h => stdc_errors.h} | 16 ++-- .../tables/{stdc_signal_table.h => stdc_signals.h} | 14 +-- 19 files changed, 277 insertions(+), 141 deletions(-) create mode 100644 libc/src/__support/StringUtil/platform_errors.h create mode 100644 libc/src/__support/StringUtil/platform_signals.h delete mode 100644 libc/src/__support/StringUtil/tables/error_table.h delete mode 100644 libc/src/__support/StringUtil/tables/linux/CMakeLists.txt rename libc/src/__support/StringUtil/tables/{linux/error_table.h => linux_extension_errors.h} (87%) rename libc/src/__support/StringUtil/tables/{linux/signal_table.h => linux_extension_signals.h} (68%) create mode 100644 libc/src/__support/StringUtil/tables/linux_platform_errors.h create mode 100644 libc/src/__support/StringUtil/tables/linux_platform_signals.h create mode 100644 libc/src/__support/StringUtil/tables/minimal_platform_errors.h create mode 100644 libc/src/__support/StringUtil/tables/minimal_platform_signals.h rename libc/src/__support/StringUtil/tables/{posix_error_table.h => posix_errors.h} (90%) rename libc/src/__support/StringUtil/tables/{posix_signal_table.h => posix_signals.h} (79%) rename libc/src/__support/StringUtil/tables/{stdc_error_table.h => stdc_errors.h} (61%) rename libc/src/__support/StringUtil/tables/{stdc_signal_table.h => stdc_signals.h} (65%) diff --git a/libc/src/__support/StringUtil/CMakeLists.txt b/libc/src/__support/StringUtil/CMakeLists.txt index 528f1e8..52daa30 100644 --- a/libc/src/__support/StringUtil/CMakeLists.txt +++ b/libc/src/__support/StringUtil/CMakeLists.txt @@ -3,6 +3,7 @@ add_header_library( HDRS message_mapper.h DEPENDS + libc.src.__support.CPP.array libc.src.__support.CPP.string_view libc.src.__support.CPP.optional ) @@ -10,6 +11,30 @@ add_header_library( # The table maps depend on message_mapper. add_subdirectory(tables) +add_header_library( + platform_errors + HDRS + platform_errors.h + DEPENDS + # To avoid complicated conditionals, we will unconditionally add dependency + # on all platform errors which are included in platform_error_table.h. + # Ultimately, only the relevent error table will be used. + .tables.linux_platform_errors + .tables.minimal_platform_errors +) + +add_header_library( + platform_signals + HDRS + platform_signals.h + DEPENDS + # To avoid complicated conditionals, we will unconditionally add dependency + # on all platform signals which are included in platform_signal_table.h. + # Ultimately, only the relevent signal table will be used. + .tables.linux_platform_signals + .tables.minimal_platform_signals +) + add_object_library( error_to_string HDRS @@ -18,12 +43,11 @@ add_object_library( error_to_string.cpp DEPENDS .message_mapper - libc.src.errno.errno + .platform_errors libc.src.__support.CPP.span libc.src.__support.CPP.string_view libc.src.__support.CPP.stringstream libc.src.__support.integer_to_string - libc.src.__support.StringUtil.tables.error_table ) add_object_library( @@ -34,10 +58,10 @@ add_object_library( signal_to_string.cpp DEPENDS .message_mapper + .platform_signals libc.include.signal libc.src.__support.CPP.span libc.src.__support.CPP.string_view libc.src.__support.CPP.stringstream libc.src.__support.integer_to_string - libc.src.__support.StringUtil.tables.signal_table ) diff --git a/libc/src/__support/StringUtil/error_to_string.cpp b/libc/src/__support/StringUtil/error_to_string.cpp index 6a35b35..193d7d0 100644 --- a/libc/src/__support/StringUtil/error_to_string.cpp +++ b/libc/src/__support/StringUtil/error_to_string.cpp @@ -6,19 +6,15 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/StringUtil/error_to_string.h" +#include "error_to_string.h" +#include "platform_errors.h" -#include "src/errno/libc_errno.h" // For error macros - -#include "src/__support/CPP/array.h" #include "src/__support/CPP/span.h" #include "src/__support/CPP/string_view.h" #include "src/__support/CPP/stringstream.h" #include "src/__support/StringUtil/message_mapper.h" #include "src/__support/integer_to_string.h" -#include "src/__support/StringUtil/tables/error_table.h" - #include namespace __llvm_libc { diff --git a/libc/src/__support/StringUtil/message_mapper.h b/libc/src/__support/StringUtil/message_mapper.h index 91b1354..f73b8de 100644 --- a/libc/src/__support/StringUtil/message_mapper.h +++ b/libc/src/__support/StringUtil/message_mapper.h @@ -15,7 +15,6 @@ #include namespace __llvm_libc { -namespace internal { struct MsgMapping { int num; @@ -99,7 +98,6 @@ constexpr MsgTable operator+(const MsgTable &t1, return res; } -} // namespace internal } // namespace __llvm_libc #endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_MESSAGE_MAPPER_H diff --git a/libc/src/__support/StringUtil/platform_errors.h b/libc/src/__support/StringUtil/platform_errors.h new file mode 100644 index 0000000..8ca3bae --- /dev/null +++ b/libc/src/__support/StringUtil/platform_errors.h @@ -0,0 +1,18 @@ +//===-- The error table for the current platform ----------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_PLATFORM_ERROR_TABLE_H +#define LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_PLATFORM_ERROR_TABLE_H + +#if defined(__linux__) || defined(__Fuchsia__) +#include "tables/linux_platform_errors.h" +#else +#include "tables/minimal_platform_errors.h" +#endif + +#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_PLATFORM_ERROR_TABLE_H diff --git a/libc/src/__support/StringUtil/platform_signals.h b/libc/src/__support/StringUtil/platform_signals.h new file mode 100644 index 0000000..eef0d3d --- /dev/null +++ b/libc/src/__support/StringUtil/platform_signals.h @@ -0,0 +1,18 @@ +//===-- The signal table for the current platform ---------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_PLATFORM_SIGNAL_TABLE_H +#define LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_PLATFORM_SIGNAL_TABLE_H + +#if defined(__linux__) || defined(__Fuchsia__) +#include "tables/linux_platform_signals.h" +#else +#include "tables/minimal_platform_signals.h" +#endif + +#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_PLATFORM_SIGNAL_TABLE_H diff --git a/libc/src/__support/StringUtil/signal_to_string.cpp b/libc/src/__support/StringUtil/signal_to_string.cpp index b320138..c14123a 100644 --- a/libc/src/__support/StringUtil/signal_to_string.cpp +++ b/libc/src/__support/StringUtil/signal_to_string.cpp @@ -6,13 +6,13 @@ // //===----------------------------------------------------------------------===// -#include "src/__support/StringUtil/signal_to_string.h" +#include "signal_to_string.h" +#include "platform_signals.h" #include "src/__support/CPP/span.h" #include "src/__support/CPP/string_view.h" #include "src/__support/CPP/stringstream.h" #include "src/__support/StringUtil/message_mapper.h" -#include "src/__support/StringUtil/tables/signal_table.h" #include "src/__support/integer_to_string.h" #include diff --git a/libc/src/__support/StringUtil/tables/CMakeLists.txt b/libc/src/__support/StringUtil/tables/CMakeLists.txt index e8208f3..faba4fd 100644 --- a/libc/src/__support/StringUtil/tables/CMakeLists.txt +++ b/libc/src/__support/StringUtil/tables/CMakeLists.txt @@ -1,35 +1,89 @@ -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS}) - add_subdirectory(${LIBC_TARGET_OS}) -endif() +add_header_library( + stdc_errors + HDRS + stdc_errors.h + DEPENDS + libc.include.errno + libc.src.__support.StringUtil.message_mapper +) -set(error_to_string_platform_dep "") -if(TARGET libc.src.__support.StringUtil.tables.${LIBC_TARGET_OS}.error_table) - set(error_to_string_platform_dep - libc.src.__support.StringUtil.tables.${LIBC_TARGET_OS}.error_table) -endif() +add_header_library( + posix_errors + HDRS + posix_errors.h + DEPENDS + libc.include.errno + libc.src.__support.StringUtil.message_mapper +) add_header_library( - error_table + linux_extension_errors HDRS - error_table.h - stdc_error_table.h - posix_error_table.h + linux_extension_errors.h DEPENDS - ${error_to_string_platform_dep} + libc.include.errno + libc.src.__support.StringUtil.message_mapper ) -set(signal_to_string_platform_dep "") -if(TARGET libc.src.__support.StringUtil.tables.${LIBC_TARGET_OS}.signal_table) - set(signal_to_string_platform_dep - libc.src.__support.StringUtil.tables.${LIBC_TARGET_OS}.signal_table) -endif() +add_header_library( + linux_platform_errors + HDRS + linux_platform_errors + DEPENDS + .linux_extension_errors + .posix_errors + .stdc_errors +) + +add_header_library( + minimal_platform_errors + HDRS + minimal_platform_errors + DEPENDS + .stdc_errors +) + +add_header_library( + stdc_signals + HDRS + stdc_signals.h + DEPENDS + libc.include.signal + libc.src.__support.StringUtil.message_mapper +) + +add_header_library( + posix_signals + HDRS + posix_signals.h + DEPENDS + libc.include.signal + libc.src.__support.StringUtil.message_mapper +) + +add_header_library( + linux_extension_signals + HDRS + linux_extension_signals.h + DEPENDS + libc.include.signal + libc.src.__support.StringUtil.message_mapper +) + +add_header_library( + linux_platform_signals + HDRS + linux_platform_signals + DEPENDS + .linux_extension_signals + .posix_signals + .stdc_signals +) add_header_library( - signal_table + minimal_platform_signals HDRS - signal_table.h - stdc_signal_table.h - posix_signal_table.h + minimal_platform_signals DEPENDS - ${signal_to_string_platform_dep} + .stdc_signals ) diff --git a/libc/src/__support/StringUtil/tables/error_table.h b/libc/src/__support/StringUtil/tables/error_table.h deleted file mode 100644 index 5e8226e..0000000 --- a/libc/src/__support/StringUtil/tables/error_table.h +++ /dev/null @@ -1,39 +0,0 @@ -//===-- Map from error numbers to strings -----------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_ERROR_TABLE_H -#define LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_ERROR_TABLE_H - -#include "src/__support/StringUtil/message_mapper.h" - -#include "posix_error_table.h" -#include "stdc_error_table.h" - -#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 { - -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 - -#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_ERROR_TABLE_H diff --git a/libc/src/__support/StringUtil/tables/linux/CMakeLists.txt b/libc/src/__support/StringUtil/tables/linux/CMakeLists.txt deleted file mode 100644 index 82d3a29..0000000 --- a/libc/src/__support/StringUtil/tables/linux/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -add_header_library( - error_table - HDRS - error_table.h - DEPENDS - libc.src.__support.StringUtil.message_mapper - libc.src.errno.errno -) - -add_header_library( - signal_table - HDRS - signal_table.h - DEPENDS - libc.src.__support.StringUtil.message_mapper - libc.include.signal -) diff --git a/libc/src/__support/StringUtil/tables/linux/error_table.h b/libc/src/__support/StringUtil/tables/linux_extension_errors.h similarity index 87% rename from libc/src/__support/StringUtil/tables/linux/error_table.h rename to libc/src/__support/StringUtil/tables/linux_extension_errors.h index c898cf97..632c563 100644 --- a/libc/src/__support/StringUtil/tables/linux/error_table.h +++ b/libc/src/__support/StringUtil/tables/linux_extension_errors.h @@ -1,4 +1,4 @@ -//===-- Map from error numbers to strings on linux --------------*- C++ -*-===// +//===-- Map of Linux extension error numbers to strings ---------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,14 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_ERROR_TABLE_H -#define LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_ERROR_TABLE_H +#ifndef LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_EXTENSION_ERRORS_H +#define LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_EXTENSION_ERRORS_H -#include "src/errno/libc_errno.h" // For error macros - -#include "src/__support/CPP/array.h" #include "src/__support/StringUtil/message_mapper.h" -namespace __llvm_libc::internal { +#include // For error macros + +namespace __llvm_libc { constexpr MsgTable<52> LINUX_ERRORS = { MsgMapping(ENOTBLK, "Block device required"), @@ -71,6 +70,6 @@ constexpr MsgTable<52> LINUX_ERRORS = { MsgMapping(EHWPOISON, "Memory page has hardware error"), }; -} // namespace __llvm_libc::internal +} // namespace __llvm_libc -#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_ERROR_TABLE_H +#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_EXTENSION_ERRORS_H diff --git a/libc/src/__support/StringUtil/tables/linux/signal_table.h b/libc/src/__support/StringUtil/tables/linux_extension_signals.h similarity index 68% rename from libc/src/__support/StringUtil/tables/linux/signal_table.h rename to libc/src/__support/StringUtil/tables/linux_extension_signals.h index 864cd6f..7e31009 100644 --- a/libc/src/__support/StringUtil/tables/linux/signal_table.h +++ b/libc/src/__support/StringUtil/tables/linux_extension_signals.h @@ -1,4 +1,4 @@ -//===-- Map from signal numbers to strings on linux -------------*- C++ -*-===// +//===-- Map of Linux extension signal numbers to strings --------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,14 +6,14 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_SIGNAL_TABLE_H -#define LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_SIGNAL_TABLE_H - -#include +#ifndef LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_EXTENSION_SIGNALS_H +#define LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_EXTENSION_SIGNALS_H #include "src/__support/StringUtil/message_mapper.h" -namespace __llvm_libc::internal { +#include // For signal numbers + +namespace __llvm_libc { // The array being larger than necessary isn't a problem. The MsgMappings will // be set to their default state which maps 0 to an empty string. This will get @@ -28,6 +28,6 @@ inline constexpr const MsgTable<3> LINUX_SIGNALS = { #endif }; -} // namespace __llvm_libc::internal +} // namespace __llvm_libc -#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_SIGNAL_TABLE_H +#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_EXTENSION_SIGNALS_H diff --git a/libc/src/__support/StringUtil/tables/linux_platform_errors.h b/libc/src/__support/StringUtil/tables/linux_platform_errors.h new file mode 100644 index 0000000..e6d2010 --- /dev/null +++ b/libc/src/__support/StringUtil/tables/linux_platform_errors.h @@ -0,0 +1,23 @@ +//===-- Map of error numbers to strings for the Linux platform --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_PLATFORM_ERRORS_H +#define LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_PLATFORM_ERRORS_H + +#include "linux_extension_errors.h" +#include "posix_errors.h" +#include "stdc_errors.h" + +namespace __llvm_libc { + +inline constexpr auto PLATFORM_ERRORS = + STDC_ERRORS + POSIX_ERRORS + LINUX_ERRORS; + +} // namespace __llvm_libc + +#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_PLATFORM_ERRORS_H diff --git a/libc/src/__support/StringUtil/tables/linux_platform_signals.h b/libc/src/__support/StringUtil/tables/linux_platform_signals.h new file mode 100644 index 0000000..7f98a24 --- /dev/null +++ b/libc/src/__support/StringUtil/tables/linux_platform_signals.h @@ -0,0 +1,23 @@ +//===-- Map of error numbers to strings for the Linux platform --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_PLATFORM_SIGNALS_H +#define LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_PLATFORM_SIGNALS_H + +#include "linux_extension_signals.h" +#include "posix_signals.h" +#include "stdc_signals.h" + +namespace __llvm_libc { + +inline constexpr auto PLATFORM_SIGNALS = + STDC_SIGNALS + POSIX_SIGNALS + LINUX_SIGNALS; + +} // namespace __llvm_libc + +#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_PLATFORM_SIGNALS_H diff --git a/libc/src/__support/StringUtil/tables/minimal_platform_errors.h b/libc/src/__support/StringUtil/tables/minimal_platform_errors.h new file mode 100644 index 0000000..9fa75d5 --- /dev/null +++ b/libc/src/__support/StringUtil/tables/minimal_platform_errors.h @@ -0,0 +1,20 @@ +//===-- Map of error numbers to strings for a stdc platform -----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_MINIMAL_PLATFORM_ERRORS_H +#define LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_MINIMAL_PLATFORM_ERRORS_H + +#include "stdc_errors.h" + +namespace __llvm_libc { + +inline constexpr auto PLATFORM_ERRORS = STDC_ERRORS; + +} // namespace __llvm_libc + +#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_MINIMAL_PLATFORM_ERRORS_H diff --git a/libc/src/__support/StringUtil/tables/minimal_platform_signals.h b/libc/src/__support/StringUtil/tables/minimal_platform_signals.h new file mode 100644 index 0000000..758dfc8 --- /dev/null +++ b/libc/src/__support/StringUtil/tables/minimal_platform_signals.h @@ -0,0 +1,20 @@ +//===-- Map of error numbers to strings for a stdc platform -----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_MINIMAL_PLATFORM_SIGNALS_H +#define LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_MINIMAL_PLATFORM_SIGNALS_H + +#include "stdc_signals.h" + +namespace __llvm_libc { + +inline constexpr auto PLATFORM_SIGNALS = STDC_SIGNALS; + +} // namespace __llvm_libc + +#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_MINIMAL_PLATFORM_SIGNALS_H diff --git a/libc/src/__support/StringUtil/tables/posix_error_table.h b/libc/src/__support/StringUtil/tables/posix_errors.h similarity index 90% rename from libc/src/__support/StringUtil/tables/posix_error_table.h rename to libc/src/__support/StringUtil/tables/posix_errors.h index 1778eb9..43b1d9d 100644 --- a/libc/src/__support/StringUtil/tables/posix_error_table.h +++ b/libc/src/__support/StringUtil/tables/posix_errors.h @@ -1,4 +1,4 @@ -//===-- Map from error numbers to strings in posix --------------*- C++ -*-===// +//===-- Map of POSIX error numbers to strings -------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,14 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_POSIX_ERROR_TABLE_H -#define LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_POSIX_ERROR_TABLE_H +#ifndef LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_POSIX_ERRORS_H +#define LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_POSIX_ERRORS_H -#include "src/errno/libc_errno.h" // For error macros - -#include "src/__support/CPP/array.h" #include "src/__support/StringUtil/message_mapper.h" -namespace __llvm_libc::internal { +#include // For error macros + +namespace __llvm_libc { inline constexpr MsgTable<76> POSIX_ERRORS = { MsgMapping(EPERM, "Operation not permitted"), @@ -95,6 +94,6 @@ inline constexpr MsgTable<76> POSIX_ERRORS = { MsgMapping(ENOTRECOVERABLE, "State not recoverable"), }; -} // namespace __llvm_libc::internal +} // namespace __llvm_libc -#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_POSIX_ERROR_TABLE_H +#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_POSIX_ERRORS_H diff --git a/libc/src/__support/StringUtil/tables/posix_signal_table.h b/libc/src/__support/StringUtil/tables/posix_signals.h similarity index 79% rename from libc/src/__support/StringUtil/tables/posix_signal_table.h rename to libc/src/__support/StringUtil/tables/posix_signals.h index aae0884..b34035d 100644 --- a/libc/src/__support/StringUtil/tables/posix_signal_table.h +++ b/libc/src/__support/StringUtil/tables/posix_signals.h @@ -1,4 +1,4 @@ -//===-- Map from signal numbers to strings in posix -------------*- C++ -*-===// +//===-- Map of POSIX signal numbers to strings ------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,15 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_POSIX_SIGNAL_TABLE_H -#define LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_POSIX_SIGNAL_TABLE_H - -#include +#ifndef LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_POSIX_SIGNALS_H +#define LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_POSIX_SIGNALS_H #include "src/__support/CPP/array.h" #include "src/__support/StringUtil/message_mapper.h" -namespace __llvm_libc::internal { +#include // For signal numbers + +namespace __llvm_libc { inline constexpr MsgTable<22> POSIX_SIGNALS = { MsgMapping(SIGHUP, "Hangup"), @@ -41,6 +41,6 @@ inline constexpr MsgTable<22> POSIX_SIGNALS = { MsgMapping(SIGSYS, "Bad system call"), }; -} // namespace __llvm_libc::internal +} // namespace __llvm_libc -#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_POSIX_SIGNAL_TABLE_H +#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_POSIX_SIGNALS_H diff --git a/libc/src/__support/StringUtil/tables/stdc_error_table.h b/libc/src/__support/StringUtil/tables/stdc_errors.h similarity index 61% rename from libc/src/__support/StringUtil/tables/stdc_error_table.h rename to libc/src/__support/StringUtil/tables/stdc_errors.h index 5a2a883..42b934f 100644 --- a/libc/src/__support/StringUtil/tables/stdc_error_table.h +++ b/libc/src/__support/StringUtil/tables/stdc_errors.h @@ -1,4 +1,4 @@ -//===-- Map from error numbers to strings in the c std ----------*- C++ -*-===// +//===-- Map of C standard error numbers to strings --------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,14 +6,14 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_STDC_ERROR_TABLE_H -#define LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_STDC_ERROR_TABLE_H - -#include "src/errno/libc_errno.h" // For error macros +#ifndef LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_STDC_ERRORS_H +#define LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_STDC_ERRORS_H #include "src/__support/StringUtil/message_mapper.h" -namespace __llvm_libc::internal { +#include // For error macros + +namespace __llvm_libc { inline constexpr const MsgTable<4> STDC_ERRORS = { MsgMapping(0, "Success"), @@ -22,6 +22,6 @@ inline constexpr const MsgTable<4> STDC_ERRORS = { MsgMapping(EILSEQ, "Invalid or incomplete multibyte or wide character"), }; -} // namespace __llvm_libc::internal +} // namespace __llvm_libc -#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_ERROR_TABLE_H +#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_ERRORS_H diff --git a/libc/src/__support/StringUtil/tables/stdc_signal_table.h b/libc/src/__support/StringUtil/tables/stdc_signals.h similarity index 65% rename from libc/src/__support/StringUtil/tables/stdc_signal_table.h rename to libc/src/__support/StringUtil/tables/stdc_signals.h index 10cae1e..3de4318e 100644 --- a/libc/src/__support/StringUtil/tables/stdc_signal_table.h +++ b/libc/src/__support/StringUtil/tables/stdc_signals.h @@ -1,4 +1,4 @@ -//===-- Map from signal numbers to strings in the c std ---------*- C++ -*-===// +//===-- Map of C standard signal numbers to strings -------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,14 +6,14 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_STDC_SIGNAL_TABLE_H -#define LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_STDC_SIGNAL_TABLE_H +#ifndef LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_STDC_SIGNALS_H +#define LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_STDC_SIGNALS_H -#include +#include // For signal numbers #include "src/__support/StringUtil/message_mapper.h" -namespace __llvm_libc::internal { +namespace __llvm_libc { inline constexpr const MsgTable<6> STDC_SIGNALS = { MsgMapping(SIGINT, "Interrupt"), @@ -24,6 +24,6 @@ inline constexpr const MsgTable<6> STDC_SIGNALS = { MsgMapping(SIGTERM, "Terminated"), }; -} // namespace __llvm_libc::internal +} // namespace __llvm_libc -#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_SIGNAL_TABLE_H +#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_TABLES_LINUX_SIGNALS_H -- 2.7.4