diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-02-02 09:48:26 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2007-02-02 09:48:26 +0000 |
commit | ce28a8ab09cdd49890261d37b5b9280131d18014 (patch) | |
tree | c8ba4212f852ffa7ae3aaf87b3a316612e2c401b /stdio-common/_itowa.c | |
parent | a544f6724f8a668e4e2c4e47b5d8b87a47c67db7 (diff) | |
download | glibc-ce28a8ab09cdd49890261d37b5b9280131d18014.tar.gz glibc-ce28a8ab09cdd49890261d37b5b9280131d18014.tar.xz glibc-ce28a8ab09cdd49890261d37b5b9280131d18014.zip |
Updated to fedora-glibc-20070202T0923 cvs/fedora-glibc-2_5_90-16
Diffstat (limited to 'stdio-common/_itowa.c')
-rw-r--r-- | stdio-common/_itowa.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/stdio-common/_itowa.c b/stdio-common/_itowa.c index b9cc341dd9..09a961dfaf 100644 --- a/stdio-common/_itowa.c +++ b/stdio-common/_itowa.c @@ -1,5 +1,5 @@ /* 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. Contributed by Torbjorn Granlund <tege@matematik.su.se> and Ulrich Drepper <drepper@gnu.org>. @@ -21,6 +21,7 @@ #include <gmp-mparam.h> #include <gmp.h> +#include <limits.h> #include <stdlib/gmp-impl.h> #include <stdlib/longlong.h> @@ -85,6 +86,7 @@ extern const wchar_t _itowa_lower_digits[] attribute_hidden; extern const wchar_t _itowa_upper_digits[] attribute_hidden; +#if LLONG_MAX != LONG_MAX wchar_t * _itowa (value, buflim, base, upper_case) unsigned long long int value; @@ -99,7 +101,7 @@ _itowa (value, buflim, base, upper_case) switch (base) { -#define RUN_2N(BITS) \ +# define RUN_2N(BITS) \ do \ { \ /* `unsigned long long int' always has 64 bits. */ \ @@ -153,7 +155,7 @@ _itowa (value, buflim, base, upper_case) default: { -#if BITS_PER_MP_LIMB == 64 +# if BITS_PER_MP_LIMB == 64 mp_limb_t base_multiplier = brec->base_multiplier; if (brec->flag) while (value != 0) @@ -177,8 +179,8 @@ _itowa (value, buflim, base, upper_case) *--bp = digits[rem]; value = quo; } -#endif -#if BITS_PER_MP_LIMB == 32 +# endif +# if BITS_PER_MP_LIMB == 32 mp_limb_t t[3]; int n; @@ -186,11 +188,11 @@ _itowa (value, buflim, base, upper_case) Optimize for frequent cases of 32 bit numbers. */ 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; mp_limb_t big_base_norm = brec->big.base << big_normalization_steps; -#endif +# endif if ((mp_limb_t) (value >> 32) >= brec->big.base) { mp_limb_t x1hi, x1lo, r; @@ -199,7 +201,7 @@ _itowa (value, buflim, base, upper_case) always be very small. It might be faster just to subtract in a tight loop. */ -#if UDIV_TIME > 2 * UMUL_TIME +# if UDIV_TIME > 2 * UMUL_TIME mp_limb_t x, xh, xl; if (big_normalization_steps == 0) @@ -224,7 +226,7 @@ _itowa (value, buflim, base, upper_case) udiv_qrnnd_preinv (t[0], x, xh, xl, big_base_norm, brec->big.base_ninv); t[1] = x >> big_normalization_steps; -#elif UDIV_NEEDS_NORMALIZATION +# elif UDIV_NEEDS_NORMALIZATION mp_limb_t x, xh, xl; if (big_normalization_steps == 0) @@ -246,17 +248,17 @@ _itowa (value, buflim, base, upper_case) xl = x1lo << big_normalization_steps; udiv_qrnnd (t[0], x, xh, xl, big_base_norm); t[1] = x >> big_normalization_steps; -#else +# else udiv_qrnnd (x1hi, r, 0, (mp_limb_t) (value >> 32), 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); -#endif +# endif n = 3; } else { -#if (UDIV_TIME > 2 * UMUL_TIME) +# if UDIV_TIME > 2 * UMUL_TIME mp_limb_t x; value <<= brec->big.normalization_steps; @@ -264,17 +266,17 @@ _itowa (value, buflim, base, upper_case) (mp_limb_t) value, big_base_norm, brec->big.base_ninv); t[1] = x >> brec->big.normalization_steps; -#elif UDIV_NEEDS_NORMALIZATION +# elif UDIV_NEEDS_NORMALIZATION mp_limb_t x; value <<= big_normalization_steps; udiv_qrnnd (t[0], x, (mp_limb_t) (value >> 32), (mp_limb_t) value, big_base_norm); t[1] = x >> big_normalization_steps; -#else +# else udiv_qrnnd (t[0], t[1], (mp_limb_t) (value >> 32), (mp_limb_t) value, brec->big.base); -#endif +# endif n = 2; } } @@ -290,7 +292,7 @@ _itowa (value, buflim, base, upper_case) mp_limb_t ti = t[--n]; 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; if (brec->flag) while (ti != 0) @@ -316,7 +318,7 @@ _itowa (value, buflim, base, upper_case) ti = quo; ++ndig_for_this_limb; } -#else +# else while (ti != 0) { mp_limb_t quo, rem; @@ -327,7 +329,7 @@ _itowa (value, buflim, base, upper_case) ti = quo; ++ndig_for_this_limb; } -#endif +# endif /* If this wasn't the most significant word, pad with zeros. */ if (n != 0) while (ndig_for_this_limb < brec->big.ndigits) @@ -337,10 +339,11 @@ _itowa (value, buflim, base, upper_case) } } while (n != 0); -#endif +# endif } break; } return bp; } +#endif |