Paul Eggert wrote: > +# FIXME: This implementation is a copy of printf-frexp.m4 and should be > shared.
Indeed, it's bad for maintenance to have several macros which set the same autoconf cache variable, as they can easily evolve differently. I'm fixing these 4 occurrences: 2010-07-12 Bruno Haible <br...@clisp.org> Unify tests that set gl_cv_func_frexp_no_libm. * m4/frexp.m4 (gl_CHECK_FREXP_NO_LIBM): New macro, extracted from gl_FUNC_FREXP_NO_LIBM. (gl_FUNC_FREXP, gl_FUNC_FREXP_NO_LIBM): Require it. * m4/printf-frexp.m4 (gl_FUNC_PRINTF_FREXP): Likewise. --- m4/frexp.m4.orig Mon Jul 12 23:04:11 2010 +++ m4/frexp.m4 Mon Jul 12 23:03:21 2010 @@ -1,5 +1,5 @@ -# frexp.m4 serial 7 -dnl Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +# frexp.m4 serial 8 +dnl Copyright (C) 2007-2010 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. @@ -7,16 +7,8 @@ AC_DEFUN([gl_FUNC_FREXP], [ AC_REQUIRE([gl_MATH_H_DEFAULTS]) + AC_REQUIRE([gl_CHECK_FREXP_NO_LIBM]) FREXP_LIBM= - AC_CACHE_CHECK([whether frexp() can be used without linking with libm], - [gl_cv_func_frexp_no_libm], - [ - AC_TRY_LINK([#include <math.h> - double x;], - [int e; return frexp (x, &e) > 0;], - [gl_cv_func_frexp_no_libm=yes], - [gl_cv_func_frexp_no_libm=no]) - ]) if test $gl_cv_func_frexp_no_libm = no; then AC_CACHE_CHECK([whether frexp() can be used with libm], [gl_cv_func_frexp_in_libm], @@ -59,15 +51,7 @@ AC_DEFUN([gl_FUNC_FREXP_NO_LIBM], [ AC_REQUIRE([gl_MATH_H_DEFAULTS]) - AC_CACHE_CHECK([whether frexp() can be used without linking with libm], - [gl_cv_func_frexp_no_libm], - [ - AC_TRY_LINK([#include <math.h> - double x;], - [int e; return frexp (x, &e) > 0;], - [gl_cv_func_frexp_no_libm=yes], - [gl_cv_func_frexp_no_libm=no]) - ]) + AC_REQUIRE([gl_CHECK_FREXP_NO_LIBM]) if test $gl_cv_func_frexp_no_libm = yes; then gl_FUNC_FREXP_WORKS case "$gl_cv_func_frexp_works" in @@ -87,6 +71,21 @@ fi ]) +dnl Check whether frexp() can be used without linking with libm. +dnl Set gl_cv_func_frexp_no_libm to 'yes' or 'no' accordingly. +AC_DEFUN([gl_CHECK_FREXP_NO_LIBM], +[ + AC_CACHE_CHECK([whether frexp() can be used without linking with libm], + [gl_cv_func_frexp_no_libm], + [ + AC_TRY_LINK([#include <math.h> + double x;], + [int e; return frexp (x, &e) > 0;], + [gl_cv_func_frexp_no_libm=yes], + [gl_cv_func_frexp_no_libm=no]) + ]) +]) + dnl Test whether frexp() works also on denormalized numbers (this fails e.g. on dnl NetBSD 3.0), on infinite numbers (this fails e.g. on IRIX 6.5 and mingw), dnl and on negative zero (this fails e.g. on NetBSD 4.99). --- m4/printf-frexp.m4.orig Mon Jul 12 23:04:11 2010 +++ m4/printf-frexp.m4 Mon Jul 12 23:03:20 2010 @@ -1,5 +1,5 @@ -# printf-frexp.m4 serial 3 -dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. +# printf-frexp.m4 serial 4 +dnl Copyright (C) 2007, 2009-2010 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. @@ -8,16 +8,7 @@ AC_DEFUN([gl_FUNC_PRINTF_FREXP], [ - AC_CACHE_CHECK([whether frexp can be used without linking with libm], - [gl_cv_func_frexp_no_libm], - [ - AC_TRY_LINK([#include <math.h> - double x; - int y;], - [return frexp (x, &y) < 1;], - [gl_cv_func_frexp_no_libm=yes], - [gl_cv_func_frexp_no_libm=no]) - ]) + AC_REQUIRE([gl_CHECK_FREXP_NO_LIBM]) if test $gl_cv_func_frexp_no_libm = yes; then gl_FUNC_FREXP_WORKS case "$gl_cv_func_frexp_works" in 2010-07-12 Bruno Haible <br...@clisp.org> Unify tests that set gl_cv_func_frexpl_no_libm. * m4/frexpl.m4 (gl_CHECK_FREXPL_NO_LIBM): New macro, extracted from gl_FUNC_FREXPL_NO_LIBM. (gl_FUNC_FREXPL, gl_FUNC_FREXPL_NO_LIBM): Invoke it. * m4/printf-frexpl.m4 (gl_FUNC_PRINTF_FREXPL): Likewise. --- m4/frexpl.m4.orig Mon Jul 12 23:14:48 2010 +++ m4/frexpl.m4 Mon Jul 12 23:13:29 2010 @@ -1,4 +1,4 @@ -# frexpl.m4 serial 9 +# frexpl.m4 serial 10 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,15 +12,7 @@ AC_CHECK_DECL([frexpl], , [HAVE_DECL_FREXPL=0], [#include <math.h>]) FREXPL_LIBM= if test $HAVE_DECL_FREXPL = 1; then - AC_CACHE_CHECK([whether frexpl() can be used without linking with libm], - [gl_cv_func_frexpl_no_libm], - [ - AC_TRY_LINK([#include <math.h> - long double x;], - [int e; return frexpl (x, &e) > 0;], - [gl_cv_func_frexpl_no_libm=yes], - [gl_cv_func_frexpl_no_libm=no]) - ]) + gl_CHECK_FREXPL_NO_LIBM if test $gl_cv_func_frexpl_no_libm = no; then AC_CACHE_CHECK([whether frexpl() can be used with libm], [gl_cv_func_frexpl_in_libm], @@ -69,15 +61,7 @@ dnl MacOS X 10.3 has frexpl() in libc but doesn't declare it in <math.h>. AC_CHECK_DECL([frexpl], , [HAVE_DECL_FREXPL=0], [#include <math.h>]) if test $HAVE_DECL_FREXPL = 1; then - AC_CACHE_CHECK([whether frexpl() can be used without linking with libm], - [gl_cv_func_frexpl_no_libm], - [ - AC_TRY_LINK([#include <math.h> - long double x;], - [int e; return frexpl (x, &e) > 0;], - [gl_cv_func_frexpl_no_libm=yes], - [gl_cv_func_frexpl_no_libm=no]) - ]) + gl_CHECK_FREXPL_NO_LIBM if test $gl_cv_func_frexpl_no_libm = yes; then gl_FUNC_FREXPL_WORKS case "$gl_cv_func_frexpl_works" in @@ -99,6 +83,21 @@ fi ]) +dnl Test whether frexpl() can be used without linking with libm. +dnl Set gl_cv_func_frexpl_no_libm to 'yes' or 'no' accordingly. +AC_DEFUN([gl_CHECK_FREXPL_NO_LIBM], +[ + AC_CACHE_CHECK([whether frexpl() can be used without linking with libm], + [gl_cv_func_frexpl_no_libm], + [ + AC_TRY_LINK([#include <math.h> + long double x;], + [int e; return frexpl (x, &e) > 0;], + [gl_cv_func_frexpl_no_libm=yes], + [gl_cv_func_frexpl_no_libm=no]) + ]) +]) + dnl Test whether frexpl() works on finite numbers (this fails on dnl MacOS X 10.4/PowerPC, on AIX 5.1, and on BeOS), on denormalized numbers dnl (this fails on MacOS X 10.5/i386), and also on infinite numbers (this --- m4/printf-frexpl.m4.orig Mon Jul 12 23:14:48 2010 +++ m4/printf-frexpl.m4 Mon Jul 12 23:14:33 2010 @@ -1,5 +1,5 @@ -# printf-frexpl.m4 serial 6 -dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. +# printf-frexpl.m4 serial 7 +dnl Copyright (C) 2007, 2009-2010 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. @@ -10,16 +10,7 @@ [ AC_REQUIRE([gl_MATH_H_DEFAULTS]) dnl Subset of gl_FUNC_FREXPL_NO_LIBM. - AC_CACHE_CHECK([whether frexpl can be used without linking with libm], - [gl_cv_func_frexpl_no_libm], - [ - AC_TRY_LINK([#include <math.h> - long double x; - int y;], - [return frexpl (x, &y) < 1;], - [gl_cv_func_frexpl_no_libm=yes], - [gl_cv_func_frexpl_no_libm=no]) - ]) + gl_CHECK_FREXPL_NO_LIBM if test $gl_cv_func_frexpl_no_libm = yes; then gl_FUNC_FREXPL_WORKS case "$gl_cv_func_frexpl_works" in 2010-07-12 Bruno Haible <br...@clisp.org> Unify tests that set gl_cv_func_ldexp_no_libm. * m4/ldexp.m4: New file, based on m4/mathfunc.m4. * m4/strtod.m4 (gl_PREREQ_STRTOD): Require gl_CHECK_LDEXP_NO_LIBM. * modules/ldexp (Files): Remove m4/mathfunc.m4. Add m4/ldexp.m4. (configure.ac): Simply invoke gl_FUNC_LDEXP. * modules/strtod (Files): Add m4/ldexp.m4. ================================= m4/ldexp.m4 ================================= # ldexp.m4 serial 1 dnl Copyright (C) 2010 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. AC_DEFUN([gl_FUNC_LDEXP], [ AC_REQUIRE([gl_CHECK_LDEXP_NO_LIBM]) LDEXP_LIBM= if test $gl_cv_func_ldexp_no_libm = no; then AC_CACHE_CHECK([whether ldexp() can be used with libm], [gl_cv_func_ldexp_in_libm], [ save_LIBS="$LIBS" LIBS="$LIBS -lm" AC_LINK_IFELSE( [AC_LANG_PROGRAM([[#ifndef __NO_MATH_INLINES # define __NO_MATH_INLINES 1 /* for glibc */ #endif #include <math.h> double (*funcptr) (double, int) = ldexp; double x;]], [[return ldexp (x, -1) > 0;]])], [gl_cv_func_ldexp_in_libm=yes], [gl_cv_func_ldexp_in_libm=no]) LIBS="$save_LIBS" ]) if test $gl_cv_func_ldexp_in_libm = yes; then LDEXP_LIBM=-lm fi fi AC_SUBST([LDEXP_LIBM]) ]) dnl Test whether ldexp() can be used without linking with libm. dnl Set gl_cv_func_ldexp_no_libm to 'yes' or 'no' accordingly. AC_DEFUN([gl_CHECK_LDEXP_NO_LIBM], [ AC_CACHE_CHECK([whether ldexp() can be used without linking with libm], [gl_cv_func_ldexp_no_libm], [ AC_LINK_IFELSE( [AC_LANG_PROGRAM([[#ifndef __NO_MATH_INLINES # define __NO_MATH_INLINES 1 /* for glibc */ #endif #include <math.h> double (*funcptr) (double, int) = ldexp; double x;]], [[return ldexp (x, -1) > 0;]])], [gl_cv_func_ldexp_no_libm=yes], [gl_cv_func_ldexp_no_libm=no]) ]) ]) =============================================================================== --- m4/strtod.m4.orig Mon Jul 12 23:32:57 2010 +++ m4/strtod.m4 Mon Jul 12 23:32:09 2010 @@ -1,4 +1,4 @@ -# strtod.m4 serial 15 +# strtod.m4 serial 16 dnl Copyright (C) 2002-2003, 2006-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -119,18 +119,8 @@ ]) # Prerequisites of lib/strtod.c. -# FIXME: This implementation is a copy of printf-frexp.m4 and should be shared. AC_DEFUN([gl_PREREQ_STRTOD], [ - AC_CACHE_CHECK([whether ldexp can be used without linking with libm], - [gl_cv_func_ldexp_no_libm], - [ - AC_TRY_LINK([#include <math.h> - double x; - int y;], - [return ldexp (x, y) < 1;], - [gl_cv_func_ldexp_no_libm=yes], - [gl_cv_func_ldexp_no_libm=no]) - ]) + AC_REQUIRE([gl_CHECK_LDEXP_NO_LIBM]) if test $gl_cv_func_ldexp_no_libm = yes; then AC_DEFINE([HAVE_LDEXP_IN_LIBC], [1], [Define if the ldexp function is available in libc.]) --- modules/ldexp.orig Mon Jul 12 23:32:57 2010 +++ modules/ldexp Mon Jul 12 23:31:11 2010 @@ -2,12 +2,12 @@ ldexp() function: multiply a 'double' by a power of 2. Files: -m4/mathfunc.m4 +m4/ldexp.m4 Depends-on: configure.ac: -gl_MATHFUNC([ldexp], [double], [(double, int)]) +gl_FUNC_LDEXP Makefile.am: --- modules/strtod.orig Mon Jul 12 23:32:57 2010 +++ modules/strtod Mon Jul 12 23:32:35 2010 @@ -4,6 +4,7 @@ Files: lib/strtod.c m4/strtod.m4 +m4/ldexp.m4 Depends-on: c-ctype 2010-07-12 Bruno Haible <br...@clisp.org> Unify tests that set gl_cv_func_ldexpl_no_libm. * m4/ldexpl.m4 (gl_CHECK_LDEXPL_NO_LIBM): New macro, extracted from gl_FUNC_LDEXPL. (gl_FUNC_LDEXPL): Invoke it. * m4/printf-frexpl.m4 (gl_FUNC_PRINTF_FREXPL): Likewise. --- m4/ldexpl.m4.orig Mon Jul 12 23:40:36 2010 +++ m4/ldexpl.m4 Mon Jul 12 23:39:19 2010 @@ -1,4 +1,4 @@ -# ldexpl.m4 serial 5 +# ldexpl.m4 serial 6 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -12,15 +12,7 @@ AC_CHECK_DECL([ldexpl], , [HAVE_DECL_LDEXPL=0], [#include <math.h>]) LDEXPL_LIBM= if test $HAVE_DECL_LDEXPL = 1; then - AC_CACHE_CHECK([whether ldexpl() can be used without linking with libm], - [gl_cv_func_ldexpl_no_libm], - [ - AC_TRY_LINK([#include <math.h> - long double x;], - [return ldexpl (x, -1) > 0;], - [gl_cv_func_ldexpl_no_libm=yes], - [gl_cv_func_ldexpl_no_libm=no]) - ]) + gl_CHECK_LDEXPL_NO_LIBM if test $gl_cv_func_ldexpl_no_libm = no; then AC_CACHE_CHECK([whether ldexpl() can be used with libm], [gl_cv_func_ldexpl_in_libm], @@ -62,6 +54,21 @@ AC_SUBST([LDEXPL_LIBM]) ]) +dnl Test whether ldexpl() can be used without linking with libm. +dnl Set gl_cv_func_ldexpl_no_libm to 'yes' or 'no' accordingly. +AC_DEFUN([gl_CHECK_LDEXPL_NO_LIBM], +[ + AC_CACHE_CHECK([whether ldexpl() can be used without linking with libm], + [gl_cv_func_ldexpl_no_libm], + [ + AC_TRY_LINK([#include <math.h> + long double x;], + [return ldexpl (x, -1) > 0;], + [gl_cv_func_ldexpl_no_libm=yes], + [gl_cv_func_ldexpl_no_libm=no]) + ]) +]) + dnl Test whether ldexpl() works on finite numbers (this fails on AIX 5.1 dnl and MacOS X 10.4/PowerPC). AC_DEFUN([gl_FUNC_LDEXPL_WORKS], --- m4/printf-frexpl.m4.orig Mon Jul 12 23:40:36 2010 +++ m4/printf-frexpl.m4 Mon Jul 12 23:39:57 2010 @@ -30,16 +30,7 @@ AC_CHECK_DECL([frexpl], , [HAVE_DECL_FREXPL=0], [#include <math.h>]) fi - AC_CACHE_CHECK([whether ldexpl can be used without linking with libm], - [gl_cv_func_ldexpl_no_libm], - [ - AC_TRY_LINK([#include <math.h> - long double x; - int y;], - [return ldexpl (x, y) < 1;], - [gl_cv_func_ldexpl_no_libm=yes], - [gl_cv_func_ldexpl_no_libm=no]) - ]) + gl_CHECK_LDEXPL_NO_LIBM if test $gl_cv_func_ldexpl_no_libm = yes; then gl_FUNC_LDEXPL_WORKS case "$gl_cv_func_ldexpl_works" in