bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: IBM z/OS compatibility issues - per-thread locale functions


From: Bruno Haible
Subject: Re: IBM z/OS compatibility issues - per-thread locale functions
Date: Mon, 18 Nov 2019 01:17:46 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; )

Hello Daniel,

> BROKEN LOCALE FUNCTIONS
> 
> The configure script finds the following:
> 
>     checking for xlocale.h... no
>     checking for duplocale... yes
>     checking for uselocale... yes
>     checking for newlocale... yes
>     checking for freelocale... yes
> 
>     checking whether locale.h conforms to POSIX:2001... yes
>     checking whether uselocale works... no
> 
>     checking whether duplocale(LC_GLOBAL_LOCALE) works... no
> 
>     checking whether setlocale supports the C locale... yes
> 
> The problem is, those duplocale(), newlocale(), and freelocale()
> functions are not usable. Not only are they not declared in locale.h,
> not only does the runtime crash if you call them, the locale_t type
> isn't even defined. Here is a portion of the config.log output for the
> "duplocale works" test:
> 
>     configure:37076: checking whether duplocale(LC_GLOBAL_LOCALE) works
>     configure:37166: xlc-wrap -o conftest -g -qfloat=ieee -qlanglvl=extc99 
> -qenumsize=4 -D_UNIX95_THREADS -D_XOPEN_SOURCE=600 -DNSIG=39 
> -qhaltonmsg=CCN3296  conftest.c  >&5
>     ERROR CCN3275 ./conftest.c:405   Unexpected text loc encountered.
>     ERROR CCN3045 ./conftest.c:405   Undeclared identifier locale_t.
>     ERROR CCN3045 ./conftest.c:415   Undeclared identifier LC_GLOBAL_LOCALE.
>     ERROR CCN3045 ./conftest.c:415   Undeclared identifier loc.
>     CCN0793(I) Compilation failed for file ./conftest.c.  Object file not 
> created.
>     configure:37166: $? = 12
>     configure: program exited with status 12
> 
> And the "uselocale works" test, which fails in the crashing way:
> 
>     configure:24730: checking whether uselocale works
>     configure:24757: xlc-wrap -o conftest -g -qfloat=ieee -qlanglvl=extc99 
> -qenumsize=4 -D_UNIX95_THREADS -D_XOPEN_SOURCE=600 -DNSIG=39 
> -qhaltonmsg=CCN3296  conftest.c  >&5
>     configure:24757: $? = 0
>     configure:24757: ./conftest
>     CEE3728S The use of a function, which is not supported by this release of 
> Language Environment was detected.
>              From compile unit /tmp/gnulib-build/conftest.c at entry point 
> main at statement 275 at compile unit offset
>               +00000074 at entry offset +00000074 at address 2190A9BC.
>     configure:24757: $? = 137
>     configure: program exited with status 137
> 
> Currently, gnulib reads this as "Oh, the system duplocale() et al. are
> broken, let me replace them." Unfortunately, this results in build
> errors at the replacement function prototype, due to the missing
> locale_t type:
> 
>     xlc-wrap -DHAVE_CONFIG_H -I. -I/u/username/testdir/gllib -I.. 
> -DGNULIB_STRICT_CHECKING=1 -D_UNIX95_THREADS -D_XOPEN_SOURCE=600 -DNSIG=39 
> -qhaltonmsg=CCN3296  -g -qfloat=ieee -qlanglvl=extc99 -qenumsize=4  -c -o 
> hard-locale.o /u/username/testdir/gllib/hard-locale.c
>     ERROR CCN3166 ./locale.h:702   Definition of function locale_t requires 
> parentheses.
>     ERROR CCN3276 ./locale.h:702   Syntax error: possible missing '{'?
> 
> In order to get a successful build, I have to set
> 
>     ac_cv_func_duplocale=no
>     ac_cv_func_newlocale=no
> 
> before configuring. Could these functions (perhaps freelocale() too) be
> treated as non-existent if there is no usable locale_t type?
> Alternately, checking for their (missing) declarations should also work.

This patch should do it.


