[libcxx-commits] [libcxx] 906e3ec - [AIX][libc++] Forward-declare locale functions in aix.h when _XOPEN_SOURCE < 700 (#220508)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Oct 6 19:53:22 PDT 2026
Author: Himadhith
Date: 2026-10-07T02:53:13Z
New Revision: 906e3ec0647aef01363973edf3cb0104a812589a
URL: https://github.com/llvm/llvm-project/commit/906e3ec0647aef01363973edf3cb0104a812589a
DIFF: https://github.com/llvm/llvm-project/commit/906e3ec0647aef01363973edf3cb0104a812589a.diff
LOG: [AIX][libc++] Forward-declare locale functions in aix.h when _XOPEN_SOURCE < 700 (#220508)
On AIX, the following locale function `uselocale` is only declared in
`usr/include/locale.h` when `_XOPEN_SOURCE > 700`.
This causes a failure in the test
`libcxx/test/extensions/posix/xopen_source.gen.py` which tests
`_XOPEN_SOURCE ` against 500, 600 and 700, with the following error:
```
#__locale_dir/support/aix.h:36:72: error: no member named 'uselocale' in the global namespace; did you mean 'setlocale'?
```
The fix here is to forward declare `uselocale` inside `aix.h` and make
it visible.
---------
Co-authored-by: himadhith <himadhith.v at ibm.com>
Added:
Modified:
libcxx/include/__locale_dir/support/aix.h
libcxx/test/extensions/posix/xopen_source.gen.py
Removed:
################################################################################
diff --git a/libcxx/include/__locale_dir/support/aix.h b/libcxx/include/__locale_dir/support/aix.h
index 17f095ac6ce424..ef2194eb2dff9b 100644
--- a/libcxx/include/__locale_dir/support/aix.h
+++ b/libcxx/include/__locale_dir/support/aix.h
@@ -32,12 +32,15 @@
_LIBCPP_BEGIN_NAMESPACE_STD
namespace __locale {
+// Forward declare for _XOPEN_SOURCE=500 and _XOPEN_SOURCE=600
+extern "C" locale_t __libcpp_aix_uselocale(locale_t) _NOEXCEPT __asm__("uselocale");
+
struct __locale_guard {
- _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t __loc) : __old_loc_(::uselocale(__loc)) {}
+ _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t __loc) : __old_loc_(__libcpp_aix_uselocale(__loc)) {}
_LIBCPP_HIDE_FROM_ABI ~__locale_guard() {
if (__old_loc_)
- ::uselocale(__old_loc_);
+ __libcpp_aix_uselocale(__old_loc_);
}
locale_t __old_loc_;
diff --git a/libcxx/test/extensions/posix/xopen_source.gen.py b/libcxx/test/extensions/posix/xopen_source.gen.py
index ac04e38bde38a5..bd14e691de5af1 100644
--- a/libcxx/test/extensions/posix/xopen_source.gen.py
+++ b/libcxx/test/extensions/posix/xopen_source.gen.py
@@ -12,10 +12,6 @@
#
# https://llvm.org/PR117630
-# The AIX localization support uses some functions as part of their headers that require a
-# recent value of _XOPEN_SOURCE.
-# UNSUPPORTED: LIBCXX-AIX-FIXME
-
# FreeBSD maps _XOPEN_SOURCE=500 to __ISO_C_VISIBLE=1990 (see <sys/_visible.h>), which hides
# everything C99 added to the C library, even in C++ mode. libc++ needs some of those
# additions to provide a conforming library at all.
More information about the libcxx-commits
mailing list