[libc-commits] [libc] 21be7ef - [libc] Implement BSD extensions in <err.h> (#199055)

via libc-commits libc-commits at lists.llvm.org
Wed Jul 8 22:09:06 PDT 2026


Author: Jeff Bailey
Date: 2026-07-09T06:09:01+01:00
New Revision: 21be7ef4473615a774f7c26beeebba3161b72322

URL: https://github.com/llvm/llvm-project/commit/21be7ef4473615a774f7c26beeebba3161b72322
DIFF: https://github.com/llvm/llvm-project/commit/21be7ef4473615a774f7c26beeebba3161b72322.diff

LOG: [libc] Implement BSD extensions in <err.h> (#199055)

Implemented the BSD-extension functions defined in <err.h>:

- err, errx, verr, verrx
- warn, warnx, vwarn, vwarnx

Added an internal reporting helper in src/__support/Err. The err family
functions call internal::exit directly to satisfy [[noreturn]]
requirements. Enabled these entrypoints for aarch64, riscv, and x86_64.

Assisted-by: Automated tooling, human reviewed.

Added: 
    libc/include/err.yaml
    libc/src/err/CMakeLists.txt
    libc/src/err/err.cpp
    libc/src/err/err.h
    libc/src/err/errx.cpp
    libc/src/err/errx.h
    libc/src/err/report.cpp
    libc/src/err/report.h
    libc/src/err/verr.cpp
    libc/src/err/verr.h
    libc/src/err/verrx.cpp
    libc/src/err/verrx.h
    libc/src/err/vwarn.cpp
    libc/src/err/vwarn.h
    libc/src/err/vwarnx.cpp
    libc/src/err/vwarnx.h
    libc/src/err/warn.cpp
    libc/src/err/warn.h
    libc/src/err/warnx.cpp
    libc/src/err/warnx.h
    libc/test/src/err/CMakeLists.txt
    libc/test/src/err/err_test.cpp
    libc/test/src/err/errx_test.cpp
    libc/test/src/err/verr_test.cpp
    libc/test/src/err/verrx_test.cpp
    libc/test/src/err/vwarn_test.cpp
    libc/test/src/err/vwarnx_test.cpp
    libc/test/src/err/warn_test.cpp
    libc/test/src/err/warnx_test.cpp

Modified: 
    libc/config/linux/aarch64/entrypoints.txt
    libc/config/linux/arm/entrypoints.txt
    libc/config/linux/riscv/entrypoints.txt
    libc/config/linux/x86_64/entrypoints.txt
    libc/include/CMakeLists.txt
    libc/src/CMakeLists.txt
    libc/test/src/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index af89add35f01e..97625b28a2555 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -23,6 +23,16 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.dlfcn.dlopen
     libc.src.dlfcn.dlsym
 
+    # err.h entrypoints
+    libc.src.err.err
+    libc.src.err.verr
+    libc.src.err.errx
+    libc.src.err.verrx
+    libc.src.err.warn
+    libc.src.err.vwarn
+    libc.src.err.warnx
+    libc.src.err.vwarnx
+
     # errno.h entrypoints
     libc.src.errno.errno
 

diff  --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 20763eec40e8b..1986d6a5347dc 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -17,6 +17,16 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.ctype.tolower
     libc.src.ctype.toupper
 
+    # err.h entrypoints
+    libc.src.err.err
+    libc.src.err.verr
+    libc.src.err.errx
+    libc.src.err.verrx
+    libc.src.err.warn
+    libc.src.err.vwarn
+    libc.src.err.warnx
+    libc.src.err.vwarnx
+
     # errno.h entrypoints
     libc.src.errno.errno
 

diff  --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 6cced22ce8c85..90a93715b5d1e 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -23,6 +23,16 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.dlfcn.dlopen
     libc.src.dlfcn.dlsym
 
+    # err.h entrypoints
+    libc.src.err.err
+    libc.src.err.verr
+    libc.src.err.errx
+    libc.src.err.verrx
+    libc.src.err.warn
+    libc.src.err.vwarn
+    libc.src.err.warnx
+    libc.src.err.vwarnx
+
     # errno.h entrypoints
     libc.src.errno.errno
 

diff  --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index ae457e1cb79e0..bac62464a6c45 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -33,6 +33,16 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.dlfcn.dlopen
     libc.src.dlfcn.dlsym
 
+    # err.h entrypoints
+    libc.src.err.err
+    libc.src.err.verr
+    libc.src.err.errx
+    libc.src.err.verrx
+    libc.src.err.warn
+    libc.src.err.vwarn
+    libc.src.err.warnx
+    libc.src.err.vwarnx
+
     # errno.h entrypoints
     libc.src.errno.errno
 

diff  --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 57310e6c6291b..b856097c6bd3c 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -82,6 +82,14 @@ add_header_macro(
     .llvm_libc_common_h
 )
 
+add_header_macro(
+  err
+  ../libc/include/err.yaml
+  err.h
+  DEPENDS
+    .llvm_libc_common_h
+)
+
 add_header_macro(
   features
   ../libc/include/features.yaml

diff  --git a/libc/include/err.yaml b/libc/include/err.yaml
new file mode 100644
index 0000000000000..753a49ae99e33
--- /dev/null
+++ b/libc/include/err.yaml
@@ -0,0 +1,67 @@
+header: err.h
+standards:
+  - bsd
+macros: []
+types:
+  - type_name: va_list
+functions:
+  - name: err
+    standards:
+      - bsd
+    return_type: void
+    arguments:
+      - type: int
+      - type: const char *
+      - type: '...'
+  - name: verr
+    standards:
+      - bsd
+    return_type: void
+    arguments:
+      - type: int
+      - type: const char *
+      - type: va_list
+  - name: errx
+    standards:
+      - bsd
+    return_type: void
+    arguments:
+      - type: int
+      - type: const char *
+      - type: '...'
+  - name: verrx
+    standards:
+      - bsd
+    return_type: void
+    arguments:
+      - type: int
+      - type: const char *
+      - type: va_list
+  - name: warn
+    standards:
+      - bsd
+    return_type: void
+    arguments:
+      - type: const char *
+      - type: '...'
+  - name: vwarn
+    standards:
+      - bsd
+    return_type: void
+    arguments:
+      - type: const char *
+      - type: va_list
+  - name: warnx
+    standards:
+      - bsd
+    return_type: void
+    arguments:
+      - type: const char *
+      - type: '...'
+  - name: vwarnx
+    standards:
+      - bsd
+    return_type: void
+    arguments:
+      - type: const char *
+      - type: va_list

diff  --git a/libc/src/CMakeLists.txt b/libc/src/CMakeLists.txt
index 6ada1bef26a88..2c7c4d00f150a 100644
--- a/libc/src/CMakeLists.txt
+++ b/libc/src/CMakeLists.txt
@@ -27,6 +27,7 @@ add_subdirectory(wctype)
 
 if(${LIBC_TARGET_OS} STREQUAL "linux")
   add_subdirectory(dirent)
+  add_subdirectory(err)
   add_subdirectory(fcntl)
   add_subdirectory(poll)
   add_subdirectory(pthread)

diff  --git a/libc/src/err/CMakeLists.txt b/libc/src/err/CMakeLists.txt
new file mode 100644
index 0000000000000..a2c2c43f4fc3a
--- /dev/null
+++ b/libc/src/err/CMakeLists.txt
@@ -0,0 +1,137 @@
+if(NOT TARGET libc.src.__support.OSUtil.osutil)
+  return()
+endif()
+
+add_object_library(
+  report
+  SRCS
+    report.cpp
+  HDRS
+    report.h
+  DEPENDS
+    libc.hdr.errno_macros
+    libc.src.__support.arg_list
+    libc.src.__support.libc_errno
+    libc.src.__support.OSUtil.osutil
+    libc.src.__support.StringUtil.error_to_string
+    libc.src.stdio.printf_core.printf_main
+    libc.src.stdio.printf_core.writer
+    libc.src.__support.CPP.string_view
+    libc.src.__support.macros.config
+)
+
+add_entrypoint_object(
+  err
+  SRCS
+    err.cpp
+  HDRS
+    err.h
+  DEPENDS
+    .report
+    libc.src.__support.OSUtil.osutil
+    libc.src.__support.arg_list
+    libc.src.__support.common
+    libc.src.__support.macros.config
+    libc.src.__support.libc_errno
+)
+
+add_entrypoint_object(
+  verr
+  SRCS
+    verr.cpp
+  HDRS
+    verr.h
+  DEPENDS
+    .report
+    libc.src.__support.OSUtil.osutil
+    libc.src.__support.arg_list
+    libc.src.__support.common
+    libc.src.__support.macros.config
+    libc.src.__support.libc_errno
+)
+
+add_entrypoint_object(
+  errx
+  SRCS
+    errx.cpp
+  HDRS
+    errx.h
+  DEPENDS
+    .report
+    libc.src.__support.OSUtil.osutil
+    libc.src.__support.arg_list
+    libc.src.__support.common
+    libc.src.__support.macros.config
+    libc.src.__support.libc_errno
+)
+
+add_entrypoint_object(
+  verrx
+  SRCS
+    verrx.cpp
+  HDRS
+    verrx.h
+  DEPENDS
+    .report
+    libc.src.__support.OSUtil.osutil
+    libc.src.__support.arg_list
+    libc.src.__support.common
+    libc.src.__support.macros.config
+    libc.src.__support.libc_errno
+)
+
+add_entrypoint_object(
+  warn
+  SRCS
+    warn.cpp
+  HDRS
+    warn.h
+  DEPENDS
+    .report
+    libc.src.__support.arg_list
+    libc.src.__support.common
+    libc.src.__support.macros.config
+    libc.src.__support.libc_errno
+)
+
+add_entrypoint_object(
+  vwarn
+  SRCS
+    vwarn.cpp
+  HDRS
+    vwarn.h
+  DEPENDS
+    .report
+    libc.src.__support.arg_list
+    libc.src.__support.common
+    libc.src.__support.macros.config
+    libc.src.__support.libc_errno
+)
+
+add_entrypoint_object(
+  warnx
+  SRCS
+    warnx.cpp
+  HDRS
+    warnx.h
+  DEPENDS
+    .report
+    libc.src.__support.arg_list
+    libc.src.__support.common
+    libc.src.__support.macros.config
+    libc.src.__support.libc_errno
+)
+
+add_entrypoint_object(
+  vwarnx
+  SRCS
+    vwarnx.cpp
+  HDRS
+    vwarnx.h
+  DEPENDS
+    .report
+    libc.src.__support.arg_list
+    libc.src.__support.common
+    libc.src.__support.macros.config
+    libc.src.__support.libc_errno
+)

diff  --git a/libc/src/err/err.cpp b/libc/src/err/err.cpp
new file mode 100644
index 0000000000000..9528c4a451f3e
--- /dev/null
+++ b/libc/src/err/err.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 err.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/err/err.h"
+#include "src/__support/OSUtil/exit.h"
+#include "src/__support/arg_list.h"
+#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
+#include "src/__support/macros/config.h"
+#include "src/err/report.h"
+
+#include <stdarg.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+[[noreturn]] LLVM_LIBC_FUNCTION(void, err, (int eval, const char *fmt, ...)) {
+  int saved_errno = libc_errno;
+  va_list args;
+  va_start(args, fmt);
+  internal::ArgList arg_list(args);
+  err_reporting::report(true, saved_errno, fmt, arg_list);
+  va_end(args);
+  internal::exit(eval);
+}
+
+} // namespace LIBC_NAMESPACE_DECL

diff  --git a/libc/src/err/err.h b/libc/src/err/err.h
new file mode 100644
index 0000000000000..1ab2f284fa742
--- /dev/null
+++ b/libc/src/err/err.h
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 header for err.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_ERR_ERR_H
+#define LLVM_LIBC_SRC_ERR_ERR_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+[[noreturn]] void err(int eval, const char *fmt, ...);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_ERR_ERR_H

diff  --git a/libc/src/err/errx.cpp b/libc/src/err/errx.cpp
new file mode 100644
index 0000000000000..b875675a465c8
--- /dev/null
+++ b/libc/src/err/errx.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 errx.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/err/errx.h"
+#include "src/__support/OSUtil/exit.h"
+#include "src/__support/arg_list.h"
+#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
+#include "src/__support/macros/config.h"
+#include "src/err/report.h"
+
+#include <stdarg.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+[[noreturn]] LLVM_LIBC_FUNCTION(void, errx, (int eval, const char *fmt, ...)) {
+  int saved_errno = libc_errno;
+  va_list args;
+  va_start(args, fmt);
+  internal::ArgList arg_list(args);
+  err_reporting::report(false, saved_errno, fmt, arg_list);
+  va_end(args);
+  internal::exit(eval);
+}
+
+} // namespace LIBC_NAMESPACE_DECL

diff  --git a/libc/src/err/errx.h b/libc/src/err/errx.h
new file mode 100644
index 0000000000000..a2885e715b85f
--- /dev/null
+++ b/libc/src/err/errx.h
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 header for errx.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_ERR_ERRX_H
+#define LLVM_LIBC_SRC_ERR_ERRX_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+[[noreturn]] void errx(int eval, const char *fmt, ...);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_ERR_ERRX_H

diff  --git a/libc/src/err/report.cpp b/libc/src/err/report.cpp
new file mode 100644
index 0000000000000..bd4274fce77ed
--- /dev/null
+++ b/libc/src/err/report.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 {
+
+void report(bool show_err, int err_num, const char *fmt,
+            internal::ArgList &args) {
+  const char *progname = "libllvmlibc";
+  // TODO: Use a proper way to get progname if available.
+#ifdef __linux__
+  progname = program_invocation_short_name;
+#endif
+
+  char buffer[1024];
+  printf_core::FlushingBuffer wb(
+      buffer, sizeof(buffer),
+      [](cpp::string_view str, [[maybe_unused]] void *raw_stream) -> int {
+        write_to_stderr(str);
+        return static_cast<int>(str.size());
+      },
+      nullptr);
+  printf_core::Writer writer(wb);
+
+  writer.write(progname);
+  if (fmt != nullptr || show_err)
+    writer.write(": ");
+
+  if (fmt != nullptr) {
+    if (!printf_core::printf_main(&writer, fmt, args)) {
+      wb.flush_to_stream();
+      return;
+    }
+    if (show_err)
+      writer.write(": ");
+  }
+
+  if (show_err)
+    writer.write(get_error_string(err_num));
+
+  writer.write("\n");
+  wb.flush_to_stream();
+}
+
+} // namespace err_reporting
+} // namespace LIBC_NAMESPACE_DECL

diff  --git a/libc/src/err/report.h b/libc/src/err/report.h
new file mode 100644
index 0000000000000..446b882f6ba09
--- /dev/null
+++ b/libc/src/err/report.h
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 header for internal error reporting.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_ERR_REPORT_H
+#define LLVM_LIBC_SRC_ERR_REPORT_H
+
+#include "src/__support/arg_list.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace err_reporting {
+
+void report(bool show_err, int err_num, const char *fmt,
+            internal::ArgList &args);
+
+} // namespace err_reporting
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_ERR_REPORT_H

diff  --git a/libc/src/err/verr.cpp b/libc/src/err/verr.cpp
new file mode 100644
index 0000000000000..90049de2b6d91
--- /dev/null
+++ b/libc/src/err/verr.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 verr.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/err/verr.h"
+#include "src/__support/OSUtil/exit.h"
+#include "src/__support/arg_list.h"
+#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
+#include "src/__support/macros/config.h"
+#include "src/err/report.h"
+
+#include <stdarg.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+[[noreturn]] LLVM_LIBC_FUNCTION(void, verr,
+                                (int eval, const char *fmt, va_list args)) {
+  int saved_errno = libc_errno;
+  internal::ArgList arg_list(args);
+  err_reporting::report(true, saved_errno, fmt, arg_list);
+  internal::exit(eval);
+}
+
+} // namespace LIBC_NAMESPACE_DECL

diff  --git a/libc/src/err/verr.h b/libc/src/err/verr.h
new file mode 100644
index 0000000000000..24054c5a17fef
--- /dev/null
+++ b/libc/src/err/verr.h
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 header for verr.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_ERR_VERR_H
+#define LLVM_LIBC_SRC_ERR_VERR_H
+
+#include "src/__support/macros/config.h"
+#include <stdarg.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+[[noreturn]] void verr(int eval, const char *fmt, va_list args);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_ERR_VERR_H

diff  --git a/libc/src/err/verrx.cpp b/libc/src/err/verrx.cpp
new file mode 100644
index 0000000000000..bb5550f1c8805
--- /dev/null
+++ b/libc/src/err/verrx.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 verrx.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/err/verrx.h"
+#include "src/__support/OSUtil/exit.h"
+#include "src/__support/arg_list.h"
+#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
+#include "src/__support/macros/config.h"
+#include "src/err/report.h"
+
+#include <stdarg.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+[[noreturn]] LLVM_LIBC_FUNCTION(void, verrx,
+                                (int eval, const char *fmt, va_list args)) {
+  int saved_errno = libc_errno;
+  internal::ArgList arg_list(args);
+  err_reporting::report(false, saved_errno, fmt, arg_list);
+  internal::exit(eval);
+}
+
+} // namespace LIBC_NAMESPACE_DECL

diff  --git a/libc/src/err/verrx.h b/libc/src/err/verrx.h
new file mode 100644
index 0000000000000..c12b067b9fdde
--- /dev/null
+++ b/libc/src/err/verrx.h
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 header for verrx.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_ERR_VERRX_H
+#define LLVM_LIBC_SRC_ERR_VERRX_H
+
+#include "src/__support/macros/config.h"
+#include <stdarg.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+[[noreturn]] void verrx(int eval, const char *fmt, va_list args);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_ERR_VERRX_H

diff  --git a/libc/src/err/vwarn.cpp b/libc/src/err/vwarn.cpp
new file mode 100644
index 0000000000000..65ca531f475d7
--- /dev/null
+++ b/libc/src/err/vwarn.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 vwarn.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/err/vwarn.h"
+#include "src/__support/arg_list.h"
+#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
+#include "src/__support/macros/config.h"
+#include "src/err/report.h"
+
+#include <stdarg.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(void, vwarn, (const char *fmt, va_list args)) {
+  int saved_errno = libc_errno;
+  internal::ArgList arg_list(args);
+  err_reporting::report(true, saved_errno, fmt, arg_list);
+  libc_errno = saved_errno;
+}
+
+} // namespace LIBC_NAMESPACE_DECL

diff  --git a/libc/src/err/vwarn.h b/libc/src/err/vwarn.h
new file mode 100644
index 0000000000000..71cd21e2e40ff
--- /dev/null
+++ b/libc/src/err/vwarn.h
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 header for vwarn.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_ERR_VWARN_H
+#define LLVM_LIBC_SRC_ERR_VWARN_H
+
+#include "src/__support/macros/config.h"
+#include <stdarg.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+void vwarn(const char *fmt, va_list args);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_ERR_VWARN_H

diff  --git a/libc/src/err/vwarnx.cpp b/libc/src/err/vwarnx.cpp
new file mode 100644
index 0000000000000..938b7a0f0a9af
--- /dev/null
+++ b/libc/src/err/vwarnx.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 vwarnx.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/err/vwarnx.h"
+#include "src/__support/arg_list.h"
+#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
+#include "src/__support/macros/config.h"
+#include "src/err/report.h"
+
+#include <stdarg.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(void, vwarnx, (const char *fmt, va_list args)) {
+  int saved_errno = libc_errno;
+  internal::ArgList arg_list(args);
+  err_reporting::report(false, saved_errno, fmt, arg_list);
+  libc_errno = saved_errno;
+}
+
+} // namespace LIBC_NAMESPACE_DECL

diff  --git a/libc/src/err/vwarnx.h b/libc/src/err/vwarnx.h
new file mode 100644
index 0000000000000..a1a871a96f37d
--- /dev/null
+++ b/libc/src/err/vwarnx.h
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 header for vwarnx.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_ERR_VWARNX_H
+#define LLVM_LIBC_SRC_ERR_VWARNX_H
+
+#include "src/__support/macros/config.h"
+#include <stdarg.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+void vwarnx(const char *fmt, va_list args);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_ERR_VWARNX_H

