patches/mpfr/2.4.0/100-printf-hh-ll.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Jul 17 17:54:21 2011 +0200 (2011-07-17)
changeset 2888 dd71df95903a
permissions -rw-r--r--
cc/gcc: pass the companion libs prefix to cc_core

In case of canadian-cross, the companion libraries are not the same for
the core cc (they run on 'build') as they are for the final cc (they run
on 'host').

Prepare for this differentiation (coming later), while retaining the
current behavior (to use the same compblibs).

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
     1 diff -Naurd mpfr-2.4.0-a/PATCHES mpfr-2.4.0-b/PATCHES
     2 --- mpfr-2.4.0-a/PATCHES	2009-01-26 12:52:01.000000000 +0000
     3 +++ mpfr-2.4.0-b/PATCHES	2009-02-20 17:27:44.000000000 +0000
     4 @@ -0,0 +1 @@
     5 +printf-hh-ll
     6 diff -Naurd mpfr-2.4.0-a/VERSION mpfr-2.4.0-b/VERSION
     7 --- mpfr-2.4.0-a/VERSION	2009-01-26 12:52:01.000000000 +0000
     8 +++ mpfr-2.4.0-b/VERSION	2009-02-20 17:27:44.000000000 +0000
     9 @@ -1 +1 @@
    10 -2.4.0
    11 +2.4.0-p1
    12 diff -Naurd mpfr-2.4.0-a/acinclude.m4 mpfr-2.4.0-b/acinclude.m4
    13 --- mpfr-2.4.0-a/acinclude.m4	2009-01-26 12:52:01.000000000 +0000
    14 +++ mpfr-2.4.0-b/acinclude.m4	2009-01-26 12:52:01.000000000 +0000
    15 @@ -722,6 +722,16 @@
    16           [AC_DEFINE([NPRINTF_J], 1, [gmp_printf cannot read intmax_t])])
    17  fi
    18  
    19 +MPFR_FUNC_PRINTF_SPEC([%hhd], [char], [
    20 +#include <gmp.h>
    21 +         ], [gmp_],,
    22 +         [AC_DEFINE([NPRINTF_HH], 1, [gmp_printf cannot use 'hh' length modifier])])
    23 +
    24 +MPFR_FUNC_PRINTF_SPEC([%lld], [long long int], [
    25 +#include <gmp.h>
    26 +         ], [gmp_],,
    27 +         [AC_DEFINE([NPRINTF_LL], 1, [gmp_printf cannot read long long int])])
    28 +
    29  MPFR_FUNC_PRINTF_SPEC([%.0Lf], [long double], [
    30  #include <gmp.h>
    31           ], [gmp_],,
    32 diff -Naurd mpfr-2.4.0-a/configure mpfr-2.4.0-b/configure
    33 --- mpfr-2.4.0-a/configure	2009-01-26 12:54:36.000000000 +0000
    34 +++ mpfr-2.4.0-b/configure	2009-02-20 17:38:36.000000000 +0000
    35 @@ -24874,6 +24874,170 @@
    36  fi
    37  
    38  
    39 +{ $as_echo "$as_me:$LINENO: checking if gmp_printf supports \"%hhd\"" >&5
    40 +$as_echo_n "checking if gmp_printf supports \"%hhd\"... " >&6; }
    41 +if test "$cross_compiling" = yes; then
    42 +  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
    43 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
    44 +{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
    45 +See \`config.log' for more details." >&5
    46 +$as_echo "$as_me: error: cannot run test program while cross compiling
    47 +See \`config.log' for more details." >&2;}
    48 +   { (exit 1); exit 1; }; }; }
    49 +else
    50 +  cat >conftest.$ac_ext <<_ACEOF
    51 +/* confdefs.h.  */
    52 +_ACEOF
    53 +cat confdefs.h >>conftest.$ac_ext
    54 +cat >>conftest.$ac_ext <<_ACEOF
    55 +/* end confdefs.h.  */
    56 +
    57 +#include <stdio.h>
    58 +
    59 +#include <gmp.h>
    60 +
    61 +
    62 +int
    63 +main ()
    64 +{
    65 +
    66 +  char s[256];
    67 +  char a = 0;
    68 +  return (gmp_sprintf (s, "%hhd", a) != 1) ? 1 : 0;
    69 +
    70 +  ;
    71 +  return 0;
    72 +}
    73 +_ACEOF
    74 +rm -f conftest$ac_exeext
    75 +if { (ac_try="$ac_link"
    76 +case "(($ac_try" in
    77 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
    78 +  *) ac_try_echo=$ac_try;;
    79 +esac
    80 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
    81 +$as_echo "$ac_try_echo") >&5
    82 +  (eval "$ac_link") 2>&5
    83 +  ac_status=$?
    84 +  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
    85 +  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
    86 +  { (case "(($ac_try" in
    87 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
    88 +  *) ac_try_echo=$ac_try;;
    89 +esac
    90 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
    91 +$as_echo "$ac_try_echo") >&5
    92 +  (eval "$ac_try") 2>&5
    93 +  ac_status=$?
    94 +  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
    95 +  (exit $ac_status); }; }; then
    96 +  { $as_echo "$as_me:$LINENO: result: yes" >&5
    97 +$as_echo "yes" >&6; }
    98 +
    99 +else
   100 +  $as_echo "$as_me: program exited with status $ac_status" >&5
   101 +$as_echo "$as_me: failed program was:" >&5
   102 +sed 's/^/| /' conftest.$ac_ext >&5
   103 +
   104 +( exit $ac_status )
   105 +{ $as_echo "$as_me:$LINENO: result: no" >&5
   106 +$as_echo "no" >&6; }
   107 +
   108 +cat >>confdefs.h <<\_ACEOF
   109 +#define NPRINTF_HH 1
   110 +_ACEOF
   111 +
   112 +fi
   113 +rm -rf conftest.dSYM
   114 +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
   115 +fi
   116 +
   117 +
   118 +
   119 +
   120 +
   121 +{ $as_echo "$as_me:$LINENO: checking if gmp_printf supports \"%lld\"" >&5
   122 +$as_echo_n "checking if gmp_printf supports \"%lld\"... " >&6; }
   123 +if test "$cross_compiling" = yes; then
   124 +  { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
   125 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
   126 +{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
   127 +See \`config.log' for more details." >&5
   128 +$as_echo "$as_me: error: cannot run test program while cross compiling
   129 +See \`config.log' for more details." >&2;}
   130 +   { (exit 1); exit 1; }; }; }
   131 +else
   132 +  cat >conftest.$ac_ext <<_ACEOF
   133 +/* confdefs.h.  */
   134 +_ACEOF
   135 +cat confdefs.h >>conftest.$ac_ext
   136 +cat >>conftest.$ac_ext <<_ACEOF
   137 +/* end confdefs.h.  */
   138 +
   139 +#include <stdio.h>
   140 +
   141 +#include <gmp.h>
   142 +
   143 +
   144 +int
   145 +main ()
   146 +{
   147 +
   148 +  char s[256];
   149 +  long long int a = 0;
   150 +  return (gmp_sprintf (s, "%lld", a) != 1) ? 1 : 0;
   151 +
   152 +  ;
   153 +  return 0;
   154 +}
   155 +_ACEOF
   156 +rm -f conftest$ac_exeext
   157 +if { (ac_try="$ac_link"
   158 +case "(($ac_try" in
   159 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   160 +  *) ac_try_echo=$ac_try;;
   161 +esac
   162 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
   163 +$as_echo "$ac_try_echo") >&5
   164 +  (eval "$ac_link") 2>&5
   165 +  ac_status=$?
   166 +  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   167 +  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
   168 +  { (case "(($ac_try" in
   169 +  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   170 +  *) ac_try_echo=$ac_try;;
   171 +esac
   172 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
   173 +$as_echo "$ac_try_echo") >&5
   174 +  (eval "$ac_try") 2>&5
   175 +  ac_status=$?
   176 +  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
   177 +  (exit $ac_status); }; }; then
   178 +  { $as_echo "$as_me:$LINENO: result: yes" >&5
   179 +$as_echo "yes" >&6; }
   180 +
   181 +else
   182 +  $as_echo "$as_me: program exited with status $ac_status" >&5
   183 +$as_echo "$as_me: failed program was:" >&5
   184 +sed 's/^/| /' conftest.$ac_ext >&5
   185 +
   186 +( exit $ac_status )
   187 +{ $as_echo "$as_me:$LINENO: result: no" >&5
   188 +$as_echo "no" >&6; }
   189 +
   190 +cat >>confdefs.h <<\_ACEOF
   191 +#define NPRINTF_LL 1
   192 +_ACEOF
   193 +
   194 +fi
   195 +rm -rf conftest.dSYM
   196 +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
   197 +fi
   198 +
   199 +
   200 +
   201 +
   202 +
   203  { $as_echo "$as_me:$LINENO: checking if gmp_printf supports \"%.0Lf\"" >&5
   204  $as_echo_n "checking if gmp_printf supports \"%.0Lf\"... " >&6; }
   205  if test "$cross_compiling" = yes; then
   206 diff -Naurd mpfr-2.4.0-a/mpfr.h mpfr-2.4.0-b/mpfr.h
   207 --- mpfr-2.4.0-a/mpfr.h	2009-01-26 12:52:01.000000000 +0000
   208 +++ mpfr-2.4.0-b/mpfr.h	2009-02-20 17:27:44.000000000 +0000
   209 @@ -27,7 +27,7 @@
   210  #define MPFR_VERSION_MAJOR 2
   211  #define MPFR_VERSION_MINOR 4
   212  #define MPFR_VERSION_PATCHLEVEL 0
   213 -#define MPFR_VERSION_STRING "2.4.0"
   214 +#define MPFR_VERSION_STRING "2.4.0-p1"
   215  
   216  /* Macros dealing with MPFR VERSION */
   217  #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   218 diff -Naurd mpfr-2.4.0-a/tests/tfprintf.c mpfr-2.4.0-b/tests/tfprintf.c
   219 --- mpfr-2.4.0-a/tests/tfprintf.c	2009-01-26 12:52:00.000000000 +0000
   220 +++ mpfr-2.4.0-b/tests/tfprintf.c	2009-02-20 16:31:02.000000000 +0000
   221 @@ -146,6 +146,7 @@
   222    short sh = -1;
   223    unsigned short ush = 1;
   224    int i = -1;
   225 +  int j = 1;
   226    unsigned int ui = 1;
   227    long lo = -1;
   228    unsigned long ulo = 1;
   229 @@ -179,12 +180,11 @@
   230  
   231    limb[0] = limb[1] = limb[2] = ~ (mp_limb_t) 0;
   232  
   233 -  check_vfprintf (fout, "a. %Ra, b. %hhu, c. %u, d. %lx%hhn", mpfr, uch, ui,
   234 -                  ulo, &uch);
   235 -  check_length (1, uch, 28, hhu);
   236 -  check_vfprintf (fout, "a. %hhi, b. %Rb, c. %u, d. %li%ln", sch, mpfr, i,
   237 +  check_vfprintf (fout, "a. %Ra, b. %u, c. %lx%n", mpfr, ui, ulo, &j);
   238 +  check_length (1, j, 22, d);
   239 +  check_vfprintf (fout, "a. %c, b. %Rb, c. %u, d. %li%ln", i, mpfr, i,
   240                    lo, &ulo);
   241 -  check_length (2, ulo, 37, lu);
   242 +  check_length (2, ulo, 36, lu);
   243    check_vfprintf (fout, "a. %hi, b. %*f, c. %Re%hn", ush, 3, f, mpfr, &ush);
   244    check_length (3, ush, 29, hu);
   245    check_vfprintf (fout, "a. %hi, b. %f, c. %#.2Rf%n", sh, d, mpfr, &i);
   246 @@ -208,13 +208,18 @@
   247    check_length (9, sz, 30, zu);
   248  #endif
   249  
   250 +#ifndef NPRINTF_HH
   251 +  check_vfprintf (fout, "a. %hhi, b.%RA, c. %hhu%hhn", sch, mpfr, uch, &uch);
   252 +  check_length (10, uch, 21, hhu);
   253 +#endif
   254 +
   255  #if (__GNU_MP_VERSION * 10 + __GNU_MP_VERSION_MINOR) >= 42
   256    /* The 'M' specifier was added in gmp 4.2.0 */
   257    check_vfprintf (fout, "a. %Mx b. %Re%Mn", limb[0], mpfr, &limb[0]);
   258    if (limb[0] != 14 + BITS_PER_MP_LIMB / 4 || limb[1] != ~ (mp_limb_t) 0
   259        || limb[2] != ~ (mp_limb_t) 0)
   260      {
   261 -      printf ("Error in test #10: mpfr_vfprintf did not print %d characters"
   262 +      printf ("Error in test #11: mpfr_vfprintf did not print %d characters"
   263                " as expected\n", 14 + (int) BITS_PER_MP_LIMB / 4);
   264        exit (1);
   265      }
   266 @@ -227,13 +232,13 @@
   267    if (limb[0] != 14 + 3 * BITS_PER_MP_LIMB / 4 || limb[1] != (mp_limb_t) 0
   268        || limb[2] != ~ (mp_limb_t) 0)
   269      {
   270 -      printf ("Error in test #11: mpfr_vfprintf did not print %d characters"
   271 +      printf ("Error in test #12: mpfr_vfprintf did not print %d characters"
   272                " as expected\n", 14 + (int) BITS_PER_MP_LIMB / 4);
   273        exit (1);
   274      }
   275  #endif
   276  
   277 -#ifdef HAVE_LONG_LONG
   278 +#if defined(HAVE_LONG_LONG) && !defined(NPRINTF_LL)
   279    {
   280      long long llo = -1;
   281      unsigned long long ullo = 1;
   282 diff -Naurd mpfr-2.4.0-a/tests/tprintf.c mpfr-2.4.0-b/tests/tprintf.c
   283 --- mpfr-2.4.0-a/tests/tprintf.c	2009-01-26 12:52:00.000000000 +0000
   284 +++ mpfr-2.4.0-b/tests/tprintf.c	2009-02-20 16:31:02.000000000 +0000
   285 @@ -150,6 +150,7 @@
   286    short sh = -1;
   287    unsigned short ush = 1;
   288    int i = -1;
   289 +  int j = 1;
   290    unsigned int ui = 1;
   291    long lo = -1;
   292    unsigned long ulo = 1;
   293 @@ -178,11 +179,10 @@
   294    mpfr_set_f (mpfr, mpf, GMP_RNDN);
   295    prec = mpfr_get_prec (mpfr);
   296  
   297 -  check_vprintf ("a. %Ra, b. %hhu, c. %u, d. %lx%hhn", mpfr, uch, ui, ulo,
   298 -                 &uch);
   299 -  check_length (1, uch, 28, hhu);
   300 -  check_vprintf ("a. %hhi, b. %Rb, c. %u, d. %li%ln", sch, mpfr, i, lo, &ulo);
   301 -  check_length (2, ulo, 37, lu);
   302 +  check_vprintf ("a. %Ra, b. %u, c. %lx%n", mpfr, ui, ulo, &j);
   303 +  check_length (1, j, 22, d);
   304 +  check_vprintf ("a. %c, b. %Rb, c. %u, d. %li%ln", i, mpfr, i, lo, &ulo);
   305 +  check_length (2, ulo, 36, lu);
   306    check_vprintf ("a. %hi, b. %*f, c. %Re%hn", ush, 3, f, mpfr, &ush);
   307    check_length (3, ush, 29, hu);
   308    check_vprintf ("a. %hi, b. %f, c. %#.2Rf%n", sh, d, mpfr, &i);
   309 @@ -204,7 +204,12 @@
   310    check_length (9, sz, 30, zu);
   311  #endif
   312  
   313 -#ifdef HAVE_LONG_LONG
   314 +#ifndef NPRINTF_HH
   315 +  check_vprintf ("a. %hhi, b. %Ra, c. %hhu%hhn", sch, mpfr, uch, &uch);
   316 +  check_length (10, uch, 22, hhu);
   317 +#endif
   318 +
   319 +#if defined(HAVE_LONG_LONG) && !defined(NPRINTF_LL)
   320    {
   321      long long llo = -1;
   322      unsigned long long ullo = 1;
   323 diff -Naurd mpfr-2.4.0-a/vasprintf.c mpfr-2.4.0-b/vasprintf.c
   324 --- mpfr-2.4.0-a/vasprintf.c	2009-01-26 12:52:01.000000000 +0000
   325 +++ mpfr-2.4.0-b/vasprintf.c	2009-02-20 16:31:02.000000000 +0000
   326 @@ -235,10 +235,14 @@
   327        break;
   328      case 'h':
   329        if (*++format == 'h')
   330 +#ifndef NPRINTF_HH
   331          {
   332            ++format;
   333            specinfo->arg_type = CHAR_ARG;
   334          }
   335 +#else
   336 +        specinfo->arg_type = UNSUPPORTED;
   337 +#endif
   338        else
   339          specinfo->arg_type = SHORT_ARG;
   340        break;
   341 @@ -246,7 +250,7 @@
   342        if (*++format == 'l')
   343          {
   344            ++format;
   345 -#ifdef HAVE_LONG_LONG
   346 +#if defined (HAVE_LONG_LONG) && !defined(NPRINTF_LL)
   347            specinfo->arg_type = LONG_LONG_ARG;
   348  #else
   349            specinfo->arg_type = UNSUPPORTED;
   350 diff -Naurd mpfr-2.4.0-a/version.c mpfr-2.4.0-b/version.c
   351 --- mpfr-2.4.0-a/version.c	2009-01-26 12:52:01.000000000 +0000
   352 +++ mpfr-2.4.0-b/version.c	2009-02-20 17:27:44.000000000 +0000
   353 @@ -25,5 +25,5 @@
   354  const char *
   355  mpfr_get_version (void)
   356  {
   357 -  return "2.4.0";
   358 +  return "2.4.0-p1";
   359  }