[libc-commits] [libc] [libc] Implement BSD extensions in <err.h> (PR #199055)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Fri May 22 12:00:01 PDT 2026
================
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of internal error reporting helpers.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/err/report.h"
+
+#include "hdr/errno_macros.h"
+#include "src/__support/CPP/string_view.h"
+#include "src/__support/OSUtil/io.h"
+#include "src/__support/StringUtil/error_to_string.h"
+#include "src/__support/arg_list.h"
+#include "src/__support/libc_errno.h"
+#include "src/__support/macros/config.h"
+#include "src/stdio/printf_core/printf_main.h"
+#include "src/stdio/printf_core/writer.h"
+
+#ifdef __linux__
+extern "C" char *program_invocation_short_name;
+#endif
+
+namespace LIBC_NAMESPACE_DECL {
+namespace err_reporting {
+
+namespace {
+
+void write_to_stderr(cpp::string_view msg) {
+ LIBC_NAMESPACE::write_to_stderr(msg);
+}
+
+} // namespace
+
+void report(bool show_err, const char *fmt, internal::ArgList &args) {
+ int saved_errno = libc_errno;
----------------
michaelrj-google wrote:
saving errno isn't necessary, internal functions aren't allowed to write to errno.
https://github.com/llvm/llvm-project/pull/199055
More information about the libc-commits
mailing list