diff  --git a/libc/src/err/warn.cpp b/libc/src/err/warn.cpp
new file mode 100644
index 0000000000000..d71cf0a4a9de4
--- /dev/null
+++ b/libc/src/err/warn.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 warn.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/err/warn.h"
+#include "src/__support/arg_list.h"
+#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
+#include "src/__support/macros/config.h"
+#include "src/err/report.h"
+
+#include <stdarg.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(void, warn, (const char *fmt, ...)) {
+  int saved_errno = libc_errno;
+  va_list args;
+  va_start(args, fmt);
+  internal::ArgList arg_list(args);
+  err_reporting::report(true, saved_errno, fmt, arg_list);
+  va_end(args);
+  libc_errno = saved_errno;
+}
+
+} // namespace LIBC_NAMESPACE_DECL

diff  --git a/libc/src/err/warn.h b/libc/src/err/warn.h
new file mode 100644
index 0000000000000..01385cbfbe205
--- /dev/null
+++ b/libc/src/err/warn.h
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 header for warn.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_ERR_WARN_H
+#define LLVM_LIBC_SRC_ERR_WARN_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+void warn(const char *fmt, ...);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_ERR_WARN_H

diff  --git a/libc/src/err/warnx.cpp b/libc/src/err/warnx.cpp
new file mode 100644
index 0000000000000..7d6ba077db7f7
--- /dev/null
+++ b/libc/src/err/warnx.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 warnx.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/err/warnx.h"
+#include "src/__support/arg_list.h"
+#include "src/__support/common.h"
+#include "src/__support/libc_errno.h"
+#include "src/__support/macros/config.h"
+#include "src/err/report.h"
+
+#include <stdarg.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(void, warnx, (const char *fmt, ...)) {
+  int saved_errno = libc_errno;
+  va_list args;
+  va_start(args, fmt);
+  internal::ArgList arg_list(args);
+  err_reporting::report(false, saved_errno, fmt, arg_list);
+  va_end(args);
+  libc_errno = saved_errno;
+}
+
+} // namespace LIBC_NAMESPACE_DECL

diff  --git a/libc/src/err/warnx.h b/libc/src/err/warnx.h
new file mode 100644
index 0000000000000..692175c8c5d5d
--- /dev/null
+++ b/libc/src/err/warnx.h
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 header for warnx.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_ERR_WARNX_H
+#define LLVM_LIBC_SRC_ERR_WARNX_H
+
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+void warnx(const char *fmt, ...);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_ERR_WARNX_H

diff  --git a/libc/test/src/CMakeLists.txt b/libc/test/src/CMakeLists.txt
index 077327d987dac..25a5c920036c3 100644
--- a/libc/test/src/CMakeLists.txt
+++ b/libc/test/src/CMakeLists.txt
@@ -86,6 +86,7 @@ add_subdirectory(unistd)
 add_subdirectory(inttypes)
 
 if(${LIBC_TARGET_OS} STREQUAL "linux")
+  add_subdirectory(err)
   add_subdirectory(fcntl)
   add_subdirectory(poll)
   add_subdirectory(sched)

diff  --git a/libc/test/src/err/CMakeLists.txt b/libc/test/src/err/CMakeLists.txt
new file mode 100644
index 0000000000000..f1e1faddc5249
--- /dev/null
+++ b/libc/test/src/err/CMakeLists.txt
@@ -0,0 +1,98 @@
+add_custom_target(libc_err_unittests)
+
+if(NOT TARGET libc.src.__support.OSUtil.osutil)
+  return()
+endif()
+
+add_libc_test(
+  err_test
+  UNIT_TEST_ONLY
+  SUITE
+    libc_err_unittests
+  SRCS
+    err_test.cpp
+  DEPENDS
+    libc.src.err.err
+    libc.src.__support.libc_errno
+)
+
+add_libc_test(
+  errx_test
+  UNIT_TEST_ONLY
+  SUITE
+    libc_err_unittests
+  SRCS
+    errx_test.cpp
+  DEPENDS
+    libc.src.err.errx
+)
+
+add_libc_test(
+  verr_test
+  UNIT_TEST_ONLY
+  SUITE
+    libc_err_unittests
+  SRCS
+    verr_test.cpp
+  DEPENDS
+    libc.src.err.verr
+    libc.src.__support.libc_errno
+)
+
+add_libc_test(
+  verrx_test
+  UNIT_TEST_ONLY
+  SUITE
+    libc_err_unittests
+  SRCS
+    verrx_test.cpp
+  DEPENDS
+    libc.src.err.verrx
+)
+
+add_libc_test(
+  warn_test
+  UNIT_TEST_ONLY
+  SUITE
+    libc_err_unittests
+  SRCS
+    warn_test.cpp
+  DEPENDS
+    libc.src.err.warn
+    libc.src.__support.libc_errno
+)
+
+add_libc_test(
+  warnx_test
+  UNIT_TEST_ONLY
+  SUITE
+    libc_err_unittests
+  SRCS
+    warnx_test.cpp
+  DEPENDS
+    libc.src.err.warnx
+    libc.src.__support.libc_errno
+)
+
+add_libc_test(
+  vwarn_test
+  UNIT_TEST_ONLY
+  SUITE
+    libc_err_unittests
+  SRCS
+    vwarn_test.cpp
+  DEPENDS
+    libc.src.err.vwarn
+    libc.src.__support.libc_errno
+)
+
+add_libc_test(
+  vwarnx_test
+  UNIT_TEST_ONLY
+  SUITE
+    libc_err_unittests
+  SRCS
+    vwarnx_test.cpp
+  DEPENDS
+    libc.src.err.vwarnx
+)

