Branch
Hash :
1d7b3715
Author :
Date :
2025-09-10T22:59:25
ilogb: Remove support for IRIX. * m4/ilogb.m4 (gl_FUNC_ILOGB_WORKS): Remove code for IRIX.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
# ilogb.m4
# serial 11
dnl Copyright (C) 2010-2025 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl This file is offered as-is, without any warranty.
AC_DEFUN([gl_FUNC_ILOGB],
[
AC_REQUIRE([gl_MATH_H_DEFAULTS])
dnl Determine ILOGB_LIBM.
gl_MATHFUNC([ilogb], [int], [(double)])
if test $gl_cv_func_ilogb_no_libm = yes \
|| test $gl_cv_func_ilogb_in_libm = yes; then
saved_LIBS="$LIBS"
LIBS="$LIBS $ILOGB_LIBM"
gl_FUNC_ILOGB_WORKS
LIBS="$saved_LIBS"
case "$gl_cv_func_ilogb_works" in
*yes) ;;
*) REPLACE_ILOGB=1 ;;
esac
else
HAVE_ILOGB=0
fi
if test $HAVE_ILOGB = 0 || test $REPLACE_ILOGB = 1; then
dnl Find libraries needed to link lib/ilogb.c.
AC_REQUIRE([gl_FUNC_FREXP])
AC_REQUIRE([gl_FUNC_ISNAND])
ILOGB_LIBM=
dnl Append $FREXP_LIBM to ILOGB_LIBM, avoiding gratuitous duplicates.
case " $ILOGB_LIBM " in
*" $FREXP_LIBM "*) ;;
*) ILOGB_LIBM="$ILOGB_LIBM $FREXP_LIBM" ;;
esac
dnl Append $ISNAND_LIBM to ILOGB_LIBM, avoiding gratuitous duplicates.
case " $ILOGB_LIBM " in
*" $ISNAND_LIBM "*) ;;
*) ILOGB_LIBM="$ILOGB_LIBM $ISNAND_LIBM" ;;
esac
fi
AC_SUBST([ILOGB_LIBM])
])
dnl Test whether ilogb() works.
dnl On OpenBSD 6.7, AIX 5.1, ilogb(0.0) is wrong.
dnl On Mac OS X 10.5 in 64-bit mode and on AIX 7.1 in 64-bit mode,
dnl ilogb(2^(DBL_MIN_EXP-1)) is wrong.
dnl On NetBSD 7.1, OpenBSD 6.7, ilogb(Infinity) is wrong.
dnl On NetBSD 7.1, OpenBSD 6.7, ilogb(NaN) is wrong.
AC_DEFUN([gl_FUNC_ILOGB_WORKS],
[
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
AC_CACHE_CHECK([whether ilogb works], [gl_cv_func_ilogb_works],
[
AC_RUN_IFELSE(
[AC_LANG_SOURCE([[
#include <float.h>
#include <limits.h>
#include <math.h>
/* Provide FP_ILOGB0, FP_ILOGBNAN, like in math.in.h. */
#if defined FP_ILOGB0 && defined FP_ILOGBNAN
# if defined __HAIKU__
/* Haiku: match what ilogb() does */
# undef FP_ILOGB0
# undef FP_ILOGBNAN
# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */
# define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */
# endif
#else
# if defined __NetBSD__
/* NetBSD: match what ilogb() does */
# define FP_ILOGB0 INT_MIN
# define FP_ILOGBNAN INT_MIN
# elif defined _AIX
/* AIX 5.1: match what ilogb() does in AIX >= 5.2 */
# define FP_ILOGB0 INT_MIN
# define FP_ILOGBNAN INT_MAX
# elif defined __sun
/* Solaris 9: match what ilogb() does */
# define FP_ILOGB0 (- INT_MAX)
# define FP_ILOGBNAN INT_MAX
# endif
#endif
volatile double x;
static double zero;
static int dummy (double x) { return 0; }
int main (int argc, char *argv[])
{
int (* volatile my_ilogb) (double) = argc ? ilogb : dummy;
int result = 0;
/* This test fails on OpenBSD 6.7, AIX 5.1. */
{
x = 0.0;
if (my_ilogb (x) != FP_ILOGB0)
result |= 1;
}
/* This test fails on Mac OS X 10.5 in 64-bit mode and on
AIX 7.1 in 64-bit mode. */
{
int i;
x = 0.5;
for (i = DBL_MIN_EXP - 1; i < 0; i++)
x = x * 0.5;
if (x > 0.0 && my_ilogb (x) != DBL_MIN_EXP - 2)
result |= 2;
}
/* This test fails on NetBSD 7.1, OpenBSD 6.7. */
{
x = 1.0 / zero;
if (my_ilogb (x) != INT_MAX)
result |= 4;
}
/* This test fails on NetBSD 7.1, OpenBSD 6.7. */
{
x = zero / zero;
if (my_ilogb (x) != FP_ILOGBNAN)
result |= 8;
}
return result;
}
]])],
[gl_cv_func_ilogb_works=yes],
[gl_cv_func_ilogb_works=no],
[case "$host_os" in
aix* | openbsd* | netbsd* | solaris*)
gl_cv_func_ilogb_works="guessing no" ;;
# Guess yes on native Windows.
mingw* | windows*)
gl_cv_func_ilogb_works="guessing yes" ;;
*) gl_cv_func_ilogb_works="guessing yes" ;;
esac
])
])
])