]> Savannah Git Hosting - gnulib.git/commitdiff
Fix compilation errors in C++ mode on Solaris 10 and Solaris 11.
authorBruno Haible <bruno@clisp.org>
Thu, 5 Dec 2019 21:25:04 +0000 (22:25 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 5 Dec 2019 21:25:04 +0000 (22:25 +0100)
* m4/isfinite.m4 (gl_ISFINITE): Require AC_CANONICAL_HOST. On Solaris,
set REPLACE_ISFINITE to 1.
* m4/isinf.m4 (gl_ISINF): Require AC_CANONICAL_HOST. On Solaris, set
REPLACE_ISINF to 1.
* m4/signbit.m4 (gl_SIGNBIT): On Solaris, set REPLACE_SIGNBIT to 1.
* lib/pthread.in.h (pthread_create, pthread_once, pthread_key_create):
Use _GL_CXXALIAS_SYS_CAST instead of _GL_CXXALIAS_SYS.
* lib/threads.in.h (call_once): Likewise.
* lib/iconv.in.h (iconv): Likewise.

ChangeLog
lib/iconv.in.h
lib/pthread.in.h
lib/threads.in.h
m4/isfinite.m4
m4/isinf.m4
m4/signbit.m4

index 8574070f1fb0f2a292e721886ab999d931e434e6..acfa55f5672b008c924f9e38229cca615eb6b674 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2019-12-05  Bruno Haible  <bruno@clisp.org>
+
+       Fix compilation errors in C++ mode on Solaris 10 and Solaris 11.
+       * m4/isfinite.m4 (gl_ISFINITE): Require AC_CANONICAL_HOST. On Solaris,
+       set REPLACE_ISFINITE to 1.
+       * m4/isinf.m4 (gl_ISINF): Require AC_CANONICAL_HOST. On Solaris, set
+       REPLACE_ISINF to 1.
+       * m4/signbit.m4 (gl_SIGNBIT): On Solaris, set REPLACE_SIGNBIT to 1.
+       * lib/pthread.in.h (pthread_create, pthread_once, pthread_key_create):
+       Use _GL_CXXALIAS_SYS_CAST instead of _GL_CXXALIAS_SYS.
+       * lib/threads.in.h (call_once): Likewise.
+       * lib/iconv.in.h (iconv): Likewise.
+
 2019-12-05  Bruno Haible  <bruno@clisp.org>
 
        wchar: Add more C++ tests.
index f244f87375f443069f723e185442848851c20137..62e69867c2a782ae03102fc0ea8a37a48b2ce681 100644 (file)
@@ -87,10 +87,12 @@ _GL_CXXALIAS_RPL (iconv, size_t,
                    @ICONV_CONST@ char **inbuf, size_t *inbytesleft,
                    char **outbuf, size_t *outbytesleft));
 # else
-_GL_CXXALIAS_SYS (iconv, size_t,
-                  (iconv_t cd,
-                   @ICONV_CONST@ char **inbuf, size_t *inbytesleft,
-                   char **outbuf, size_t *outbytesleft));
+/* Need to cast, because on some versions of Solaris, ICONV_CONST does
+   not have the right value for C++.  */
+_GL_CXXALIAS_SYS_CAST (iconv, size_t,
+                       (iconv_t cd,
+                        @ICONV_CONST@ char **inbuf, size_t *inbytesleft,
+                        char **outbuf, size_t *outbytesleft));
 # endif
 _GL_CXXALIASWARN (iconv);
 # ifndef ICONV_CONST
index a2c76e44fa151b39ef369043993995b39f0ca8e2..4ba7e7b0d92e5f91fbc9b7d3fa9cbc7311b88b35 100644 (file)
@@ -464,9 +464,9 @@ _GL_FUNCDECL_SYS (pthread_create, int,
                    void * (*mainfunc) (void *), void *arg)
                   _GL_ARG_NONNULL ((1, 3)));
 #  endif
-_GL_CXXALIAS_SYS (pthread_create, int,
-                  (pthread_t *threadp, const pthread_attr_t *attr,
-                   void * (*mainfunc) (void *), void *arg));
+_GL_CXXALIAS_SYS_CAST (pthread_create, int,
+                       (pthread_t *threadp, const pthread_attr_t *attr,
+                        void * (*mainfunc) (void *), void *arg));
 # endif
 _GL_CXXALIASWARN (pthread_create);
 #elif defined GNULIB_POSIXCHECK