diff  --git a/libc/test/src/err/err_test.cpp b/libc/test/src/err/err_test.cpp
new file mode 100644
index 0000000000000..2eae2d45596c4
--- /dev/null
+++ b/libc/test/src/err/err_test.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+/// Unit tests for err.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/libc_errno.h"
+#include "src/err/err.h"
+#include "test/UnitTest/Test.h"
+
+TEST(LlvmLibcErrTest, ErrExitCode) {
+  libc_errno = 0;
+  EXPECT_EXITS([] { LIBC_NAMESPACE::err(1, "test err"); }, 1);
+  libc_errno = 2; // ENOENT
+  EXPECT_EXITS([] { LIBC_NAMESPACE::err(127, "test err %d", 42); }, 127);
+}
+
+TEST(LlvmLibcErrTest, ErrNullFormat) {
+  libc_errno = 2; // ENOENT
+  EXPECT_EXITS([] { LIBC_NAMESPACE::err(1, nullptr); }, 1);
+}

diff  --git a/libc/test/src/err/errx_test.cpp b/libc/test/src/err/errx_test.cpp
new file mode 100644
index 0000000000000..c448d5c83e62c
--- /dev/null
+++ b/libc/test/src/err/errx_test.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+/// Unit tests for errx.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/err/errx.h"
+#include "test/UnitTest/Test.h"
+
+TEST(LlvmLibcErrxTest, ErrxExitCode) {
+  EXPECT_EXITS([] { LIBC_NAMESPACE::errx(2, "test errx"); }, 2);
+}
+
+TEST(LlvmLibcErrxTest, ErrxNullFormat) {
+  EXPECT_EXITS([] { LIBC_NAMESPACE::errx(2, nullptr); }, 2);
+}

diff  --git a/libc/test/src/err/verr_test.cpp b/libc/test/src/err/verr_test.cpp
new file mode 100644
index 0000000000000..71bfbf6eb9f82
--- /dev/null
+++ b/libc/test/src/err/verr_test.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+/// Unit tests for verr.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/libc_errno.h"
+#include "src/err/verr.h"
+#include "test/UnitTest/Test.h"
+
+#include <stdarg.h>
+
+namespace {
+void call_verr(int eval, const char *fmt, ...) {
+  va_list args;
+  va_start(args, fmt);
+  LIBC_NAMESPACE::verr(eval, fmt, args);
+  va_end(args);
+}
+} // namespace
+
+TEST(LlvmLibcVerrTest, VerrExitCode) {
+  libc_errno = 0;
+  EXPECT_EXITS([] { call_verr(1, "test verr"); }, 1);
+}
+
+TEST(LlvmLibcVerrTest, VerrNullFormat) {
+  libc_errno = 2;
+  EXPECT_EXITS([] { call_verr(1, nullptr); }, 1);
+}

