bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new common math function modules


From: Bruno Haible
Subject: Re: new common math function modules
Date: Wed, 20 Jan 2010 12:52:43 +0100
User-agent: KMail/1.9.9

Paolo Bonzini wrote:
> This causes -lm -lm -lm -lm -lm to appear in the link
> lines, which is not aesthetic

We can certainly work against avoiding duplicate -lm. I'm applying the patch
below.

> and causes quite some bloat in configure scripts size and execution time.
> 
> Is there a function that is never provided in libc unless all of them
> are provided in libc?

For the 36 functions listed, the 'various-symlists' database shows 6
different libc / libm distributions according to platforms.

*BSD = FreeBSD, OpenBSD, NetBSD
Solaris = Solaris 2.4..9
Other = glibc, Cygwin, HP-UX, OSF/1, Solaris 10, Interix

             MacOS X    AIX   *BSD   IRIX   Solaris   Other
acos                     *      *      *       *        *
asin                     *      *      *       *        *
atan                     *      *      *       *        *
atan2                    *      *      *       *        *
cbrt                     *      *      *       *        *
copysign                 *      *      *       *        *
cos                      *      *      *       *        *
cosh                     *      *      *       *        *
erf                      *      *      *       *        *
erfc                     *      *      *       *        *
exp                      *      *      *       *        *
fabs                     *                     *        *
fmod                     *      *      *       *        *
hypot                    *      *      *       *        *
j0                       *      *      *       *        *
j1                       *      *      *       *        *
jn                       *      *      *       *        *
ldexp                                                   *
lgamma                   *      *      *       *        *
log                      *      *      *       *        *
log10                    *      *      *       *        *
log1p                    *      *      *       *        *
logb                     *      *              *        *
modf                                                    *
nextafter                *      *              *        *
pow                      *      *      *       *        *
remainder                *      *      *       *        *
rint                            *      *       *        *
sin                      *      *      *       *        *
sinh                     *      *      *       *        *
sqrt                     *      *      *       *        *
tan                      *      *      *       *        *
tanh                     *      *      *       *        *
y0                       *      *      *       *        *
y1                       *      *      *       *        *
yn                       *      *      *       *        *

Hmm, it seems indeed that only a few among these 36 functions are special.
For every new platform that appears, more differences may occur. But
nevertheless, most of the simple libm functions are always in the same
library.

I'll think I'll merge the test for EXP_LIBM, LOG_LIBM etc. into a single
one - to save configure script execution time, as you say -. But the
different variables should stay, because when some platform moves
'exp' from libm to libc, not all Makefile.ams should have to be changed.

Bruno


2010-01-20  Bruno Haible  <address@hidden>

        Avoid duplicate -lm.
        * m4/isnan.m4 (gl_ISNAN): Avoid duplicate -lm in $ISNAN_LIBM.
        * m4/round.m4 (gl_FUNC_ROUND): Avoid duplicate -lm in $ROUND_LIBM.
        * m4/roundf.m4 (gl_FUNC_ROUNDF): Avoid duplicate -lm in $ROUNDF_LIBM.
        * m4/roundl.m4 (gl_FUNC_ROUNDL): Avoid duplicate -lm in $ROUNDL_LIBM.
        * m4/acosl.m4 (gl_FUNC_ACOSL): Avoid duplicate -lm in $ACOSL_LIBM.
        * m4/cosl.m4 (gl_FUNC_COSL): Avoid duplicate -lm in $COSL_LIBM.
        * m4/logl.m4 (gl_FUNC_LOGL): Avoid duplicate -lm in $LOGL_LIBM.
        * m4/sinl.m4 (gl_FUNC_SINL): Avoid duplicate -lm in $SINL_LIBM.
        * m4/sqrtl.m4 (gl_FUNC_SQRTL): Avoid duplicate -lm in $SQRTL_LIBM.
        * m4/tanl.m4 (gl_FUNC_TANL): Avoid duplicate -lm in $TANL_LIBM.
        * m4/asinl.m4 (gl_FUNC_ASINL): Same change, for consistency.
        * m4/atanl.m4 (gl_FUNC_ATANL): Likewise.
        Reported by Paolo Bonzini.

--- m4/acosl.m4.orig    Wed Jan 20 11:48:41 2010
+++ m4/acosl.m4 Wed Jan 20 11:23:19 2010
@@ -1,4 +1,4 @@
-# acosl.m4 serial 1
+# acosl.m4 serial 2
 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,