@@ -721,8 +721,9 @@ _GL_FUNCDECL_SYS (pthread_once, int,
                   (pthread_once_t *once_control, void (*initfunction) (void))
                    _GL_ARG_NONNULL ((1, 2)));
 #  endif
-_GL_CXXALIAS_SYS (pthread_once, int,
-                  (pthread_once_t *once_control, void (*initfunction) (void)));
+_GL_CXXALIAS_SYS_CAST (pthread_once, int,
+                       (pthread_once_t *once_control,
+                        void (*initfunction) (void)));
 # endif
 _GL_CXXALIASWARN (pthread_once);
 #elif defined GNULIB_POSIXCHECK
@@ -1595,8 +1596,8 @@ _GL_FUNCDECL_SYS (pthread_key_create, int,
                   (pthread_key_t *keyp, void (*destructor) (void *))
                   _GL_ARG_NONNULL ((1)));
 #  endif
-_GL_CXXALIAS_SYS (pthread_key_create, int,
-                  (pthread_key_t *keyp, void (*destructor) (void *)));
+_GL_CXXALIAS_SYS_CAST (pthread_key_create, int,
+                       (pthread_key_t *keyp, void (*destructor) (void *)));
 # endif
 _GL_CXXALIASWARN (pthread_key_create);
 #elif defined GNULIB_POSIXCHECK
index 1d28351efa54d34bb9c17257db2729642ffb0a62..31362579c2008b21413a5847de87066b2c515cca 100644 (file)
@@ -438,7 +438,7 @@ typedef pthread_once_t once_flag;
 _GL_FUNCDECL_SYS (call_once, void, (once_flag *, void (*) (void))
                                    _GL_ARG_NONNULL ((1, 2)));
 # endif
-_GL_CXXALIAS_SYS (call_once, void, (once_flag *, void (*) (void)));
+_GL_CXXALIAS_SYS_CAST (call_once, void, (once_flag *, void (*) (void)));
 _GL_CXXALIASWARN (call_once);
 #elif defined GNULIB_POSIXCHECK
 # undef call_once
