Skip to content

[libc] add locale proxy header #130621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2025
Merged

[libc] add locale proxy header #130621

merged 1 commit into from
Mar 11, 2025

Conversation

c8ef
Copy link
Contributor

@c8ef c8ef commented Mar 10, 2025

Address review comments in #130407.

This patch is already covered by existing locale test cases.

@c8ef c8ef marked this pull request as ready for review March 10, 2025 15:19
@llvmbot llvmbot added the libc label Mar 10, 2025
@c8ef c8ef requested review from jhuber6 and lntue March 10, 2025 15:19
@llvmbot
Copy link
Member

llvmbot commented Mar 10, 2025

@llvm/pr-subscribers-libc

Author: Connector Switch (c8ef)

Changes

Address review comments in #130407.

This patch is already covered by existing locale test cases.


Full diff: https://github.com/llvm/llvm-project/pull/130621.diff

5 Files Affected:

  • (modified) libc/hdr/CMakeLists.txt (+9)
  • (added) libc/hdr/locale_macros.h (+22)
  • (modified) libc/test/src/locale/CMakeLists.txt (+2-2)
  • (modified) libc/test/src/locale/locale_test.cpp (+1-3)
  • (modified) libc/test/src/locale/localeconv_test.cpp (+1-2)
diff --git a/libc/hdr/CMakeLists.txt b/libc/hdr/CMakeLists.txt
index 7f523c50e8694..b337a8c9fc2a6 100644
--- a/libc/hdr/CMakeLists.txt
+++ b/libc/hdr/CMakeLists.txt
@@ -183,6 +183,15 @@ add_proxy_header_library(
     libc.include.link
 )
 
+add_proxy_header_library(
+  locale_macros
+  HDRS
+    locale_macros.h
+  FULL_BUILD_DEPENDS
+    libc.include.llvm-libc-macros.locale_macros
+    libc.include.locale
+)
+
 add_proxy_header_library(
   sys_auxv_macros
   HDRS
diff --git a/libc/hdr/locale_macros.h b/libc/hdr/locale_macros.h
new file mode 100644
index 0000000000000..7d94f6ddabe41
--- /dev/null
+++ b/libc/hdr/locale_macros.h
@@ -0,0 +1,22 @@
+//===-- Definition of macros from locale.h --------------------------------===//
+//
+// 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_HDR_LOCALE_MACROS_H
+#define LLVM_LIBC_HDR_LOCALE_MACROS_H
+
+#ifdef LIBC_FULL_BUILD
+
+#include "include/llvm-libc-macros/locale-macros.h"
+
+#else // Overlay mode
+
+#error "macros not available in overlay mode"
+
+#endif // LLVM_LIBC_FULL_BUILD
+
+#endif // LLVM_LIBC_HDR_LOCALE_MACROS_H
diff --git a/libc/test/src/locale/CMakeLists.txt b/libc/test/src/locale/CMakeLists.txt
index 3192004db26dd..5032ce9c324e2 100644
--- a/libc/test/src/locale/CMakeLists.txt
+++ b/libc/test/src/locale/CMakeLists.txt
@@ -7,7 +7,7 @@ add_libc_test(
   SRCS
     locale_test.cpp
   DEPENDS
-    libc.include.locale
+    libc.hdr.locale_macros
     libc.src.locale.newlocale
     libc.src.locale.uselocale
     libc.src.locale.freelocale
@@ -20,6 +20,6 @@ add_libc_test(
   SRCS
     localeconv_test.cpp
   DEPENDS
-    libc.include.locale
+    libc.hdr.locale_macros
     libc.src.locale.localeconv
 )
diff --git a/libc/test/src/locale/locale_test.cpp b/libc/test/src/locale/locale_test.cpp
index bc48bb851f4e4..d800e8fa5fcf9 100644
--- a/libc/test/src/locale/locale_test.cpp
+++ b/libc/test/src/locale/locale_test.cpp
@@ -6,14 +6,12 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "hdr/locale_macros.h"
 #include "src/locale/freelocale.h"
 #include "src/locale/newlocale.h"
 #include "src/locale/uselocale.h"
-
 #include "test/UnitTest/Test.h"
 
-#include "include/llvm-libc-macros/locale-macros.h"
-
 TEST(LlvmLibcLocale, DefaultLocale) {
   locale_t new_locale = LIBC_NAMESPACE::newlocale(LC_ALL, "C", nullptr);
   EXPECT_NE(new_locale, static_cast<locale_t>(nullptr));
diff --git a/libc/test/src/locale/localeconv_test.cpp b/libc/test/src/locale/localeconv_test.cpp
index 79264276dec35..4a7888176d539 100644
--- a/libc/test/src/locale/localeconv_test.cpp
+++ b/libc/test/src/locale/localeconv_test.cpp
@@ -6,9 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "include/llvm-libc-macros/locale-macros.h"
+#include "hdr/locale_macros.h"
 #include "src/locale/localeconv.h"
-
 #include "test/UnitTest/Test.h"
 
 TEST(LlvmLibcLocale, DefaultLocale) {

@c8ef c8ef changed the title [libc] add locale proxy haeder [libc] add locale proxy header Mar 10, 2025
Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should also update the usages in /src, specifically in the following functions:

duplocale
freelocale
locale
newlocale
setlocale

@c8ef
Copy link
Contributor Author

c8ef commented Mar 11, 2025

I will merge this first to satisfy the needs of #130407, then I will clean up its usage in the src folder.

@c8ef c8ef merged commit 426caf1 into llvm:main Mar 11, 2025
20 checks passed
@c8ef c8ef deleted the locale branch March 11, 2025 00:46
c8ef added a commit that referenced this pull request Mar 13, 2025
Address review comments in
#130621 (review).

Some unused headers are also removed.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Mar 13, 2025
…130982)

Address review comments in
llvm/llvm-project#130621 (review).

Some unused headers are also removed.
frederik-h pushed a commit to frederik-h/llvm-project that referenced this pull request Mar 18, 2025
Address review comments in
llvm#130621 (review).

Some unused headers are also removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants