1# log10.m4 serial 11 2dnl Copyright (C) 2011-2021 Free Software Foundation, Inc. 3dnl This file is free software; the Free Software Foundation 4dnl gives unlimited permission to copy and/or distribute it, 5dnl with or without modifications, as long as this notice is preserved. 6 7AC_DEFUN([gl_FUNC_LOG10], 8[ 9 m4_divert_text([DEFAULTS], [gl_log10_required=plain]) 10 AC_REQUIRE([gl_MATH_H_DEFAULTS]) 11 12 dnl Determine LOG10_LIBM. 13 gl_COMMON_DOUBLE_MATHFUNC([log10]) 14 15 save_LIBS="$LIBS" 16 LIBS="$LIBS $LOG10_LIBM" 17 gl_FUNC_LOG10_WORKS 18 LIBS="$save_LIBS" 19 case "$gl_cv_func_log10_works" in 20 *yes) ;; 21 *) REPLACE_LOG10=1 ;; 22 esac 23 24 m4_ifdef([gl_FUNC_LOG10_IEEE], [ 25 if test $gl_log10_required = ieee && test $REPLACE_LOG10 = 0; then 26 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 27 AC_CACHE_CHECK([whether log10 works according to ISO C 99 with IEC 60559], 28 [gl_cv_func_log10_ieee], 29 [ 30 save_LIBS="$LIBS" 31 LIBS="$LIBS $LOG10_LIBM" 32 AC_RUN_IFELSE( 33 [AC_LANG_SOURCE([[ 34#ifndef __NO_MATH_INLINES 35# define __NO_MATH_INLINES 1 /* for glibc */ 36#endif 37#include <math.h> 38/* Compare two numbers with ==. 39 This is a separate function because IRIX 6.5 "cc -O" miscompiles an 40 'x == x' test. */ 41static int 42numeric_equal (double x, double y) 43{ 44 return x == y; 45} 46static double dummy (double x) { return 0; } 47int main (int argc, char *argv[]) 48{ 49 double (* volatile my_log10) (double) = argc ? log10 : dummy; 50 /* Test log10(negative). 51 This test fails on NetBSD 5.1, Solaris 11.4. */ 52 double y = my_log10 (-1.0); 53 if (numeric_equal (y, y)) 54 return 1; 55 return 0; 56} 57 ]])], 58 [gl_cv_func_log10_ieee=yes], 59 [gl_cv_func_log10_ieee=no], 60 [case "$host_os" in 61 # Guess yes on glibc systems. 62 *-gnu* | gnu*) gl_cv_func_log10_ieee="guessing yes" ;; 63 # Guess yes on musl systems. 64 *-musl*) gl_cv_func_log10_ieee="guessing yes" ;; 65 # Guess yes on native Windows. 66 mingw*) gl_cv_func_log10_ieee="guessing yes" ;; 67 # If we don't know, obey --enable-cross-guesses. 68 *) gl_cv_func_log10_ieee="$gl_cross_guess_normal" ;; 69 esac 70 ]) 71 LIBS="$save_LIBS" 72 ]) 73 case "$gl_cv_func_log10_ieee" in 74 *yes) ;; 75 *) REPLACE_LOG10=1 ;; 76 esac 77 fi 78 ]) 79]) 80 81dnl Test whether log10() works. 82dnl On OSF/1 5.1, log10(-0.0) is NaN. 83AC_DEFUN([gl_FUNC_LOG10_WORKS], 84[ 85 AC_REQUIRE([AC_PROG_CC]) 86 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 87 AC_CACHE_CHECK([whether log10 works], [gl_cv_func_log10_works], 88 [ 89 AC_RUN_IFELSE( 90 [AC_LANG_SOURCE([[ 91#include <math.h> 92volatile double x; 93double y; 94int main () 95{ 96 x = -0.0; 97 y = log10 (x); 98 if (!(y + y == y)) 99 return 1; 100 return 0; 101} 102]])], 103 [gl_cv_func_log10_works=yes], 104 [gl_cv_func_log10_works=no], 105 [case "$host_os" in 106 osf*) gl_cv_func_log10_works="guessing no" ;; 107 # Guess yes on native Windows. 108 mingw*) gl_cv_func_log10_works="guessing yes" ;; 109 *) gl_cv_func_log10_works="guessing yes" ;; 110 esac 111 ]) 112 ]) 113]) 114