patches/gmp/4.2.2/100-mpf_set_str.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Sep 12 23:51:25 2010 +0200 (2010-09-12)
changeset 2123 ff2181adbd28
parent 466 7f9bbf94b0bb
permissions -rw-r--r--
cc/gcc: disable complibs if not selected

Force gcc to not link with some companion libraries when
there are not needed (because selected-out).

There is no option to tell gcc *not* to build the Graphite and/or
LTO stuff. They *will* be built if gcc finds the suitable companion
libraries. If we do not provide them, but the host has them, then
gcc *will* find them, and link with them.

Consider the following:
- host has suitable PPL and CLooG (eg. Debian Squeeze)
- user wants to build gcc>=4.4
- user de-selects GRAPHITE
- gcc will find the hosts PPL and CLooG, and will use them
- the user moves the toolchain to an older host that does
not have them (eg. Debian Lenny)
- the toolchain fails, when it was properly setup not to

So, explicitly tell gcc *not* to use unneeded companion libs.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
yann@466
     1
Original patch from http://gmplib.org/patches/mpf_set_str.c.diff
yann@466
     2
Re-diffed to match crosstool-NG conventions.
yann@466
     3
yann@466
     4
diff -dur gmp-4.2.2.orig/mpf/set_str.c gmp-4.2.2/mpf/set_str.c
yann@466
     5
--- gmp-4.2.2.orig/mpf/set_str.c	2007-08-30 20:31:40.000000000 +0200
yann@466
     6
+++ gmp-4.2.2/mpf/set_str.c	2008-01-28 23:05:29.000000000 +0100
yann@466
     7
@@ -271,8 +271,29 @@
yann@466
     8
       }
yann@466
     9
 
yann@466
    10
     if (expptr != 0)
yann@466
    11
-      /* FIXME: Should do some error checking here.  */
yann@466
    12
-      exp_in_base = strtol (expptr, (char **) 0, exp_base);
yann@466
    13
+      {
yann@466
    14
+	/* Scan and convert the exponent, in base exp_base.  */
yann@466
    15
+	long dig, neg = -(long) ('-' == expptr[0]);
yann@466
    16
+	expptr -= neg;			/* conditional increment */
yann@466
    17
+	c = (unsigned char) *expptr++;
yann@466
    18
+	dig = digit_value[c];
yann@466
    19
+	if (dig >= exp_base)
yann@466
    20
+	  {
yann@466
    21
+	    TMP_FREE;
yann@466
    22
+	    return -1;
yann@466
    23
+	  }
yann@466
    24
+	exp_in_base = dig;
yann@466
    25
+	c = (unsigned char) *expptr++;
yann@466
    26
+	dig = digit_value[c];
yann@466
    27
+	while (dig < exp_base)
yann@466
    28
+	  {
yann@466
    29
+	    exp_in_base = exp_in_base * exp_base;
yann@466
    30
+	    exp_in_base += dig;
yann@466
    31
+	    c = (unsigned char) *expptr++;
yann@466
    32
+	    dig = digit_value[c];
yann@466
    33
+	  }
yann@466
    34
+	exp_in_base = (exp_in_base ^ neg) - neg; /* conditional negation */
yann@466
    35
+      }
yann@466
    36
     else
yann@466
    37
       exp_in_base = 0;
yann@466
    38
     if (dotpos != 0)