@@ -54,7 +54,16 @@
     AC_LIBOBJ([acosl])
     AC_REQUIRE([gl_FUNC_ASINL])
     AC_REQUIRE([gl_FUNC_SQRTL])
-    ACOSL_LIBM="$ASINL_LIBM $SQRTL_LIBM"
+    dnl Append $ASINL_LIBM to ACOSL_LIBM, avoiding gratuitous duplicates.
+    case " $ACOSL_LIBM " in
+      *" $ASINL_LIBM "*) ;;
+      *) ACOSL_LIBM="$ACOSL_LIBM $ASINL_LIBM" ;;
+    esac
+    dnl Append $SQRTL_LIBM to ACOSL_LIBM, avoiding gratuitous duplicates.
+    case " $ACOSL_LIBM " in
+      *" $SQRTL_LIBM "*) ;;
+      *) ACOSL_LIBM="$ACOSL_LIBM $SQRTL_LIBM" ;;
+    esac
   fi
   AC_SUBST([ACOSL_LIBM])
 ])
--- m4/asinl.m4.orig    Wed Jan 20 11:48:41 2010
+++ m4/asinl.m4 Wed Jan 20 11:17:54 2010
@@ -1,4 +1,4 @@
-# asinl.m4 serial 1
+# asinl.m4 serial 2
 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,
@@ -53,7 +53,11 @@
     HAVE_ASINL=0
     AC_LIBOBJ([asinl])
     AC_REQUIRE([gl_FUNC_SQRTL])
-    ASINL_LIBM="$SQRTL_LIBM"
+    dnl Append $SQRTL_LIBM to ASINL_LIBM, avoiding gratuitous duplicates.
+    case " $ASINL_LIBM " in
+      *" $SQRTL_LIBM "*) ;;
+      *) ASINL_LIBM="$ASINL_LIBM $SQRTL_LIBM" ;;
+    esac
   fi
   AC_SUBST([ASINL_LIBM])
 ])
--- m4/atanl.m4.orig    Wed Jan 20 11:48:41 2010
+++ m4/atanl.m4 Wed Jan 20 11:22:17 2010
@@ -1,4 +1,4 @@
-# atanl.m4 serial 1
+# atanl.m4 serial 2
 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,
@@ -53,7 +53,11 @@
     HAVE_ATANL=0
     AC_LIBOBJ([atanl])
     AC_REQUIRE([gl_FUNC_ISNANL])
-    ATANL_LIBM="$ISNANL_LIBM"
+    dnl Append $ISNANL_LIBM to ATANL_LIBM, avoiding gratuitous duplicates.
+    case " $ATANL_LIBM " in
+      *" $ISNANL_LIBM "*) ;;
+      *) ATANL_LIBM="$ATANL_LIBM $ISNANL_LIBM" ;;
+    esac
   fi
   AC_SUBST([ATANL_LIBM])
 ])
--- m4/cosl.m4.orig     Wed Jan 20 11:48:41 2010
+++ m4/cosl.m4  Wed Jan 20 11:25:49 2010
@@ -1,4 +1,4 @@
-# cosl.m4 serial 1
+# cosl.m4 serial 2
 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,
@@ -57,7 +57,21 @@
     AC_REQUIRE([gl_FUNC_ISNANL])
     AC_REQUIRE([gl_FUNC_FLOOR])
     AC_REQUIRE([gl_FUNC_FLOORL])
-    COSL_LIBM="$ISNANL_LIBM $FLOOR_LIBM $FLOORL_LIBM"
+    dnl Append $ISNANL_LIBM to COSL_LIBM, avoiding gratuitous duplicates.
+    case " $COSL_LIBM " in
+      *" $ISNANL_LIBM "*) ;;
+      *) COSL_LIBM="$COSL_LIBM $ISNANL_LIBM" ;;
+    esac
+    dnl Append $FLOOR_LIBM to COSL_LIBM, avoiding gratuitous duplicates.
+    case " $COSL_LIBM " in
+      *" $FLOOR_LIBM "*) ;;
+      *) COSL_LIBM="$COSL_LIBM $FLOOR_LIBM" ;;
+    esac
+    dnl Append $FLOORL_LIBM to COSL_LIBM, avoiding gratuitous duplicates.
+    case " $COSL_LIBM " in
+      *" $FLOORL_LIBM "*) ;;
+      *) COSL_LIBM="$COSL_LIBM $FLOORL_LIBM" ;;
+    esac
   fi
   AC_SUBST([COSL_LIBM])
 ])
