* [PATCH 2/2] gdb/doublest.c: Use frexpl rather than ldfrexp.
@ 2013-06-14 12:34 Will Newton
2013-06-14 13:03 ` Mark Kettenis
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Will Newton @ 2013-06-14 12:34 UTC (permalink / raw)
To: gdb-patches; +Cc: patches
Most modern systems have frexpl and gnulib provides an implementation
for those that don't, so use it instead of the generic but inaccurate
ldfrexp.
gdb/ChangeLog:
2013-06-14 Will Newton <will.newton@linaro.org>
* doublest.c (ldfrexp): Remove function.
(convert_doublest_to_floatformat): Call frexpl instead of
ldfrexp.
---
gdb/doublest.c | 49 +------------------------------------------------
1 file changed, 1 insertion(+), 48 deletions(-)
diff --git a/gdb/doublest.c b/gdb/doublest.c
index 9ddc7a6..2e4c87e 100644
--- a/gdb/doublest.c
+++ b/gdb/doublest.c
@@ -336,53 +336,6 @@ put_field (unsigned char *data, enum floatformat_byteorders order,
}
}
-#ifdef HAVE_LONG_DOUBLE
-/* Return the fractional part of VALUE, and put the exponent of VALUE in *EPTR.
- The range of the returned value is >= 0.5 and < 1.0. This is equivalent to
- frexp, but operates on the long double data type. */
-
-static long double ldfrexp (long double value, int *eptr);
-
-static long double
-ldfrexp (long double value, int *eptr)
-{
- long double tmp;
- int exp;
-
- /* Unfortunately, there are no portable functions for extracting the
- exponent of a long double, so we have to do it iteratively by
- multiplying or dividing by two until the fraction is between 0.5
- and 1.0. */
-
- if (value < 0.0l)
- value = -value;
-
- tmp = 1.0l;
- exp = 0;
-
- if (value >= tmp) /* Value >= 1.0 */
- while (value >= tmp)
- {
- tmp *= 2.0l;
- exp++;
- }
- else if (value != 0.0l) /* Value < 1.0 and > 0.0 */
- {
- while (value < tmp)
- {
- tmp /= 2.0l;
- exp--;
- }
- tmp *= 2.0l;
- exp++;
- }
-
- *eptr = exp;
- return value / tmp;
-}
-#endif /* HAVE_LONG_DOUBLE */
-
-
/* The converse: convert the DOUBLEST *FROM to an extended float and
store where TO points. Neither FROM nor TO have any alignment
restrictions. */
@@ -466,7 +419,7 @@ convert_doublest_to_floatformat (CONST struct floatformat *fmt,
}
#ifdef HAVE_LONG_DOUBLE
- mant = ldfrexp (dfrom, &exponent);
+ mant = frexpl (dfrom, &exponent);
#else
mant = frexp (dfrom, &exponent);
#endif
--
1.8.1.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] gdb/doublest.c: Use frexpl rather than ldfrexp.
2013-06-14 12:34 [PATCH 2/2] gdb/doublest.c: Use frexpl rather than ldfrexp Will Newton
@ 2013-06-14 13:03 ` Mark Kettenis
2013-06-21 10:58 ` Will Newton
2013-06-21 16:28 ` Joel Brobecker
2 siblings, 0 replies; 5+ messages in thread
From: Mark Kettenis @ 2013-06-14 13:03 UTC (permalink / raw)
To: will.newton; +Cc: gdb-patches, patches
> Date: Fri, 14 Jun 2013 13:33:50 +0100
> From: Will Newton <will.newton@linaro.org>
>
> Most modern systems have frexpl and gnulib provides an implementation
> for those that don't, so use it instead of the generic but inaccurate
> ldfrexp.
Great! Hopefully somebody with more gnulib experience can approve the
other diff.
> gdb/ChangeLog:
>
> 2013-06-14 Will Newton <will.newton@linaro.org>
>
> * doublest.c (ldfrexp): Remove function.
> (convert_doublest_to_floatformat): Call frexpl instead of
> ldfrexp.
> ---
> gdb/doublest.c | 49 +------------------------------------------------
> 1 file changed, 1 insertion(+), 48 deletions(-)
>
> diff --git a/gdb/doublest.c b/gdb/doublest.c
> index 9ddc7a6..2e4c87e 100644
> --- a/gdb/doublest.c
> +++ b/gdb/doublest.c
> @@ -336,53 +336,6 @@ put_field (unsigned char *data, enum floatformat_byteorders order,
> }
> }
>
> -#ifdef HAVE_LONG_DOUBLE
> -/* Return the fractional part of VALUE, and put the exponent of VALUE in *EPTR.
> - The range of the returned value is >= 0.5 and < 1.0. This is equivalent to
> - frexp, but operates on the long double data type. */
> -
> -static long double ldfrexp (long double value, int *eptr);
> -
> -static long double
> -ldfrexp (long double value, int *eptr)
> -{
> - long double tmp;
> - int exp;
> -
> - /* Unfortunately, there are no portable functions for extracting the
> - exponent of a long double, so we have to do it iteratively by
> - multiplying or dividing by two until the fraction is between 0.5
> - and 1.0. */
> -
> - if (value < 0.0l)
> - value = -value;
> -
> - tmp = 1.0l;
> - exp = 0;
> -
> - if (value >= tmp) /* Value >= 1.0 */
> - while (value >= tmp)
> - {
> - tmp *= 2.0l;
> - exp++;
> - }
> - else if (value != 0.0l) /* Value < 1.0 and > 0.0 */
> - {
> - while (value < tmp)
> - {
> - tmp /= 2.0l;
> - exp--;
> - }
> - tmp *= 2.0l;
> - exp++;
> - }
> -
> - *eptr = exp;
> - return value / tmp;
> -}
> -#endif /* HAVE_LONG_DOUBLE */
> -
> -
> /* The converse: convert the DOUBLEST *FROM to an extended float and
> store where TO points. Neither FROM nor TO have any alignment
> restrictions. */
> @@ -466,7 +419,7 @@ convert_doublest_to_floatformat (CONST struct floatformat *fmt,
> }
>
> #ifdef HAVE_LONG_DOUBLE
> - mant = ldfrexp (dfrom, &exponent);
> + mant = frexpl (dfrom, &exponent);
> #else
> mant = frexp (dfrom, &exponent);
> #endif
> --
> 1.8.1.4
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] gdb/doublest.c: Use frexpl rather than ldfrexp.
2013-06-14 12:34 [PATCH 2/2] gdb/doublest.c: Use frexpl rather than ldfrexp Will Newton
2013-06-14 13:03 ` Mark Kettenis
@ 2013-06-21 10:58 ` Will Newton
2013-06-21 16:28 ` Joel Brobecker
2 siblings, 0 replies; 5+ messages in thread
From: Will Newton @ 2013-06-21 10:58 UTC (permalink / raw)
To: gdb-patches; +Cc: Patch Tracking
On 14 June 2013 13:33, Will Newton <will.newton@linaro.org> wrote:
>
> Most modern systems have frexpl and gnulib provides an implementation
> for those that don't, so use it instead of the generic but inaccurate
> ldfrexp.
>
> gdb/ChangeLog:
>
> 2013-06-14 Will Newton <will.newton@linaro.org>
>
> * doublest.c (ldfrexp): Remove function.
> (convert_doublest_to_floatformat): Call frexpl instead of
> ldfrexp.
> ---
> gdb/doublest.c | 49 +------------------------------------------------
> 1 file changed, 1 insertion(+), 48 deletions(-)
Ping?
--
Will Newton
Toolchain Working Group, Linaro
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] gdb/doublest.c: Use frexpl rather than ldfrexp.
2013-06-14 12:34 [PATCH 2/2] gdb/doublest.c: Use frexpl rather than ldfrexp Will Newton
2013-06-14 13:03 ` Mark Kettenis
2013-06-21 10:58 ` Will Newton
@ 2013-06-21 16:28 ` Joel Brobecker
2013-06-21 16:44 ` Will Newton
2 siblings, 1 reply; 5+ messages in thread
From: Joel Brobecker @ 2013-06-21 16:28 UTC (permalink / raw)
To: Will Newton; +Cc: gdb-patches, patches
> 2013-06-14 Will Newton <will.newton@linaro.org>
>
> * doublest.c (ldfrexp): Remove function.
> (convert_doublest_to_floatformat): Call frexpl instead of
> ldfrexp.
FWIW, I read Mark's message as approval of this patch, but this looks
like an improvement for me as well. Goodbye ldfrexp :).
Thank you,
--
Joel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] gdb/doublest.c: Use frexpl rather than ldfrexp.
2013-06-21 16:28 ` Joel Brobecker
@ 2013-06-21 16:44 ` Will Newton
0 siblings, 0 replies; 5+ messages in thread
From: Will Newton @ 2013-06-21 16:44 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches, Patch Tracking
On 21 June 2013 16:56, Joel Brobecker <brobecker@adacore.com> wrote:
>> 2013-06-14 Will Newton <will.newton@linaro.org>
>>
>> * doublest.c (ldfrexp): Remove function.
>> (convert_doublest_to_floatformat): Call frexpl instead of
>> ldfrexp.
>
> FWIW, I read Mark's message as approval of this patch, but this looks
> like an improvement for me as well. Goodbye ldfrexp :).
Thanks, both patches applied.
--
Will Newton
Toolchain Working Group, Linaro
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-06-21 16:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-14 12:34 [PATCH 2/2] gdb/doublest.c: Use frexpl rather than ldfrexp Will Newton
2013-06-14 13:03 ` Mark Kettenis
2013-06-21 10:58 ` Will Newton
2013-06-21 16:28 ` Joel Brobecker
2013-06-21 16:44 ` Will Newton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox