[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
logb: undeclared on Cygwin
From: |
Bruno Haible |
Subject: |
logb: undeclared on Cygwin |
Date: |
Mon, 8 Mar 2010 00:05:26 +0100 |
User-agent: |
KMail/1.9.9 |
Hi,
On Cygwin, the <math.h> function 'logb' is not declared, but is defined and
works.
test-logb.c:24: error: `logb' undeclared here (not in a function)
test-logb.c: In function `main':
test-logb.c:38: warning: implicit declaration of function `logb'
make[4]: *** [test-logb.o] Error 1
This works around the missing the declaration.
2010-03-07 Bruno Haible <address@hidden>
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.
================================= m4/logb.m4 =================================
# 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 <math.h>])
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 <math.h>
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 <math.h>
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])
])
==============================================================================
--- doc/posix-functions/logb.texi.orig Sun Mar 7 23:59:59 2010
+++ doc/posix-functions/logb.texi Sun Mar 7 23:37:39 2010
@@ -12,4 +12,7 @@
Portability problems not fixed by Gnulib:
@itemize
address@hidden
+This function is missing a declaration on some platforms:
+Cygwin 1.5.x.
@end itemize
--- lib/math.in.h.orig Sun Mar 7 23:59:59 2010
+++ lib/math.in.h Sun Mar 7 23:48:39 2010
@@ -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 address@hidden@
+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 address@hidden@ || address@hidden@
extern long double acosl (long double x);
--- m4/math_h.m4.orig Sun Mar 7 23:59:59 2010
+++ m4/math_h.m4 Sun Mar 7 23:49:09 2010
@@ -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 <math.h>
]], [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])
--- modules/logb.orig Sun Mar 7 23:59:59 2010
+++ modules/logb Sun Mar 7 23:53:38 2010
@@ -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:
--- modules/math.orig Sun Mar 7 23:59:59 2010
+++ modules/math Sun Mar 7 23:49:39 2010
@@ -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' \
- logb: undeclared on Cygwin,
Bruno Haible <=