index e2a0234440dd2abf5212897cbdd2479e0725505a..1eb6c0bc7075f8020075141bd8ecc725399d6812 100644 (file)
@@ -1,4 +1,4 @@
-# isfinite.m4 serial 16
+# isfinite.m4 serial 17
 dnl Copyright (C) 2007-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,6 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_ISFINITE],
 [
   AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  AC_REQUIRE([AC_CANONICAL_HOST])
   dnl Persuade glibc <math.h> to declare isfinite.
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_CHECK_DECLS([isfinite], , , [[#include <math.h>]])
@@ -25,8 +26,13 @@ AC_DEFUN([gl_ISFINITE],
       dnl isfinite(long double) also does not work in this situation.
     fi
   fi
-  if test "$ac_cv_have_decl_isfinite" != yes ||
-     test "$ISFINITE_LIBM" = missing; then
+  dnl On Solaris 10, with CC in C++ mode, isfinite is not available although
+  dnl is with cc in C mode. This cannot be worked around by defining
+  dnl _XOPEN_SOURCE=600, because the latter does not work in C++ mode on
+  dnl Solaris 11.0. Therefore use the replacement functions on Solaris.
+  if test "$ac_cv_have_decl_isfinite" != yes \
+     || test "$ISFINITE_LIBM" = missing \
+     || { case "$host_os" in solaris*) true;; *) false;; esac; }; then
     REPLACE_ISFINITE=1
     dnl No libraries are needed to link lib/isfinite.c.
     ISFINITE_LIBM=
index 9bafc53f3489ef85f259484a69167faf72545832..920be7e49ce0cf24e22d3f04c29e341651e1f9e5 100644 (file)
@@ -1,4 +1,4 @@
-# isinf.m4 serial 12
+# isinf.m4 serial 13
 dnl Copyright (C) 2007-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,6 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_ISINF],
 [
   AC_REQUIRE([gl_MATH_H_DEFAULTS])
+  AC_REQUIRE([AC_CANONICAL_HOST])
   dnl Persuade glibc <math.h> to declare isinf.
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_CHECK_DECLS([isinf], , ,
@@ -26,8 +27,13 @@ AC_DEFUN([gl_ISINF],
       esac
     fi
   fi
-  if test "$ac_cv_have_decl_isinf" != yes ||
-     test "$ISINF_LIBM" = missing; then
+  dnl On Solaris 10, with CC in C++ mode, isinf is not available although
+  dnl is with cc in C mode. This cannot be worked around by defining
+  dnl _XOPEN_SOURCE=600, because the latter does not work in C++ mode on
+  dnl Solaris 11.0. Therefore use the replacement functions on Solaris.
+  if test "$ac_cv_have_decl_isinf" != yes \
+     || test "$ISINF_LIBM" = missing \
+     || { case "$host_os" in solaris*) true;; *) false;; esac; }; then
     REPLACE_ISINF=1
     dnl No libraries are needed to link lib/isinf.c.
     ISINF_LIBM=
index 097682b26ae6340fc69dd7dc72b0f1fc6f46dfd3..2718aef7f57e8cb5961c4e2816c9c8cbb0c55f69 100644 (file)
@@ -1,4 +1,4 @@
-# signbit.m4 serial 18
+# signbit.m4 serial 19
 dnl Copyright (C) 2007-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,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_SIGNBIT],
 [
   AC_REQUIRE([gl_MATH_H_DEFAULTS])
-  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_REQUIRE([AC_CANONICAL_HOST])
   AC_CACHE_CHECK([for signbit macro], [gl_cv_func_signbit],
     [
       AC_RUN_IFELSE(
@@ -90,79 +90,90 @@ AC_DEFUN([gl_SIGNBIT],
         *)
           dnl REPLACE_SIGNBIT=1 makes sure the signbit[fdl] functions get built.
           REPLACE_SIGNBIT=1
-          gl_FLOAT_SIGN_LOCATION
-          gl_DOUBLE_SIGN_LOCATION
-          gl_LONG_DOUBLE_SIGN_LOCATION
-          if test "$gl_cv_cc_float_signbit" = unknown; then
-            dnl Test whether copysignf() is declared.
-            AC_CHECK_DECLS([copysignf], , , [[#include <math.h>]])
-            if test "$ac_cv_have_decl_copysignf" = yes; then
-              dnl Test whether copysignf() can be used without libm.
-              AC_CACHE_CHECK([whether copysignf can be used without linking with libm],
-                [gl_cv_func_copysignf_no_libm],
-                [
-                  AC_LINK_IFELSE(
-                    [AC_LANG_PROGRAM(
-                       [[#include <math.h>
-                         float x, y;]],
-                       [[return copysignf (x, y) < 0;]])],
-                    [gl_cv_func_copysignf_no_libm=yes],
-                    [gl_cv_func_copysignf_no_libm=no])
-                ])
-              if test $gl_cv_func_copysignf_no_libm = yes; then
-                AC_DEFINE([HAVE_COPYSIGNF_IN_LIBC], [1],
-                  [Define if the copysignf function is declared in <math.h> and available in libc.])
-              fi
-            fi
-          fi
-          if test "$gl_cv_cc_double_signbit" = unknown; then
-            dnl Test whether copysign() is declared.
-            AC_CHECK_DECLS([copysign], , , [[#include <math.h>]])
-            if test "$ac_cv_have_decl_copysign" = yes; then
-              dnl Test whether copysign() can be used without libm.
-              AC_CACHE_CHECK([whether copysign can be used without linking with libm],
-                [gl_cv_func_copysign_no_libm],
-                [
-                  AC_LINK_IFELSE(
-                    [AC_LANG_PROGRAM(
-                       [[#include <math.h>
-                         double x, y;]],
-                       [[return copysign (x, y) < 0;]])],
-                    [gl_cv_func_copysign_no_libm=yes],
-                    [gl_cv_func_copysign_no_libm=no])
-                ])
-              if test $gl_cv_func_copysign_no_libm = yes; then
-                AC_DEFINE([HAVE_COPYSIGN_IN_LIBC], [1],
-                  [Define if the copysign function is declared in <math.h> and available in libc.])
-              fi
-            fi
-          fi
-          if test "$gl_cv_cc_long_double_signbit" = unknown; then
-            dnl Test whether copysignl() is declared.
-            AC_CHECK_DECLS([copysignl], , , [[#include <math.h>]])
-            if test "$ac_cv_have_decl_copysignl" = yes; then
-              dnl Test whether copysignl() can be used without libm.
-              AC_CACHE_CHECK([whether copysignl can be used without linking with libm],
-                [gl_cv_func_copysignl_no_libm],
-                [
-                  AC_LINK_IFELSE(
-                    [AC_LANG_PROGRAM(
-                       [[#include <math.h>
-                         long double x, y;]],
-                       [[return copysignl (x, y) < 0;]])],
-                    [gl_cv_func_copysignl_no_libm=yes],
-                    [gl_cv_func_copysignl_no_libm=no])
-                ])
-              if test $gl_cv_func_copysignl_no_libm = yes; then
-                AC_DEFINE([HAVE_COPYSIGNL_IN_LIBC], [1],
-                  [Define if the copysignl function is declared in <math.h> and available in libc.])
-              fi
-            fi
-          fi
           ;;
       esac
       ;;
   esac
+  dnl On Solaris 10, with CC in C++ mode, signbit is not available although
+  dnl is with cc in C mode. This cannot be worked around by defining
+  dnl _XOPEN_SOURCE=600, because the latter does not work in C++ mode on
+  dnl Solaris 11.0. Therefore use the replacement functions on Solaris.
+  case "$host_os" in
+    solaris*)
+      REPLACE_SIGNBIT=1
+      ;;
+  esac
+  if test $REPLACE_SIGNBIT = 1; then
+    gl_FLOAT_SIGN_LOCATION
+    gl_DOUBLE_SIGN_LOCATION
+    gl_LONG_DOUBLE_SIGN_LOCATION
+    if test "$gl_cv_cc_float_signbit" = unknown; then
+      dnl Test whether copysignf() is declared.
+      AC_CHECK_DECLS([copysignf], , , [[#include <math.h>]])
+      if test "$ac_cv_have_decl_copysignf" = yes; then
+        dnl Test whether copysignf() can be used without libm.
+        AC_CACHE_CHECK([whether copysignf can be used without linking with libm],
+          [gl_cv_func_copysignf_no_libm],
+          [
+            AC_LINK_IFELSE(
+              [AC_LANG_PROGRAM(
+                 [[#include <math.h>
+                   float x, y;]],
+                 [[return copysignf (x, y) < 0;]])],
+              [gl_cv_func_copysignf_no_libm=yes],
+              [gl_cv_func_copysignf_no_libm=no])
+          ])
+        if test $gl_cv_func_copysignf_no_libm = yes; then
+          AC_DEFINE([HAVE_COPYSIGNF_IN_LIBC], [1],
+            [Define if the copysignf function is declared in <math.h> and available in libc.])
+        fi
+      fi
+    fi
+    if test "$gl_cv_cc_double_signbit" = unknown; then
+      dnl Test whether copysign() is declared.
+      AC_CHECK_DECLS([copysign], , , [[#include <math.h>]])
+      if test "$ac_cv_have_decl_copysign" = yes; then
+        dnl Test whether copysign() can be used without libm.
+        AC_CACHE_CHECK([whether copysign can be used without linking with libm],
+          [gl_cv_func_copysign_no_libm],
+          [
+            AC_LINK_IFELSE(
+              [AC_LANG_PROGRAM(
+                 [[#include <math.h>
+                   double x, y;]],
+                 [[return copysign (x, y) < 0;]])],
+              [gl_cv_func_copysign_no_libm=yes],
+              [gl_cv_func_copysign_no_libm=no])
+          ])
+        if test $gl_cv_func_copysign_no_libm = yes; then
+          AC_DEFINE([HAVE_COPYSIGN_IN_LIBC], [1],
+            [Define if the copysign function is declared in <math.h> and available in libc.])
+        fi
+      fi
+    fi
+    if test "$gl_cv_cc_long_double_signbit" = unknown; then
+      dnl Test whether copysignl() is declared.
+      AC_CHECK_DECLS([copysignl], , , [[#include <math.h>]])
+      if test "$ac_cv_have_decl_copysignl" = yes; then
+        dnl Test whether copysignl() can be used without libm.
+        AC_CACHE_CHECK([whether copysignl can be used without linking with libm],
+          [gl_cv_func_copysignl_no_libm],
+          [
+            AC_LINK_IFELSE(
+              [AC_LANG_PROGRAM(
+                 [[#include <math.h>
+                   long double x, y;]],
+                 [[return copysignl (x, y) < 0;]])],
+              [gl_cv_func_copysignl_no_libm=yes],
+              [gl_cv_func_copysignl_no_libm=no])
+          ])
+        if test $gl_cv_func_copysignl_no_libm = yes; then
+          AC_DEFINE([HAVE_COPYSIGNL_IN_LIBC], [1],
+            [Define if the copysignl function is declared in <math.h> and available in libc.])
+        fi
+      fi
+    fi
+  fi
 ])
 
 AC_DEFUN([gl_SIGNBIT_TEST_PROGRAM], [[