From: Bruno Haible Date: Thu, 5 Dec 2019 21:25:04 +0000 (+0100) Subject: Fix compilation errors in C++ mode on Solaris 10 and Solaris 11. X-Git-Tag: v1.0~4550 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=0a13f6771d98fd03688a6e202f1e623010e49c6e;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 8574070f1f..acfa55f567 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2019-12-05 Bruno Haible + + 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 wchar: Add more C++ tests. diff --git a/lib/iconv.in.h b/lib/iconv.in.h index f244f87375..62e69867c2 100644 --- a/lib/iconv.in.h +++ b/lib/iconv.in.h @@ -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 diff --git a/lib/pthread.in.h b/lib/pthread.in.h index a2c76e44fa..4ba7e7b0d9 100644 --- a/lib/pthread.in.h +++ b/lib/pthread.in.h @@ -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 diff --git a/lib/threads.in.h b/lib/threads.in.h index 1d28351efa..31362579c2 100644 --- a/lib/threads.in.h +++ b/lib/threads.in.h @@ -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 diff --git a/m4/isfinite.m4 b/m4/isfinite.m4 index e2a0234440..1eb6c0bc70 100644 --- a/m4/isfinite.m4 +++ b/m4/isfinite.m4 @@ -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 to declare isfinite. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) AC_CHECK_DECLS([isfinite], , , [[#include ]]) @@ -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= diff --git a/m4/isinf.m4 b/m4/isinf.m4 index 9bafc53f34..920be7e49c 100644 --- a/m4/isinf.m4 +++ b/m4/isinf.m4 @@ -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 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= diff --git a/m4/signbit.m4 b/m4/signbit.m4 index 097682b26a..2718aef7f5 100644 --- a/m4/signbit.m4 +++ b/m4/signbit.m4 @@ -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 ]]) - 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 - 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 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 ]]) - 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 - 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 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 ]]) - 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 - 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 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 ]]) + 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 + 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 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 ]]) + 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 + 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 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 ]]) + 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 + 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 and available in libc.]) + fi + fi + fi + fi ]) AC_DEFUN([gl_SIGNBIT_TEST_PROGRAM], [[