2019-11-17  Bruno Haible  <address@hidden>

        locale, localename: Improve z/OS support.
        Reported by Daniel Richard G. in
        <https://lists.gnu.org/archive/html/bug-gnulib/2019-11/msg00001.html>.
        * m4/locale_h.m4 (gl_LOCALE_T): New macro, partially extracted from
        gl_LOCALE_H.
        (gl_LOCALE_H): Require it.
        * m4/localename.m4 (gl_LOCALENAME): Likewise. If locale_t is not
        defined, don't even check for newlocale, duplocale, freelocale.
        * m4/intl-thread-locale.m4 (gt_FUNC_USELOCALE): Make the test fail when
        locale_t is not defined.

diff --git a/m4/intl-thread-locale.m4 b/m4/intl-thread-locale.m4
index 3ecba86..e43f602 100644
--- a/m4/intl-thread-locale.m4
+++ b/m4/intl-thread-locale.m4
@@ -1,4 +1,4 @@
-# intl-thread-locale.m4 serial 4
+# intl-thread-locale.m4 serial 5
 dnl Copyright (C) 2015-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -139,13 +139,15 @@ AC_DEFUN([gt_FUNC_USELOCALE],
 [
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
 
-  dnl Persuade Solaris <locale.h> to define 'locale_t'.
+  dnl Persuade glibc and Solaris <locale.h> to define 'locale_t'.
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
   AC_CHECK_FUNCS_ONCE([uselocale])
 
   dnl On AIX 7.2, the uselocale() function is not documented and leads to
   dnl crashes in subsequent setlocale() invocations.
+  dnl In 2019, some versions of z/OS lack the locale_t type and have a broken
+  dnl uselocale function.
   if test $ac_cv_func_uselocale = yes; then
     AC_CHECK_HEADERS_ONCE([xlocale.h])
     AC_CACHE_CHECK([whether uselocale works],
@@ -156,6 +158,7 @@ AC_DEFUN([gt_FUNC_USELOCALE],
 #if HAVE_XLOCALE_H
 # include <xlocale.h>
 #endif
+locale_t loc1;
 int main ()
 {
   uselocale (NULL);
@@ -164,10 +167,10 @@ int main ()
 }]])],
          [gt_cv_func_uselocale_works=yes],
          [gt_cv_func_uselocale_works=no],
-         [# Guess no on AIX, yes otherwise.
+         [# Guess no on AIX and z/OS, yes otherwise.
           case "$host_os" in
-            aix*) gt_cv_func_uselocale_works="guessing no" ;;
-            *)    gt_cv_func_uselocale_works="guessing yes" ;;
+            aix* | mvs*) gt_cv_func_uselocale_works="guessing no" ;;
+            *)           gt_cv_func_uselocale_works="guessing yes" ;;
           esac
          ])
       ])
diff --git a/m4/locale_h.m4 b/m4/locale_h.m4
index d28ba0c..380e40b 100644
--- a/m4/locale_h.m4
+++ b/m4/locale_h.m4
@@ -1,4 +1,4 @@
-# locale_h.m4 serial 21
+# locale_h.m4 serial 22
 dnl Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -17,6 +17,8 @@ AC_DEFUN([gl_LOCALE_H],
   dnl If <stddef.h> is replaced, then <locale.h> must also be replaced.
   AC_REQUIRE([gl_STDDEF_H])
 
+  AC_REQUIRE([gl_LOCALE_T])
+
   dnl Solaris 11.0 defines the int_p_*, int_n_* members of 'struct lconv'
   dnl only if _LCONV_C99 is defined.
   AC_REQUIRE([AC_CANONICAL_HOST])
@@ -37,34 +39,6 @@ AC_DEFUN([gl_LOCALE_H],
        [gl_cv_header_locale_h_posix2001=yes],
        [gl_cv_header_locale_h_posix2001=no])])
 
