mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-07 06:43:00 +03:00
* stdio-common/_itowa.c: Don't compile _itowa for 64-bit
platforms. * stdio-common/_itoa.c: Don't compile in _itoa and _fitoa for 64-bit platforms. * malloc/mtrace.c (tr_where): Use _fitoa_word instead of _fitoa if possible. * posix/wordexp.c (parse_arith): Use _itoa_word instead of _itoa if possible.
This commit is contained in:
@@ -1,5 +1,14 @@
|
|||||||
2007-01-22 Ulrich Drepper <drepper@redhat.com>
|
2007-01-22 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* stdio-common/_itowa.c: Don't compile _itowa for 64-bit
|
||||||
|
platforms.
|
||||||
|
* stdio-common/_itoa.c: Don't compile in _itoa and _fitoa for
|
||||||
|
64-bit platforms.
|
||||||
|
* malloc/mtrace.c (tr_where): Use _fitoa_word instead of _fitoa if
|
||||||
|
possible.
|
||||||
|
* posix/wordexp.c (parse_arith): Use _itoa_word instead of _itoa
|
||||||
|
if possible.
|
||||||
|
|
||||||
[BZ #3902]
|
[BZ #3902]
|
||||||
* stdio-common/_itoa.c (_itoa): Make sure at least a zero is emitted.
|
* stdio-common/_itoa.c (_itoa): Make sure at least a zero is emitted.
|
||||||
* stdio-common/Makefile (tests): Add bug17.
|
* stdio-common/Makefile (tests): Add bug17.
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* More debugging hooks for `malloc'.
|
/* More debugging hooks for `malloc'.
|
||||||
Copyright (C) 1991-1994,1996-2003, 2004 Free Software Foundation, Inc.
|
Copyright (C) 1991-1994,1996-2004, 2007 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Written April 2, 1991 by John Gilmore of Cygnus Support.
|
Written April 2, 1991 by John Gilmore of Cygnus Support.
|
||||||
Based on mcheck.c by Mike Haertel.
|
Based on mcheck.c by Mike Haertel.
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -113,15 +114,20 @@ tr_where (caller)
|
|||||||
buf = alloca (len + 6 + 2 * sizeof (void *));
|
buf = alloca (len + 6 + 2 * sizeof (void *));
|
||||||
|
|
||||||
buf[0] = '(';
|
buf[0] = '(';
|
||||||
__stpcpy (_fitoa (caller >= (const __ptr_t) info.dli_saddr
|
|
||||||
? caller - (const __ptr_t) info.dli_saddr
|
char *cp = __stpcpy (__mempcpy (buf + 1, info.dli_sname, len),
|
||||||
: (const __ptr_t) info.dli_saddr - caller,
|
caller >= (__ptr_t) info.dli_saddr
|
||||||
__stpcpy (__mempcpy (buf + 1, info.dli_sname,
|
? "+0x" : "-0x");
|
||||||
len),
|
intptr_t offset = (caller >= (const __ptr_t) info.dli_saddr
|
||||||
caller >= (__ptr_t) info.dli_saddr
|
? caller - (const __ptr_t) info.dli_saddr
|
||||||
? "+0x" : "-0x"),
|
: (const __ptr_t) info.dli_saddr - caller);
|
||||||
16, 0),
|
# if LLONG_MAX == LONG_MAX
|
||||||
")");
|
cp = _fitoa_word (offset, cp, 16, 0);
|
||||||
|
# else
|
||||||
|
cp = _fitoa (offset, cp, 16, 0);
|
||||||
|
# endif
|
||||||
|
|
||||||
|
__stpcpy (cp, ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (mallstream, "@ %s%s%s[%p] ",
|
fprintf (mallstream, "@ %s%s%s[%p] ",
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* POSIX.2 wordexp implementation.
|
/* POSIX.2 wordexp implementation.
|
||||||
Copyright (C) 1997-2002, 2003, 2005, 2006 Free Software Foundation, Inc.
|
Copyright (C) 1997-2003, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Tim Waugh <tim@cyberelk.demon.co.uk>.
|
Contributed by Tim Waugh <tim@cyberelk.demon.co.uk>.
|
||||||
|
|
||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <fnmatch.h>
|
#include <fnmatch.h>
|
||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
@@ -757,8 +758,13 @@ parse_arith (char **word, size_t *word_length, size_t *max_length,
|
|||||||
convertme = numresult;
|
convertme = numresult;
|
||||||
|
|
||||||
result[20] = '\0';
|
result[20] = '\0';
|
||||||
*word = w_addstr (*word, word_length, max_length,
|
char *numstr;
|
||||||
_itoa (convertme, &result[20], 10, 0));
|
#if LLONG_MAX == LONG_MAX
|
||||||
|
numstr = _itoa_word (convertme, &result[20], 10, 0);
|
||||||
|
#else
|
||||||
|
numstr = _itoa (convertme, &result[20], 10, 0);
|
||||||
|
#endif
|
||||||
|
*word = w_addstr (*word, word_length, max_length, numstr);
|
||||||
free (expr);
|
free (expr);
|
||||||
return *word ? 0 : WRDE_NOSPACE;
|
return *word ? 0 : WRDE_NOSPACE;
|
||||||
}
|
}
|
||||||
|
@@ -78,10 +78,12 @@ struct base_table_t
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* We do not compile _itoa if we always can use _itoa_word. */
|
||||||
|
#if LLONG_MAX != LONG_MAX
|
||||||
/* Local variables. */
|
/* Local variables. */
|
||||||
const struct base_table_t _itoa_base_table[] attribute_hidden =
|
const struct base_table_t _itoa_base_table[] attribute_hidden =
|
||||||
{
|
{
|
||||||
#if BITS_PER_MP_LIMB == 64
|
# if BITS_PER_MP_LIMB == 64
|
||||||
/* 2 */ {SEL1(0ull) 1, 1},
|
/* 2 */ {SEL1(0ull) 1, 1},
|
||||||
/* 3 */ {SEL1(0xaaaaaaaaaaaaaaabull) 0, 1},
|
/* 3 */ {SEL1(0xaaaaaaaaaaaaaaabull) 0, 1},
|
||||||
/* 4 */ {SEL1(0ull) 1, 2},
|
/* 4 */ {SEL1(0ull) 1, 2},
|
||||||
@@ -117,8 +119,8 @@ const struct base_table_t _itoa_base_table[] attribute_hidden =
|
|||||||
/* 34 */ {SEL1(0xf0f0f0f0f0f0f0f1ull) 0, 5},
|
/* 34 */ {SEL1(0xf0f0f0f0f0f0f0f1ull) 0, 5},
|
||||||
/* 35 */ {SEL1(0xea0ea0ea0ea0ea0full) 0, 5},
|
/* 35 */ {SEL1(0xea0ea0ea0ea0ea0full) 0, 5},
|
||||||
/* 36 */ {SEL1(0xe38e38e38e38e38full) 0, 5}
|
/* 36 */ {SEL1(0xe38e38e38e38e38full) 0, 5}
|
||||||
#endif
|
# endif
|
||||||
#if BITS_PER_MP_LIMB == 32
|
# if BITS_PER_MP_LIMB == 32
|
||||||
/* 2 */ {SEL1(0ul) 1, 1, {0, 31, 0x80000000ul SEL2(0xfffffffful)}},
|
/* 2 */ {SEL1(0ul) 1, 1, {0, 31, 0x80000000ul SEL2(0xfffffffful)}},
|
||||||
/* 3 */ {SEL1(0xaaaaaaabul) 0, 1, {0, 20, 0xcfd41b91ul SEL2(0x3b563c24ul)}},
|
/* 3 */ {SEL1(0xaaaaaaabul) 0, 1, {0, 20, 0xcfd41b91ul SEL2(0x3b563c24ul)}},
|
||||||
/* 4 */ {SEL1(0ul) 1, 2, {1, 15, 0x40000000ul SEL2(0xfffffffful)}},
|
/* 4 */ {SEL1(0ul) 1, 2, {1, 15, 0x40000000ul SEL2(0xfffffffful)}},
|
||||||
@@ -154,8 +156,9 @@ const struct base_table_t _itoa_base_table[] attribute_hidden =
|
|||||||
/* 34 */ {SEL1(0xf0f0f0f1ul) 0, 5, {1, 6, 0x5c13d840ul SEL2(0x63dfc229ul)}},
|
/* 34 */ {SEL1(0xf0f0f0f1ul) 0, 5, {1, 6, 0x5c13d840ul SEL2(0x63dfc229ul)}},
|
||||||
/* 35 */ {SEL1(0xd41d41d5ul) 1, 6, {1, 6, 0x6d91b519ul SEL2(0x2b0fee30ul)}},
|
/* 35 */ {SEL1(0xd41d41d5ul) 1, 6, {1, 6, 0x6d91b519ul SEL2(0x2b0fee30ul)}},
|
||||||
/* 36 */ {SEL1(0x38e38e39ul) 0, 3, {0, 6, 0x81bf1000ul SEL2(0xf91bd1b6ul)}}
|
/* 36 */ {SEL1(0x38e38e39ul) 0, 3, {0, 6, 0x81bf1000ul SEL2(0xf91bd1b6ul)}}
|
||||||
#endif
|
# endif
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Lower-case digits. */
|
/* Lower-case digits. */
|
||||||
extern const char _itoa_lower_digits[];
|
extern const char _itoa_lower_digits[];
|
||||||
@@ -201,6 +204,7 @@ _itoa_word (unsigned long value, char *buflim,
|
|||||||
#undef SPECIAL
|
#undef SPECIAL
|
||||||
|
|
||||||
|
|
||||||
|
#if LLONG_MAX != LONG_MAX
|
||||||
char *
|
char *
|
||||||
_itoa (value, buflim, base, upper_case)
|
_itoa (value, buflim, base, upper_case)
|
||||||
unsigned long long int value;
|
unsigned long long int value;
|
||||||
@@ -215,7 +219,7 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
|
|
||||||
switch (base)
|
switch (base)
|
||||||
{
|
{
|
||||||
#define RUN_2N(BITS) \
|
# define RUN_2N(BITS) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
/* `unsigned long long int' always has 64 bits. */ \
|
/* `unsigned long long int' always has 64 bits. */ \
|
||||||
@@ -270,7 +274,7 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
char *bufend = buflim;
|
char *bufend = buflim;
|
||||||
#if BITS_PER_MP_LIMB == 64
|
# if BITS_PER_MP_LIMB == 64
|
||||||
mp_limb_t base_multiplier = brec->base_multiplier;
|
mp_limb_t base_multiplier = brec->base_multiplier;
|
||||||
if (brec->flag)
|
if (brec->flag)
|
||||||
while (value != 0)
|
while (value != 0)
|
||||||
@@ -294,8 +298,8 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
*--buflim = digits[rem];
|
*--buflim = digits[rem];
|
||||||
value = quo;
|
value = quo;
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
#if BITS_PER_MP_LIMB == 32
|
# if BITS_PER_MP_LIMB == 32
|
||||||
mp_limb_t t[3];
|
mp_limb_t t[3];
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
@@ -303,11 +307,11 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
Optimize for frequent cases of 32 bit numbers. */
|
Optimize for frequent cases of 32 bit numbers. */
|
||||||
if ((mp_limb_t) (value >> 32) >= 1)
|
if ((mp_limb_t) (value >> 32) >= 1)
|
||||||
{
|
{
|
||||||
#if UDIV_TIME > 2 * UMUL_TIME || UDIV_NEEDS_NORMALIZATION
|
# if UDIV_TIME > 2 * UMUL_TIME || UDIV_NEEDS_NORMALIZATION
|
||||||
int big_normalization_steps = brec->big.normalization_steps;
|
int big_normalization_steps = brec->big.normalization_steps;
|
||||||
mp_limb_t big_base_norm
|
mp_limb_t big_base_norm
|
||||||
= brec->big.base << big_normalization_steps;
|
= brec->big.base << big_normalization_steps;
|
||||||
#endif
|
# endif
|
||||||
if ((mp_limb_t) (value >> 32) >= brec->big.base)
|
if ((mp_limb_t) (value >> 32) >= brec->big.base)
|
||||||
{
|
{
|
||||||
mp_limb_t x1hi, x1lo, r;
|
mp_limb_t x1hi, x1lo, r;
|
||||||
@@ -316,7 +320,7 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
always be very small. It might be faster just to
|
always be very small. It might be faster just to
|
||||||
subtract in a tight loop. */
|
subtract in a tight loop. */
|
||||||
|
|
||||||
#if UDIV_TIME > 2 * UMUL_TIME
|
# if UDIV_TIME > 2 * UMUL_TIME
|
||||||
mp_limb_t x, xh, xl;
|
mp_limb_t x, xh, xl;
|
||||||
|
|
||||||
if (big_normalization_steps == 0)
|
if (big_normalization_steps == 0)
|
||||||
@@ -341,7 +345,7 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
udiv_qrnnd_preinv (t[0], x, xh, xl, big_base_norm,
|
udiv_qrnnd_preinv (t[0], x, xh, xl, big_base_norm,
|
||||||
brec->big.base_ninv);
|
brec->big.base_ninv);
|
||||||
t[1] = x >> big_normalization_steps;
|
t[1] = x >> big_normalization_steps;
|
||||||
#elif UDIV_NEEDS_NORMALIZATION
|
# elif UDIV_NEEDS_NORMALIZATION
|
||||||
mp_limb_t x, xh, xl;
|
mp_limb_t x, xh, xl;
|
||||||
|
|
||||||
if (big_normalization_steps == 0)
|
if (big_normalization_steps == 0)
|
||||||
@@ -363,17 +367,17 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
xl = x1lo << big_normalization_steps;
|
xl = x1lo << big_normalization_steps;
|
||||||
udiv_qrnnd (t[0], x, xh, xl, big_base_norm);
|
udiv_qrnnd (t[0], x, xh, xl, big_base_norm);
|
||||||
t[1] = x >> big_normalization_steps;
|
t[1] = x >> big_normalization_steps;
|
||||||
#else
|
# else
|
||||||
udiv_qrnnd (x1hi, r, 0, (mp_limb_t) (value >> 32),
|
udiv_qrnnd (x1hi, r, 0, (mp_limb_t) (value >> 32),
|
||||||
brec->big.base);
|
brec->big.base);
|
||||||
udiv_qrnnd (x1lo, t[2], r, (mp_limb_t) value, brec->big.base);
|
udiv_qrnnd (x1lo, t[2], r, (mp_limb_t) value, brec->big.base);
|
||||||
udiv_qrnnd (t[0], t[1], x1hi, x1lo, brec->big.base);
|
udiv_qrnnd (t[0], t[1], x1hi, x1lo, brec->big.base);
|
||||||
#endif
|
# endif
|
||||||
n = 3;
|
n = 3;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if (UDIV_TIME > 2 * UMUL_TIME)
|
# if UDIV_TIME > 2 * UMUL_TIME
|
||||||
mp_limb_t x;
|
mp_limb_t x;
|
||||||
|
|
||||||
value <<= brec->big.normalization_steps;
|
value <<= brec->big.normalization_steps;
|
||||||
@@ -381,17 +385,17 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
(mp_limb_t) value, big_base_norm,
|
(mp_limb_t) value, big_base_norm,
|
||||||
brec->big.base_ninv);
|
brec->big.base_ninv);
|
||||||
t[1] = x >> brec->big.normalization_steps;
|
t[1] = x >> brec->big.normalization_steps;
|
||||||
#elif UDIV_NEEDS_NORMALIZATION
|
# elif UDIV_NEEDS_NORMALIZATION
|
||||||
mp_limb_t x;
|
mp_limb_t x;
|
||||||
|
|
||||||
value <<= big_normalization_steps;
|
value <<= big_normalization_steps;
|
||||||
udiv_qrnnd (t[0], x, (mp_limb_t) (value >> 32),
|
udiv_qrnnd (t[0], x, (mp_limb_t) (value >> 32),
|
||||||
(mp_limb_t) value, big_base_norm);
|
(mp_limb_t) value, big_base_norm);
|
||||||
t[1] = x >> big_normalization_steps;
|
t[1] = x >> big_normalization_steps;
|
||||||
#else
|
# else
|
||||||
udiv_qrnnd (t[0], t[1], (mp_limb_t) (value >> 32),
|
udiv_qrnnd (t[0], t[1], (mp_limb_t) (value >> 32),
|
||||||
(mp_limb_t) value, brec->big.base);
|
(mp_limb_t) value, brec->big.base);
|
||||||
#endif
|
# endif
|
||||||
n = 2;
|
n = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -407,7 +411,7 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
mp_limb_t ti = t[--n];
|
mp_limb_t ti = t[--n];
|
||||||
int ndig_for_this_limb = 0;
|
int ndig_for_this_limb = 0;
|
||||||
|
|
||||||
#if UDIV_TIME > 2 * UMUL_TIME
|
# if UDIV_TIME > 2 * UMUL_TIME
|
||||||
mp_limb_t base_multiplier = brec->base_multiplier;
|
mp_limb_t base_multiplier = brec->base_multiplier;
|
||||||
if (brec->flag)
|
if (brec->flag)
|
||||||
while (ti != 0)
|
while (ti != 0)
|
||||||
@@ -433,7 +437,7 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
ti = quo;
|
ti = quo;
|
||||||
++ndig_for_this_limb;
|
++ndig_for_this_limb;
|
||||||
}
|
}
|
||||||
#else
|
# else
|
||||||
while (ti != 0)
|
while (ti != 0)
|
||||||
{
|
{
|
||||||
mp_limb_t quo, rem;
|
mp_limb_t quo, rem;
|
||||||
@@ -444,7 +448,7 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
ti = quo;
|
ti = quo;
|
||||||
++ndig_for_this_limb;
|
++ndig_for_this_limb;
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
/* If this wasn't the most significant word, pad with zeros. */
|
/* If this wasn't the most significant word, pad with zeros. */
|
||||||
if (n != 0)
|
if (n != 0)
|
||||||
while (ndig_for_this_limb < brec->big.ndigits)
|
while (ndig_for_this_limb < brec->big.ndigits)
|
||||||
@@ -454,7 +458,7 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (n != 0);
|
while (n != 0);
|
||||||
#endif
|
# endif
|
||||||
if (buflim == bufend)
|
if (buflim == bufend)
|
||||||
*--buflim = '0';
|
*--buflim = '0';
|
||||||
}
|
}
|
||||||
@@ -463,6 +467,7 @@ _itoa (value, buflim, base, upper_case)
|
|||||||
|
|
||||||
return buflim;
|
return buflim;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
char *
|
char *
|
||||||
_fitoa_word (unsigned long value, char *buf, unsigned int base, int upper_case)
|
_fitoa_word (unsigned long value, char *buf, unsigned int base, int upper_case)
|
||||||
@@ -474,6 +479,7 @@ _fitoa_word (unsigned long value, char *buf, unsigned int base, int upper_case)
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LLONG_MAX != LONG_MAX
|
||||||
char *
|
char *
|
||||||
_fitoa (unsigned long long value, char *buf, unsigned int base, int upper_case)
|
_fitoa (unsigned long long value, char *buf, unsigned int base, int upper_case)
|
||||||
{
|
{
|
||||||
@@ -483,3 +489,4 @@ _fitoa (unsigned long long value, char *buf, unsigned int base, int upper_case)
|
|||||||
*buf++ = *cp++;
|
*buf++ = *cp++;
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* Internal function for converting integers to ASCII.
|
/* Internal function for converting integers to ASCII.
|
||||||
Copyright (C) 1994,1995,1996,1999,2000,2002 Free Software Foundation, Inc.
|
Copyright (C) 1994-1996,1999,2000,2002,2007 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Torbjorn Granlund <tege@matematik.su.se>
|
Contributed by Torbjorn Granlund <tege@matematik.su.se>
|
||||||
and Ulrich Drepper <drepper@gnu.org>.
|
and Ulrich Drepper <drepper@gnu.org>.
|
||||||
@@ -85,6 +85,7 @@ extern const wchar_t _itowa_lower_digits[] attribute_hidden;
|
|||||||
extern const wchar_t _itowa_upper_digits[] attribute_hidden;
|
extern const wchar_t _itowa_upper_digits[] attribute_hidden;
|
||||||
|
|
||||||
|
|
||||||
|
#if LLONG_MAX != LONG_MAX
|
||||||
wchar_t *
|
wchar_t *
|
||||||
_itowa (value, buflim, base, upper_case)
|
_itowa (value, buflim, base, upper_case)
|
||||||
unsigned long long int value;
|
unsigned long long int value;
|
||||||
@@ -99,7 +100,7 @@ _itowa (value, buflim, base, upper_case)
|
|||||||
|
|
||||||
switch (base)
|
switch (base)
|
||||||
{
|
{
|
||||||
#define RUN_2N(BITS) \
|
# define RUN_2N(BITS) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
/* `unsigned long long int' always has 64 bits. */ \
|
/* `unsigned long long int' always has 64 bits. */ \
|
||||||
@@ -153,7 +154,7 @@ _itowa (value, buflim, base, upper_case)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
#if BITS_PER_MP_LIMB == 64
|
# if BITS_PER_MP_LIMB == 64
|
||||||
mp_limb_t base_multiplier = brec->base_multiplier;
|
mp_limb_t base_multiplier = brec->base_multiplier;
|
||||||
if (brec->flag)
|
if (brec->flag)
|
||||||
while (value != 0)
|
while (value != 0)
|
||||||
@@ -177,8 +178,8 @@ _itowa (value, buflim, base, upper_case)
|
|||||||
*--bp = digits[rem];
|
*--bp = digits[rem];
|
||||||
value = quo;
|
value = quo;
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
#if BITS_PER_MP_LIMB == 32
|
# if BITS_PER_MP_LIMB == 32
|
||||||
mp_limb_t t[3];
|
mp_limb_t t[3];
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
@@ -186,11 +187,11 @@ _itowa (value, buflim, base, upper_case)
|
|||||||
Optimize for frequent cases of 32 bit numbers. */
|
Optimize for frequent cases of 32 bit numbers. */
|
||||||
if ((mp_limb_t) (value >> 32) >= 1)
|
if ((mp_limb_t) (value >> 32) >= 1)
|
||||||
{
|
{
|
||||||
#if UDIV_TIME > 2 * UMUL_TIME || UDIV_NEEDS_NORMALIZATION
|
# if UDIV_TIME > 2 * UMUL_TIME || UDIV_NEEDS_NORMALIZATION
|
||||||
int big_normalization_steps = brec->big.normalization_steps;
|
int big_normalization_steps = brec->big.normalization_steps;
|
||||||
mp_limb_t big_base_norm
|
mp_limb_t big_base_norm
|
||||||
= brec->big.base << big_normalization_steps;
|
= brec->big.base << big_normalization_steps;
|
||||||
#endif
|
# endif
|
||||||
if ((mp_limb_t) (value >> 32) >= brec->big.base)
|
if ((mp_limb_t) (value >> 32) >= brec->big.base)
|
||||||
{
|
{
|
||||||
mp_limb_t x1hi, x1lo, r;
|
mp_limb_t x1hi, x1lo, r;
|
||||||
@@ -199,7 +200,7 @@ _itowa (value, buflim, base, upper_case)
|
|||||||
always be very small. It might be faster just to
|
always be very small. It might be faster just to
|
||||||
subtract in a tight loop. */
|
subtract in a tight loop. */
|
||||||
|
|
||||||
#if UDIV_TIME > 2 * UMUL_TIME
|
# if UDIV_TIME > 2 * UMUL_TIME
|
||||||
mp_limb_t x, xh, xl;
|
mp_limb_t x, xh, xl;
|
||||||
|
|
||||||
if (big_normalization_steps == 0)
|
if (big_normalization_steps == 0)
|
||||||
@@ -224,7 +225,7 @@ _itowa (value, buflim, base, upper_case)
|
|||||||
udiv_qrnnd_preinv (t[0], x, xh, xl, big_base_norm,
|
udiv_qrnnd_preinv (t[0], x, xh, xl, big_base_norm,
|
||||||
brec->big.base_ninv);
|
brec->big.base_ninv);
|
||||||
t[1] = x >> big_normalization_steps;
|
t[1] = x >> big_normalization_steps;
|
||||||
#elif UDIV_NEEDS_NORMALIZATION
|
# elif UDIV_NEEDS_NORMALIZATION
|
||||||
mp_limb_t x, xh, xl;
|
mp_limb_t x, xh, xl;
|
||||||
|
|
||||||
if (big_normalization_steps == 0)
|
if (big_normalization_steps == 0)
|
||||||
@@ -246,17 +247,17 @@ _itowa (value, buflim, base, upper_case)
|
|||||||
xl = x1lo << big_normalization_steps;
|
xl = x1lo << big_normalization_steps;
|
||||||
udiv_qrnnd (t[0], x, xh, xl, big_base_norm);
|
udiv_qrnnd (t[0], x, xh, xl, big_base_norm);
|
||||||
t[1] = x >> big_normalization_steps;
|
t[1] = x >> big_normalization_steps;
|
||||||
#else
|
# else
|
||||||
udiv_qrnnd (x1hi, r, 0, (mp_limb_t) (value >> 32),
|
udiv_qrnnd (x1hi, r, 0, (mp_limb_t) (value >> 32),
|
||||||
brec->big.base);
|
brec->big.base);
|
||||||
udiv_qrnnd (x1lo, t[2], r, (mp_limb_t) value, brec->big.base);
|
udiv_qrnnd (x1lo, t[2], r, (mp_limb_t) value, brec->big.base);
|
||||||
udiv_qrnnd (t[0], t[1], x1hi, x1lo, brec->big.base);
|
udiv_qrnnd (t[0], t[1], x1hi, x1lo, brec->big.base);
|
||||||
#endif
|
# endif
|
||||||
n = 3;
|
n = 3;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if (UDIV_TIME > 2 * UMUL_TIME)
|
# if UDIV_TIME > 2 * UMUL_TIME
|
||||||
mp_limb_t x;
|
mp_limb_t x;
|
||||||
|
|
||||||
value <<= brec->big.normalization_steps;
|
value <<= brec->big.normalization_steps;
|
||||||
@@ -264,17 +265,17 @@ _itowa (value, buflim, base, upper_case)
|
|||||||
(mp_limb_t) value, big_base_norm,
|
(mp_limb_t) value, big_base_norm,
|
||||||
brec->big.base_ninv);
|
brec->big.base_ninv);
|
||||||
t[1] = x >> brec->big.normalization_steps;
|
t[1] = x >> brec->big.normalization_steps;
|
||||||
#elif UDIV_NEEDS_NORMALIZATION
|
# elif UDIV_NEEDS_NORMALIZATION
|
||||||
mp_limb_t x;
|
mp_limb_t x;
|
||||||
|
|
||||||
value <<= big_normalization_steps;
|
value <<= big_normalization_steps;
|
||||||
udiv_qrnnd (t[0], x, (mp_limb_t) (value >> 32),
|
udiv_qrnnd (t[0], x, (mp_limb_t) (value >> 32),
|
||||||
(mp_limb_t) value, big_base_norm);
|
(mp_limb_t) value, big_base_norm);
|
||||||
t[1] = x >> big_normalization_steps;
|
t[1] = x >> big_normalization_steps;
|
||||||
#else
|
# else
|
||||||
udiv_qrnnd (t[0], t[1], (mp_limb_t) (value >> 32),
|
udiv_qrnnd (t[0], t[1], (mp_limb_t) (value >> 32),
|
||||||
(mp_limb_t) value, brec->big.base);
|
(mp_limb_t) value, brec->big.base);
|
||||||
#endif
|
# endif
|
||||||
n = 2;
|
n = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -290,7 +291,7 @@ _itowa (value, buflim, base, upper_case)
|
|||||||
mp_limb_t ti = t[--n];
|
mp_limb_t ti = t[--n];
|
||||||
int ndig_for_this_limb = 0;
|
int ndig_for_this_limb = 0;
|
||||||
|
|
||||||
#if UDIV_TIME > 2 * UMUL_TIME
|
# if UDIV_TIME > 2 * UMUL_TIME
|
||||||
mp_limb_t base_multiplier = brec->base_multiplier;
|
mp_limb_t base_multiplier = brec->base_multiplier;
|
||||||
if (brec->flag)
|
if (brec->flag)
|
||||||
while (ti != 0)
|
while (ti != 0)
|
||||||
@@ -316,7 +317,7 @@ _itowa (value, buflim, base, upper_case)
|
|||||||
ti = quo;
|
ti = quo;
|
||||||
++ndig_for_this_limb;
|
++ndig_for_this_limb;
|
||||||
}
|
}
|
||||||
#else
|
# else
|
||||||
while (ti != 0)
|
while (ti != 0)
|
||||||
{
|
{
|
||||||
mp_limb_t quo, rem;
|
mp_limb_t quo, rem;
|
||||||
@@ -327,7 +328,7 @@ _itowa (value, buflim, base, upper_case)
|
|||||||
ti = quo;
|
ti = quo;
|
||||||
++ndig_for_this_limb;
|
++ndig_for_this_limb;
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
/* If this wasn't the most significant word, pad with zeros. */
|
/* If this wasn't the most significant word, pad with zeros. */
|
||||||
if (n != 0)
|
if (n != 0)
|
||||||
while (ndig_for_this_limb < brec->big.ndigits)
|
while (ndig_for_this_limb < brec->big.ndigits)
|
||||||
@@ -337,10 +338,11 @@ _itowa (value, buflim, base, upper_case)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (n != 0);
|
while (n != 0);
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bp;
|
return bp;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
Reference in New Issue
Block a user