# HG changeset patch # User Bruno Haible # Date 1268003087 -3600 # Node ID d3ea0f2aacfc96ec2bc950885ce60fdf8a0abb9f # Parent f1b034447063cca6e1136ff00dc280b9eedafb69 logb: Provide missing declaration for Cygwin. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2010-03-07 Bruno Haible + + logb: Provide missing declaration for Cygwin. + * lib/math.in.h (logb): New declaration. + * m4/logb.m4: New file. + * modules/logb (Files): Add m4/logb.m4. + (Depends-on): Add math. + (configure.ac): Invoke gl_FUNC_LOGB, gl_MATH_MODULE_INDICATOR. + * m4/math_h.m4 (gl_MATH_H): Check also for logb declaration. + (gl_MATH_H_DEFAULTS): Initialize GNULIB_LOGB, HAVE_DECL_LOGB. + * modules/math (Makefile.am): Substitute GNULIB_LOGB, HAVE_DECL_LOGB. + * doc/posix-functions/logb.texi: Mention the Cygwin bug. + 2010-03-07 Bruno Haible Fix test-cond link error. diff --git a/doc/posix-functions/logb.texi b/doc/posix-functions/logb.texi --- a/doc/posix-functions/logb.texi +++ b/doc/posix-functions/logb.texi @@ -12,4 +12,7 @@ Portability problems not fixed by Gnulib: @itemize +@item +This function is missing a declaration on some platforms: +Cygwin 1.5.x. @end itemize diff --git a/lib/math.in.h b/lib/math.in.h --- a/lib/math.in.h +++ b/lib/math.in.h @@ -97,6 +97,7 @@ # define HUGE_VAL (1.0 / 0.0) #endif + /* Write x as x = mantissa * 2^exp where @@ -117,6 +118,19 @@ #endif +#if @GNULIB_LOGB@ +# if !@HAVE_DECL_LOGB@ +extern double logb (double x); +# endif +#elif defined GNULIB_POSIXCHECK +# undef logb +# if HAVE_RAW_DECL_LOGB +_GL_WARN_ON_USE (logb, "logb is unportable - " + "use gnulib module logb for portability"); +# endif +#endif + + #if @GNULIB_ACOSL@ # if !@HAVE_ACOSL@ || !@HAVE_DECL_ACOSL@ extern long double acosl (long double x); diff --git a/m4/logb.m4 b/m4/logb.m4 new file mode 100644 --- /dev/null +++ b/m4/logb.m4 @@ -0,0 +1,44 @@ +# logb.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_LOGB], +[ + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + dnl Test whether logb() is declared. + AC_CHECK_DECLS([logb], , , [#include ]) + if test "$ac_cv_have_decl_logb" != yes; then + HAVE_DECL_LOGB=0 + fi + dnl Test whether logb() can be used without libm. + LOGB_LIBM=? + AC_TRY_LINK([ + #ifndef __NO_MATH_INLINES + # define __NO_MATH_INLINES 1 /* for glibc */ + #endif + #include + extern double logb (double x); + double x;], + [x = logb(x);], + [LOGB_LIBM=]) + if test "$LOGB_LIBM" = "?"; then + save_LIBS="$LIBS" + LIBS="$LIBS -lm" + AC_TRY_LINK([ + #ifndef __NO_MATH_INLINES + # define __NO_MATH_INLINES 1 /* for glibc */ + #endif + #include + extern double logb (double x); + double x;], + [x = logb(x);], + [LOGB_LIBM="-lm"]) + LIBS="$save_LIBS" + fi + if test "$LOGB_LIBM" = "?"; then + LOGB_LIBM= + fi + AC_SUBST([LOGB_LIBM]) +]) diff --git a/m4/math_h.m4 b/m4/math_h.m4 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -1,4 +1,4 @@ -# math_h.m4 serial 17 +# math_h.m4 serial 18 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, @@ -40,7 +40,7 @@ dnl corresponding gnulib module is not in use. gl_WARN_ON_USE_PREPARE([[#include ]], [acosl asinl atanl ceilf ceill cosl expl floorf floorl frexpl - ldexpl logl round roundf roundl sinl sqrtl tanl trunc truncf truncl]) + ldexpl logb logl round roundf roundl sinl sqrtl tanl trunc truncf truncl]) ]) AC_DEFUN([gl_MATH_MODULE_INDICATOR], @@ -70,6 +70,7 @@ GNULIB_ISNAND=0; AC_SUBST([GNULIB_ISNAND]) GNULIB_ISNANL=0; AC_SUBST([GNULIB_ISNANL]) GNULIB_LDEXPL=0; AC_SUBST([GNULIB_LDEXPL]) + GNULIB_LOGB=0; AC_SUBST([GNULIB_LOGB]) GNULIB_LOGL=0; AC_SUBST([GNULIB_LOGL]) GNULIB_ROUND=0; AC_SUBST([GNULIB_ROUND]) GNULIB_ROUNDF=0; AC_SUBST([GNULIB_ROUNDF]) @@ -101,6 +102,7 @@ HAVE_DECL_EXPL=1; AC_SUBST([HAVE_DECL_EXPL]) HAVE_DECL_FREXPL=1; AC_SUBST([HAVE_DECL_FREXPL]) HAVE_DECL_LDEXPL=1; AC_SUBST([HAVE_DECL_LDEXPL]) + HAVE_DECL_LOGB=1; AC_SUBST([HAVE_DECL_LOGB]) HAVE_DECL_LOGL=1; AC_SUBST([HAVE_DECL_LOGL]) HAVE_DECL_SINL=1; AC_SUBST([HAVE_DECL_SINL]) HAVE_DECL_SQRTL=1; AC_SUBST([HAVE_DECL_SQRTL]) diff --git a/modules/logb b/modules/logb --- a/modules/logb +++ b/modules/logb @@ -2,12 +2,15 @@ logb() function: get exponent. Files: +m4/logb.m4 m4/mathfunc.m4 Depends-on: +math configure.ac: -gl_MATHFUNC([logb], [double], [(double)]) +gl_FUNC_LOGB +gl_MATH_MODULE_INDICATOR([logb]) Makefile.am: diff --git a/modules/math b/modules/math --- a/modules/math +++ b/modules/math @@ -42,6 +42,7 @@ -e 's|@''GNULIB_ISNAND''@|$(GNULIB_ISNAND)|g' \ -e 's|@''GNULIB_ISNANL''@|$(GNULIB_ISNANL)|g' \ -e 's|@''GNULIB_LDEXPL''@|$(GNULIB_LDEXPL)|g' \ + -e 's|@''GNULIB_LOGB''@|$(GNULIB_LOGB)|g' \ -e 's|@''GNULIB_LOGL''@|$(GNULIB_LOGL)|g' \ -e 's|@''GNULIB_ROUND''@|$(GNULIB_ROUND)|g' \ -e 's|@''GNULIB_ROUNDF''@|$(GNULIB_ROUNDF)|g' \ @@ -72,6 +73,7 @@ -e 's|@''HAVE_DECL_EXPL''@|$(HAVE_DECL_EXPL)|g' \ -e 's|@''HAVE_DECL_FREXPL''@|$(HAVE_DECL_FREXPL)|g' \ -e 's|@''HAVE_DECL_LDEXPL''@|$(HAVE_DECL_LDEXPL)|g' \ + -e 's|@''HAVE_DECL_LOGB''@|$(HAVE_DECL_LOGB)|g' \ -e 's|@''HAVE_DECL_LOGL''@|$(HAVE_DECL_LOGL)|g' \ -e 's|@''HAVE_DECL_SINL''@|$(HAVE_DECL_SINL)|g' \ -e 's|@''HAVE_DECL_SQRTL''@|$(HAVE_DECL_SQRTL)|g' \