patches/mpfr/2.4.1/100-remainder-neg.patch
author "Yann E. MORIN" <yann.morin.1998@free.fr>
Wed Dec 26 13:30:51 2012 +0100 (2012-12-26)
changeset 3145 598880dab0f3
permissions -rw-r--r--
libc/glibc: both glibc and eglibc have pkgversion and bugurl

Well, all eglibc version we support do, and latest glibc versions
we support do.

Not all glibc versions do, but older versions simply ignore the
unrecognised ./configure flags.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
     1 diff -Naurd mpfr-2.4.1-a/PATCHES mpfr-2.4.1-b/PATCHES
     2 --- mpfr-2.4.1-a/PATCHES	2009-02-20 09:43:17.000000000 +0000
     3 +++ mpfr-2.4.1-b/PATCHES	2009-02-27 16:56:29.000000000 +0000
     4 @@ -0,0 +1 @@
     5 +remainder-neg
     6 diff -Naurd mpfr-2.4.1-a/VERSION mpfr-2.4.1-b/VERSION
     7 --- mpfr-2.4.1-a/VERSION	2009-02-25 16:16:08.000000000 +0000
     8 +++ mpfr-2.4.1-b/VERSION	2009-02-27 16:55:37.000000000 +0000
     9 @@ -1 +1 @@
    10 -2.4.1
    11 +2.4.1-p1
    12 diff -Naurd mpfr-2.4.1-a/mpfr.h mpfr-2.4.1-b/mpfr.h
    13 --- mpfr-2.4.1-a/mpfr.h	2009-02-25 16:16:08.000000000 +0000
    14 +++ mpfr-2.4.1-b/mpfr.h	2009-02-27 16:55:38.000000000 +0000
    15 @@ -27,7 +27,7 @@
    16  #define MPFR_VERSION_MAJOR 2
    17  #define MPFR_VERSION_MINOR 4
    18  #define MPFR_VERSION_PATCHLEVEL 1
    19 -#define MPFR_VERSION_STRING "2.4.1"
    20 +#define MPFR_VERSION_STRING "2.4.1-p1"
    21  
    22  /* Macros dealing with MPFR VERSION */
    23  #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
    24 diff -Naurd mpfr-2.4.1-a/rem1.c mpfr-2.4.1-b/rem1.c
    25 --- mpfr-2.4.1-a/rem1.c	2009-02-20 09:43:17.000000000 +0000
    26 +++ mpfr-2.4.1-b/rem1.c	2009-02-27 16:55:15.000000000 +0000
    27 @@ -170,7 +170,12 @@
    28      }
    29  
    30    if (mpz_cmp_ui (r, 0) == 0)
    31 -    inex = mpfr_set_ui (rem, 0, GMP_RNDN);
    32 +    {
    33 +      inex = mpfr_set_ui (rem, 0, GMP_RNDN);
    34 +      /* take into account sign of x */
    35 +      if (signx < 0)
    36 +        mpfr_neg (rem, rem, GMP_RNDN);
    37 +    }
    38    else
    39      {
    40        if (rnd_q == GMP_RNDN)
    41 @@ -190,6 +195,9 @@
    42                  *quo += 1;
    43              }
    44          }
    45 +      /* take into account sign of x */
    46 +      if (signx < 0)
    47 +        mpz_neg (r, r);
    48        inex = mpfr_set_z (rem, r, rnd);
    49        /* if ex > ey, rem should be multiplied by 2^ey, else by 2^ex */
    50        MPFR_EXP (rem) += (ex > ey) ? ey : ex;
    51 @@ -198,13 +206,6 @@
    52    if (quo)
    53      *quo *= sign;
    54  
    55 -  /* take into account sign of x */
    56 -  if (signx < 0)
    57 -    {
    58 -      mpfr_neg (rem, rem, GMP_RNDN);
    59 -      inex = -inex;
    60 -    }
    61 -
    62    mpz_clear (mx);
    63    mpz_clear (my);
    64    mpz_clear (r);
    65 diff -Naurd mpfr-2.4.1-a/tests/tremquo.c mpfr-2.4.1-b/tests/tremquo.c
    66 --- mpfr-2.4.1-a/tests/tremquo.c	2009-02-20 09:43:15.000000000 +0000
    67 +++ mpfr-2.4.1-b/tests/tremquo.c	2009-02-27 16:55:15.000000000 +0000
    68 @@ -25,6 +25,36 @@
    69  
    70  #include "mpfr-test.h"
    71  
    72 +static void
    73 +bug20090227 (void)
    74 +{
    75 +  mpfr_t x, y, r1, r2;
    76 +  int inex1, inex2;
    77 +
    78 +  mpfr_init2 (x, 118);
    79 +  mpfr_init2 (y, 181);
    80 +  mpfr_init2 (r1, 140);
    81 +  mpfr_init2 (r2, 140);
    82 +  mpfr_set_si (x, -1, GMP_RNDN);
    83 +  mpfr_set_str_binary (y, "1.100100100001111110110101010001000100001011010001100001000110100110001001100011001100010100010111000000011011100000111001101000100101001000000100100111000001000100010100110011111010");
    84 +  inex1 = mpfr_remainder (r1, x, y, GMP_RNDU);
    85 +  /* since the quotient is -1, r1 is the rounding of x+y */
    86 +  inex2 = mpfr_add (r2, x, y, GMP_RNDU);
    87 +  if (mpfr_cmp (r1, r2))
    88 +    {
    89 +      printf ("Error in mpfr_remainder (bug20090227)\n");
    90 +      printf ("Expected ");
    91 +      mpfr_dump (r2);
    92 +      printf ("Got      ");
    93 +      mpfr_dump (r1);
    94 +      exit (1);
    95 +    }
    96 +  mpfr_clear (x);
    97 +  mpfr_clear (y);
    98 +  mpfr_clear (r1);
    99 +  mpfr_clear (r2);
   100 +}
   101 +
   102  int
   103  main (int argc, char *argv[])
   104  {
   105 @@ -50,6 +80,8 @@
   106  
   107    tests_start_mpfr ();
   108  
   109 +  bug20090227 ();
   110 +
   111    mpfr_init (x);
   112    mpfr_init (y);
   113    mpfr_init (r);
   114 diff -Naurd mpfr-2.4.1-a/version.c mpfr-2.4.1-b/version.c
   115 --- mpfr-2.4.1-a/version.c	2009-02-25 16:16:08.000000000 +0000
   116 +++ mpfr-2.4.1-b/version.c	2009-02-27 16:55:38.000000000 +0000
   117 @@ -25,5 +25,5 @@
   118  const char *
   119  mpfr_get_version (void)
   120  {
   121 -  return "2.4.1";
   122 +  return "2.4.1-p1";
   123  }