[libcxx-commits] [libcxx] [libc++] Fix compilation for NetBSD. (PR #143055)
Alex Rønne Petersen via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jun 5 18:06:13 PDT 2025
https://github.com/alexrp created https://github.com/llvm/llvm-project/pull/143055
To my knowledge, NetBSD is mostly like other BSDs, but doesn't have `xlocale.h`. I think c664a7f may have inadvertently broken this.
>From cd7d08ba4a6416e57ead54b64a9afdac5b5296bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= <alex at alexrp.com>
Date: Fri, 6 Jun 2025 02:56:30 +0200
Subject: [PATCH] [libc++] Fix compilation for NetBSD.
To my knowledge, NetBSD is mostly like other BSDs, but doesn't have xlocale.h. I
think c664a7f may have inadvertently broken this.
---
libcxx/include/__locale_dir/locale_base_api.h | 2 ++
libcxx/include/__locale_dir/support/apple.h | 2 ++
.../include/__locale_dir/support/bsd_like.h | 2 --
libcxx/include/__locale_dir/support/freebsd.h | 2 ++
libcxx/include/__locale_dir/support/netbsd.h | 20 +++++++++++++++++++
5 files changed, 26 insertions(+), 2 deletions(-)
create mode 100644 libcxx/include/__locale_dir/support/netbsd.h
diff --git a/libcxx/include/__locale_dir/locale_base_api.h b/libcxx/include/__locale_dir/locale_base_api.h
index bbc30b1cfe03f..c0ef6865fdee0 100644
--- a/libcxx/include/__locale_dir/locale_base_api.h
+++ b/libcxx/include/__locale_dir/locale_base_api.h
@@ -117,6 +117,8 @@
# include <__locale_dir/support/apple.h>
# elif defined(__FreeBSD__)
# include <__locale_dir/support/freebsd.h>
+# elif defined(__NetBSD__)
+# include <__locale_dir/support/netbsd.h>
# elif defined(_LIBCPP_MSVCRT_LIKE)
# include <__locale_dir/support/windows.h>
# elif defined(__Fuchsia__)
diff --git a/libcxx/include/__locale_dir/support/apple.h b/libcxx/include/__locale_dir/support/apple.h
index 62eb79c30d435..5216ed2ba758a 100644
--- a/libcxx/include/__locale_dir/support/apple.h
+++ b/libcxx/include/__locale_dir/support/apple.h
@@ -15,6 +15,8 @@
# pragma GCC system_header
#endif
+#include <xlocale.h>
+
#include <__locale_dir/support/bsd_like.h>
#endif // _LIBCPP___LOCALE_DIR_SUPPORT_APPLE_H
diff --git a/libcxx/include/__locale_dir/support/bsd_like.h b/libcxx/include/__locale_dir/support/bsd_like.h
index 54eb397358d7a..e9168c91b4fb3 100644
--- a/libcxx/include/__locale_dir/support/bsd_like.h
+++ b/libcxx/include/__locale_dir/support/bsd_like.h
@@ -24,8 +24,6 @@
# include <wctype.h>
#endif
-#include <xlocale.h>
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/__locale_dir/support/freebsd.h b/libcxx/include/__locale_dir/support/freebsd.h
index 5c6e21e387271..5e24cbd29bb5a 100644
--- a/libcxx/include/__locale_dir/support/freebsd.h
+++ b/libcxx/include/__locale_dir/support/freebsd.h
@@ -15,6 +15,8 @@
# pragma GCC system_header
#endif
+#include <xlocale.h>
+
#include <__locale_dir/support/bsd_like.h>
#endif // _LIBCPP___LOCALE_DIR_SUPPORT_FREEBSD_H
diff --git a/libcxx/include/__locale_dir/support/netbsd.h b/libcxx/include/__locale_dir/support/netbsd.h
new file mode 100644
index 0000000000000..190857f6f84fe
--- /dev/null
+++ b/libcxx/include/__locale_dir/support/netbsd.h
@@ -0,0 +1,20 @@
+//===-----------------------------------------------------------------------===//
+//
+// 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 _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H
+#define _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#include <__locale_dir/support/bsd_like.h>
+
+#endif // _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H
More information about the libcxx-commits
mailing list