-  dnl Check for <xlocale.h>.
-  AC_CHECK_HEADERS_ONCE([xlocale.h])
-  if test $ac_cv_header_xlocale_h = yes; then
-    HAVE_XLOCALE_H=1
-    dnl Check whether use of locale_t requires inclusion of <xlocale.h>,
-    dnl e.g. on Mac OS X 10.5. If <locale.h> does not define locale_t by
-    dnl itself, we assume that <xlocale.h> will do so.
-    AC_CACHE_CHECK([whether locale.h defines locale_t],
-      [gl_cv_header_locale_has_locale_t],
-      [AC_COMPILE_IFELSE(
-         [AC_LANG_PROGRAM(
-            [[#include <locale.h>
-              locale_t x;]],
-            [[]])],
-         [gl_cv_header_locale_has_locale_t=yes],
-         [gl_cv_header_locale_has_locale_t=no])
-      ])
-    if test $gl_cv_header_locale_has_locale_t = yes; then
-      gl_cv_header_locale_h_needs_xlocale_h=no
-    else
-      gl_cv_header_locale_h_needs_xlocale_h=yes
-    fi
-  else
-    HAVE_XLOCALE_H=0
-    gl_cv_header_locale_h_needs_xlocale_h=no
-  fi
-  AC_SUBST([HAVE_XLOCALE_H])
-
   dnl Check whether 'struct lconv' is complete.
   dnl Bionic libc's 'struct lconv' is just a dummy.
   dnl On OpenBSD 4.9, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.5.x,
@@ -99,6 +73,49 @@ AC_DEFUN([gl_LOCALE_H],
     [setlocale newlocale duplocale freelocale])
 ])
 
+dnl Checks to determine whether the system has the locale_t type,
+dnl and how to obtain it.
+AC_DEFUN([gl_LOCALE_T],
+[
+  dnl Persuade glibc and Solaris <locale.h> to define locale_t.
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+
+  dnl Check whether use of locale_t requires inclusion of <xlocale.h>,
+  dnl e.g. on Mac OS X 10.5. If <locale.h> does not define locale_t by
+  dnl itself, we assume that <xlocale.h> will do so.
+  AC_CACHE_CHECK([whether locale.h defines locale_t],
+    [gl_cv_header_locale_has_locale_t],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <locale.h>
+            locale_t x;]],
+          [[]])],
+       [gl_cv_header_locale_has_locale_t=yes],
+       [gl_cv_header_locale_has_locale_t=no])
+    ])
+
+  dnl Check for <xlocale.h>.
+  AC_CHECK_HEADERS_ONCE([xlocale.h])
+  if test $ac_cv_header_xlocale_h = yes; then
+    HAVE_XLOCALE_H=1
+    if test $gl_cv_header_locale_has_locale_t = yes; then
+      gl_cv_header_locale_h_needs_xlocale_h=no
+    else
+      gl_cv_header_locale_h_needs_xlocale_h=yes
+    fi
+    HAVE_LOCALE_T=1
+  else
+    HAVE_XLOCALE_H=0
+    gl_cv_header_locale_h_needs_xlocale_h=no
+    if test $gl_cv_header_locale_has_locale_t = yes; then
+      HAVE_LOCALE_T=1
+    else
+      HAVE_LOCALE_T=0
+    fi
+  fi
+  AC_SUBST([HAVE_XLOCALE_H])
+])
+
 AC_DEFUN([gl_LOCALE_MODULE_INDICATOR],
 [
   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
diff --git a/m4/localename.m4 b/m4/localename.m4
index a9f629d..8e8d249 100644
--- a/m4/localename.m4
+++ b/m4/localename.m4
@@ -1,4 +1,4 @@
-# localename.m4 serial 6
+# localename.m4 serial 7
 dnl Copyright (C) 2007, 2009-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,11 +7,20 @@ dnl with or without modifications, as long as this notice is 
preserved.
 AC_DEFUN([gl_LOCALENAME],
 [
   AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
+  AC_REQUIRE([gl_LOCALE_T])
   AC_REQUIRE([gt_LC_MESSAGES])
   AC_REQUIRE([gt_INTL_THREAD_LOCALE_NAME])
   AC_REQUIRE([gt_INTL_MACOSX])
   AC_CHECK_HEADERS_ONCE([langinfo.h])
-  AC_CHECK_FUNCS_ONCE([newlocale duplocale freelocale])
+  if test $HAVE_LOCALE_T = 1; then
+    AC_CHECK_FUNCS_ONCE([newlocale duplocale freelocale])
+  else
+    dnl In 2019, some versions of z/OS lack the locale_t type and have broken
+    dnl newlocale, duplocale, freelocale functions.
+    ac_cv_func_newlocale=no
+    ac_cv_func_duplocale=no
+    ac_cv_func_freelocale=no
+  fi
   if test $ac_cv_func_newlocale != yes; then
     HAVE_NEWLOCALE=0
   fi




reply via email to

[Prev in Thread] Current Thread [Next in Thread]