--- m4/isnan.m4.orig    Wed Jan 20 11:48:41 2010
+++ m4/isnan.m4 Wed Jan 20 11:36:19 2010
@@ -1,4 +1,4 @@
-# isnan.m4 serial 2
+# isnan.m4 serial 3
 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,
@@ -18,7 +18,22 @@
      && test $gl_func_isnand = yes \
      && test $gl_func_isnanl = yes; then
     AC_MSG_RESULT([yes])
-    ISNAN_LIBM="$ISNANF_LIBM $ISNAND_LIBM $ISNANL_LIBM"
+    ISNAN_LIBM=
+    dnl Append $ISNANF_LIBM to ISNAN_LIBM, avoiding gratuitous duplicates.
+    case " $ISNAN_LIBM " in
+      *" $ISNANF_LIBM "*) ;;
+      *) ISNAN_LIBM="$ISNAN_LIBM $ISNANF_LIBM" ;;
+    esac
+    dnl Append $ISNAND_LIBM to ISNAN_LIBM, avoiding gratuitous duplicates.
+    case " $ISNAN_LIBM " in
+      *" $ISNAND_LIBM "*) ;;
+      *) ISNAN_LIBM="$ISNAN_LIBM $ISNAND_LIBM" ;;
+    esac
+    dnl Append $ISNANL_LIBM to ISNAN_LIBM, avoiding gratuitous duplicates.
+    case " $ISNAN_LIBM " in
+      *" $ISNANL_LIBM "*) ;;
+      *) ISNAN_LIBM="$ISNAN_LIBM $ISNANL_LIBM" ;;
+    esac
   else
     AC_MSG_RESULT([no])
     REPLACE_ISNAN=1
--- m4/logl.m4.orig     Wed Jan 20 11:48:41 2010
+++ m4/logl.m4  Wed Jan 20 11:31:17 2010
@@ -1,4 +1,4 @@
-# logl.m4 serial 1
+# logl.m4 serial 2
 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,
@@ -55,7 +55,21 @@
     AC_REQUIRE([gl_FUNC_FREXPL])
     AC_REQUIRE([gl_FUNC_ISNANL])
     AC_REQUIRE([gl_FUNC_FLOORL])
-    LOGL_LIBM="$FREXPL_LIBM $ISNANL_LIBM $FLOORL_LIBM"
+    dnl Append $FREXPL_LIBM to LOGL_LIBM, avoiding gratuitous duplicates.
+    case " $LOGL_LIBM " in
+      *" $FREXPL_LIBM "*) ;;
+      *) LOGL_LIBM="$LOGL_LIBM $FREXPL_LIBM" ;;
+    esac
+    dnl Append $ISNANL_LIBM to LOGL_LIBM, avoiding gratuitous duplicates.
+    case " $LOGL_LIBM " in
+      *" $ISNANL_LIBM "*) ;;
+      *) LOGL_LIBM="$LOGL_LIBM $ISNANL_LIBM" ;;
+    esac
+    dnl Append $FLOORL_LIBM to LOGL_LIBM, avoiding gratuitous duplicates.
+    case " $LOGL_LIBM " in
+      *" $FLOORL_LIBM "*) ;;
+      *) LOGL_LIBM="$LOGL_LIBM $FLOORL_LIBM" ;;
+    esac
   fi
   AC_SUBST([LOGL_LIBM])
 ])
--- m4/round.m4.orig    Wed Jan 20 11:48:41 2010
+++ m4/round.m4 Wed Jan 20 11:32:29 2010
@@ -1,5 +1,5 @@
-# round.m4 serial 6
-dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
+# round.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.
@@ -56,7 +56,17 @@
     AC_LIBOBJ([round])
     gl_FUNC_FLOOR_LIBS
     gl_FUNC_CEIL_LIBS
-    ROUND_LIBM="$FLOOR_LIBM $CEIL_LIBM"
+    ROUND_LIBM=
+    dnl Append $FLOOR_LIBM to ROUND_LIBM, avoiding gratuitous duplicates.
+    case " $ROUND_LIBM " in
+      *" $FLOOR_LIBM "*) ;;
+      *) ROUND_LIBM="$ROUND_LIBM $FLOOR_LIBM" ;;
+    esac
+    dnl Append $CEIL_LIBM to ROUND_LIBM, avoiding gratuitous duplicates.
+    case " $ROUND_LIBM " in
+      *" $CEIL_LIBM "*) ;;
+      *) ROUND_LIBM="$ROUND_LIBM $CEIL_LIBM" ;;
+    esac
   fi
   AC_SUBST([ROUND_LIBM])
 ])
--- m4/roundf.m4.orig   Wed Jan 20 11:48:41 2010
+++ m4/roundf.m4        Wed Jan 20 11:33:49 2010
@@ -1,4 +1,4 @@
-# roundf.m4 serial 7
+# roundf.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,
@@ -59,7 +59,17 @@
       if test "$FLOORF_LIBM" != '?' && test "$CEILF_LIBM" != '?'; then
         AC_DEFINE([HAVE_FLOORF_AND_CEILF], [1],
           [Define if the both the floorf() and ceilf() functions exist.])
-        ROUNDF_LIBM="$FLOORF_LIBM $CEILF_LIBM"
+        ROUNDF_LIBM=
+        dnl Append $FLOORF_LIBM to ROUNDF_LIBM, avoiding gratuitous duplicates.
+        case " $ROUNDF_LIBM " in
+          *" $FLOORF_LIBM "*) ;;
+          *) ROUNDF_LIBM="$ROUNDF_LIBM $FLOORF_LIBM" ;;
+        esac
+        dnl Append $CEILF_LIBM to ROUNDF_LIBM, avoiding gratuitous duplicates.
+        case " $ROUNDF_LIBM " in
+          *" $CEILF_LIBM "*) ;;
+          *) ROUNDF_LIBM="$ROUNDF_LIBM $CEILF_LIBM" ;;
+        esac
       else
         ROUNDF_LIBM=
       fi
--- m4/roundl.m4.orig   Wed Jan 20 11:48:41 2010
+++ m4/roundl.m4        Wed Jan 20 11:34:59 2010
@@ -1,5 +1,5 @@
-# roundl.m4 serial 5
-dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
+# roundl.m4 serial 6
+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.
@@ -24,7 +24,17 @@
       if test "$FLOORL_LIBM" != '?' && test "$CEILL_LIBM" != '?'; then
         AC_DEFINE([HAVE_FLOORL_AND_CEILL], [1],
           [Define if the both the floorl() and ceill() functions exist.])
-        ROUNDL_LIBM="$FLOORL_LIBM $CEILL_LIBM"
+        ROUNDL_LIBM=
+        dnl Append $FLOORL_LIBM to ROUNDL_LIBM, avoiding gratuitous duplicates.
+        case " $ROUNDL_LIBM " in
+          *" $FLOORL_LIBM "*) ;;
+          *) ROUNDL_LIBM="$ROUNDL_LIBM $FLOORL_LIBM" ;;
+        esac
+        dnl Append $CEILL_LIBM to ROUNDL_LIBM, avoiding gratuitous duplicates.
+        case " $ROUNDL_LIBM " in
+          *" $CEILL_LIBM "*) ;;
+          *) ROUNDL_LIBM="$ROUNDL_LIBM $CEILL_LIBM" ;;
+        esac
       else
         ROUNDL_LIBM=
       fi
--- m4/sinl.m4.orig     Wed Jan 20 11:48:41 2010
+++ m4/sinl.m4  Wed Jan 20 11:26:59 2010
@@ -1,4 +1,4 @@
-# sinl.m4 serial 1
+# sinl.m4 serial 2
 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,
@@ -57,7 +57,21 @@
     AC_REQUIRE([gl_FUNC_ISNANL])
     AC_REQUIRE([gl_FUNC_FLOOR])
     AC_REQUIRE([gl_FUNC_FLOORL])
-    SINL_LIBM="$ISNANL_LIBM $FLOOR_LIBM $FLOORL_LIBM"
+    dnl Append $ISNANL_LIBM to SINL_LIBM, avoiding gratuitous duplicates.
+    case " $SINL_LIBM " in
+      *" $ISNANL_LIBM "*) ;;
+      *) SINL_LIBM="$SINL_LIBM $ISNANL_LIBM" ;;
+    esac
+    dnl Append $FLOOR_LIBM to SINL_LIBM, avoiding gratuitous duplicates.
+    case " $SINL_LIBM " in
+      *" $FLOOR_LIBM "*) ;;
+      *) SINL_LIBM="$SINL_LIBM $FLOOR_LIBM" ;;
+    esac
+    dnl Append $FLOORL_LIBM to SINL_LIBM, avoiding gratuitous duplicates.
+    case " $SINL_LIBM " in
+      *" $FLOORL_LIBM "*) ;;
+      *) SINL_LIBM="$SINL_LIBM $FLOORL_LIBM" ;;
+    esac
   fi
   AC_SUBST([SINL_LIBM])
 ])
--- m4/sqrtl.m4.orig    Wed Jan 20 11:48:41 2010
+++ m4/sqrtl.m4 Wed Jan 20 11:30:08 2010
@@ -1,4 +1,4 @@
-# sqrtl.m4 serial 1
+# sqrtl.m4 serial 2
 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,
@@ -56,7 +56,26 @@
     AC_REQUIRE([gl_FUNC_FREXPL])
     AC_REQUIRE([gl_FUNC_LDEXPL])
     AC_REQUIRE([gl_FUNC_SQRT])
-    SQRTL_LIBM="$ISNANL_LIBM $FREXPL_LIBM $LDEXPL_LIBM $SQRT_LIBM"
+    dnl Append $ISNANL_LIBM to SQRTL_LIBM, avoiding gratuitous duplicates.
+    case " $SQRTL_LIBM " in
+      *" $ISNANL_LIBM "*) ;;
+      *) SQRTL_LIBM="$SQRTL_LIBM $ISNANL_LIBM" ;;
+    esac
+    dnl Append $FREXPL_LIBM to SQRTL_LIBM, avoiding gratuitous duplicates.
+    case " $SQRTL_LIBM " in
+      *" $FREXPL_LIBM "*) ;;
+      *) SQRTL_LIBM="$SQRTL_LIBM $FREXPL_LIBM" ;;
+    esac
+    dnl Append $LDEXPL_LIBM to SQRTL_LIBM, avoiding gratuitous duplicates.
+    case " $SQRTL_LIBM " in
+      *" $LDEXPL_LIBM "*) ;;
+      *) SQRTL_LIBM="$SQRTL_LIBM $LDEXPL_LIBM" ;;
+    esac
+    dnl Append $SQRT_LIBM to SQRTL_LIBM, avoiding gratuitous duplicates.
+    case " $SQRTL_LIBM " in
+      *" $SQRT_LIBM "*) ;;
+      *) SQRTL_LIBM="$SQRTL_LIBM $SQRT_LIBM" ;;
+    esac
   fi
   AC_SUBST([SQRTL_LIBM])
 ])
--- m4/tanl.m4.orig     Wed Jan 20 11:48:41 2010
+++ m4/tanl.m4  Wed Jan 20 11:28:16 2010
@@ -1,4 +1,4 @@
-# tanl.m4 serial 1
+# tanl.m4 serial 2
 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,
@@ -56,7 +56,21 @@
     AC_REQUIRE([gl_FUNC_ISNANL])
     AC_REQUIRE([gl_FUNC_FLOOR])
     AC_REQUIRE([gl_FUNC_FLOORL])
-    TANL_LIBM="$ISNANL_LIBM $FLOOR_LIBM $FLOORL_LIBM"
+    dnl Append $ISNANL_LIBM to TANL_LIBM, avoiding gratuitous duplicates.
+    case " $TANL_LIBM " in
+      *" $ISNANL_LIBM "*) ;;
+      *) TANL_LIBM="$TANL_LIBM $ISNANL_LIBM" ;;
+    esac
+    dnl Append $FLOOR_LIBM to TANL_LIBM, avoiding gratuitous duplicates.
+    case " $TANL_LIBM " in
+      *" $FLOOR_LIBM "*) ;;
+      *) TANL_LIBM="$TANL_LIBM $FLOOR_LIBM" ;;
+    esac
+    dnl Append $FLOORL_LIBM to TANL_LIBM, avoiding gratuitous duplicates.
+    case " $TANL_LIBM " in
+      *" $FLOORL_LIBM "*) ;;
+      *) TANL_LIBM="$TANL_LIBM $FLOORL_LIBM" ;;
+    esac
   fi
   AC_SUBST([TANL_LIBM])
 ])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]