Hi,

Andy Fiddaman wrote:
> The attached patch adds support for using the POSIX getlocalename_l() function
> in illumos to avoid having to reach into undocumented/opaque structs.

Thanks for notifying us about this. Yes, the purpose of getlocalename_l() in
POSIX is to avoid peeking into undocumented structs.

> 2025-05-03  Andy Fiddaman <illu...@fiddaman.net>
> 
>       getlocalename_l-unsafe: Add support for the POSIX 2024 getlocalename_l
>       on illumos to avoid reaching into undocumented structures.

Thanks for the patch. It could well work. Although, part of it is a no-op:

  - The change to m4/intl-thread-locale.m4 is redundant because the Autoconf
    macro that is used with getlocalename_l-unsafe.c, namely
    gl_FUNC_GETLOCALENAME_L_UNSAFE in m4/getlocalename_l.m4, already contains

      AC_CHECK_FUNCS_ONCE([getlocalename_l])

And an '#undef getlocalename_l' is needed, in order to avoid an endless
recursion when gnulib's module 'getlocalename_l-simple' is in use.

I was going to test the attached patch, but find that I cannot test it:
The commit 
https://github.com/illumos/illumos-gate/commit/004345e48064ccd168d15f66eba2031c6090ccee
is from 2025-04-24.
- In OmniOS, https://downloads.omnios.org/media/, the latest 'bloody'
  build and the modification time of the empty directory r151054
  both predate the 2025-04-24. So it's unclear to me what you have
  in fact tested. But it is not an environment that I can get hold of.
- In OpenIndiana, there is a download
  https://dlc.openindiana.org/isos/hipster/test/OI-hipster-gui-20250425.iso
  but it does not contain the function: "nm /lib/libc.so.1" does not list
  the getlocalename_l symbol, and "man getlocalename_l" returns nothing.

Since I don't want to commit an untested patch, I can only queue the
patch for now, for later testing.

Bruno
>From 9c8ce4cfd654c29cdab4df026bbd24b8a525b570 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sat, 3 May 2025 16:44:15 +0200
Subject: [PATCH] getlocalename_l-unsafe: Improve support for Solaris 11
 OpenIndiana.

Suggested by Andy Fiddaman <illu...@fiddaman.net> in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-05/msg00018.html>.

* lib/getlocalename_l-unsafe.c (getlocalename_l_unsafe): On Solaris, use
the system's getlocalename_l() function if available.
---
 ChangeLog                    |  8 ++++++++
 lib/getlocalename_l-unsafe.c | 11 +++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b7ac01b08c..e0c84fbb3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-05-03  Bruno Haible  <br...@clisp.org>
+
+	getlocalename_l-unsafe: Improve support for Solaris 11 OpenIndiana.
+	Suggested by Andy Fiddaman <illu...@fiddaman.net> in
+	<https://lists.gnu.org/archive/html/bug-gnulib/2025-05/msg00018.html>.
+	* lib/getlocalename_l-unsafe.c (getlocalename_l_unsafe): On Solaris, use
+	the system's getlocalename_l() function if available.
+
 2025-05-03  Bruno Haible  <br...@clisp.org>
 
 	getlocalename_l-unsafe: Fix typo in comment.
diff --git a/lib/getlocalename_l-unsafe.c b/lib/getlocalename_l-unsafe.c
index cb7ae5e5ea..66b2c74726 100644
--- a/lib/getlocalename_l-unsafe.c
+++ b/lib/getlocalename_l-unsafe.c
@@ -550,8 +550,14 @@ getlocalename_l_unsafe (int category, locale_t locale)
       /* We shouldn't get here.  */
       return (struct string_with_storage) { "", STORAGE_INDEFINITE };
 # else
-      /* Solaris 11 OpenIndiana.
-         For the internal structure of locale objects, see
+      /* Solaris 11 OpenIndiana or Solaris 11 OmniOS.  */
+#  if HAVE_GETLOCALENAME_L
+      /* illumos after April 2025.  */
+#   undef getlocalename_l
+      const char *name = getlocalename_l (category, locale);
+      return (struct string_with_storage) { name, STORAGE_OBJECT };
+#  else
+      /* For the internal structure of locale objects, see
          https://github.com/OpenIndiana/illumos-gate/blob/master/usr/src/lib/libc/port/locale/localeimpl.h  */
       switch (category)
         {
@@ -568,6 +574,7 @@ getlocalename_l_unsafe (int category, locale_t locale)
         default: /* We shouldn't get here.  */
           return (struct string_with_storage) { "", STORAGE_INDEFINITE };
         }
+#  endif
 # endif
 #elif HAVE_NAMELESS_LOCALES
       /* OpenBSD >= 6.2, AIX >= 7.1 */
-- 
2.43.0

Reply via email to