diff  --git a/libc/test/src/err/verrx_test.cpp b/libc/test/src/err/verrx_test.cpp
new file mode 100644
index 0000000000000..9c10734fb09f1
--- /dev/null
+++ b/libc/test/src/err/verrx_test.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+/// Unit tests for verrx.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/err/verrx.h"
+#include "test/UnitTest/Test.h"
+
+#include <stdarg.h>
+
+namespace {
+void call_verrx(int eval, const char *fmt, ...) {
+  va_list args;
+  va_start(args, fmt);
+  LIBC_NAMESPACE::verrx(eval, fmt, args);
+  va_end(args);
+}
+} // namespace
+
+TEST(LlvmLibcVerrxTest, VerrxExitCode) {
+  EXPECT_EXITS([] { call_verrx(2, "test verrx"); }, 2);
+}
+
+TEST(LlvmLibcVerrxTest, VerrxNullFormat) {
+  EXPECT_EXITS([] { call_verrx(2, nullptr); }, 2);
+}

diff  --git a/libc/test/src/err/vwarn_test.cpp b/libc/test/src/err/vwarn_test.cpp
new file mode 100644
index 0000000000000..3b47352de289a
--- /dev/null
+++ b/libc/test/src/err/vwarn_test.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+/// Unit tests for vwarn.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/libc_errno.h"
+#include "src/err/vwarn.h"
+#include "test/UnitTest/Test.h"
+
+#include <stdarg.h>
+
+namespace {
+void call_vwarn(const char *fmt, ...) {
+  va_list args;
+  va_start(args, fmt);
+  LIBC_NAMESPACE::vwarn(fmt, args);
+  va_end(args);
+}
+} // namespace
+
+TEST(LlvmLibcVwarnTest, VwarnNoExit) {
+  libc_errno = 1; // EPERM
+  call_vwarn("test vwarn");
+}
+
+TEST(LlvmLibcVwarnTest, VwarnNullFormat) {
+  libc_errno = 2;
+  call_vwarn(nullptr);
+}

diff  --git a/libc/test/src/err/vwarnx_test.cpp b/libc/test/src/err/vwarnx_test.cpp
new file mode 100644
index 0000000000000..286b7b89c6b18
--- /dev/null
+++ b/libc/test/src/err/vwarnx_test.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+/// Unit tests for vwarnx.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/err/vwarnx.h"
+#include "test/UnitTest/Test.h"
+
+#include <stdarg.h>
+
+namespace {
+void call_vwarnx(const char *fmt, ...) {
+  va_list args;
+  va_start(args, fmt);
+  LIBC_NAMESPACE::vwarnx(fmt, args);
+  va_end(args);
+}
+} // namespace
+
+TEST(LlvmLibcVwarnxTest, VwarnxNoExit) { call_vwarnx("test vwarnx"); }
+
+TEST(LlvmLibcVwarnxTest, VwarnxNullFormat) { call_vwarnx(nullptr); }

diff  --git a/libc/test/src/err/warn_test.cpp b/libc/test/src/err/warn_test.cpp
new file mode 100644
index 0000000000000..b11ce2e712809
--- /dev/null
+++ b/libc/test/src/err/warn_test.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+/// Unit tests for warn.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/libc_errno.h"
+#include "src/err/warn.h"
+#include "test/UnitTest/Test.h"
+
+TEST(LlvmLibcWarnTest, WarnNoExit) {
+  libc_errno = 0;
+  LIBC_NAMESPACE::warn("test warn");
+}
+
+TEST(LlvmLibcWarnTest, WarnNullFormat) {
+  libc_errno = 2;
+  LIBC_NAMESPACE::warn(nullptr);
+}

diff  --git a/libc/test/src/err/warnx_test.cpp b/libc/test/src/err/warnx_test.cpp
new file mode 100644
index 0000000000000..a605e32f830e6
--- /dev/null
+++ b/libc/test/src/err/warnx_test.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+/// Unit tests for warnx.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/libc_errno.h"
+#include "src/err/warnx.h"
+#include "test/UnitTest/Test.h"
+
+TEST(LlvmLibcWarnxTest, WarnxNoExit) {
+  libc_errno = 1;
+  LIBC_NAMESPACE::warnx("test warnx");
+}
+
+TEST(LlvmLibcWarnxTest, WarnxNullFormat) { LIBC_NAMESPACE::warnx(nullptr); }


        


More information about the libc-commits mailing list