HDRS
message_mapper.h
DEPENDS
+ libc.src.__support.CPP.array
libc.src.__support.CPP.string_view
libc.src.__support.CPP.optional
)
# 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
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(
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
)
//
//===----------------------------------------------------------------------===//
-#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 <stddef.h>
namespace __llvm_libc {
#include <stddef.h>
namespace __llvm_libc {
-namespace internal {
struct MsgMapping {
int num;
return res;
}
-} // namespace internal
} // namespace __llvm_libc
#endif // LLVM_LIBC_SRC_SUPPORT_STRING_UTIL_MESSAGE_MAPPER_H
--- /dev/null
+//===-- 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
--- /dev/null
+//===-- 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
//
//===----------------------------------------------------------------------===//
-#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 <signal.h>
-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
)
+++ /dev/null
-//===-- 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
+++ /dev/null
-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
-)
-//===-- 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.
//
//===----------------------------------------------------------------------===//
-#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 <errno.h> // For error macros
+
+namespace __llvm_libc {
constexpr MsgTable<52> LINUX_ERRORS = {
MsgMapping(ENOTBLK, "Block device required"),
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
-//===-- 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.
//
//===----------------------------------------------------------------------===//
-#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 <signal.h>
+#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 <signal.h> // 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
#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
--- /dev/null
+//===-- 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
--- /dev/null
+//===-- 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
--- /dev/null
+//===-- 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
--- /dev/null
+//===-- 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
-//===-- 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.
//
//===----------------------------------------------------------------------===//
-#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 <errno.h> // For error macros
+
+namespace __llvm_libc {
inline constexpr MsgTable<76> POSIX_ERRORS = {
MsgMapping(EPERM, "Operation not permitted"),
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
-//===-- 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.
//
//===----------------------------------------------------------------------===//
-#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 <signal.h>
+#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 <signal.h> // For signal numbers
+
+namespace __llvm_libc {
inline constexpr MsgTable<22> POSIX_SIGNALS = {
MsgMapping(SIGHUP, "Hangup"),
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
-//===-- 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.
//
//===----------------------------------------------------------------------===//
-#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 <errno.h> // For error macros
+
+namespace __llvm_libc {
inline constexpr const MsgTable<4> STDC_ERRORS = {
MsgMapping(0, "Success"),
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
-//===-- 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.
//
//===----------------------------------------------------------------------===//
-#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 <signal.h>
+#include <signal.h> // 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"),
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