Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb/doublest.c: Avoid calling ldfrexp if long double is double.
  2013-06-07 18:40 [PATCH] gdb/doublest.c: Avoid calling ldfrexp if long double is double Will Newton
@ 2013-06-07 18:39 ` Will Newton
  2013-06-07 20:24 ` Mark Kettenis
  1 sibling, 0 replies; 4+ messages in thread
From: Will Newton @ 2013-06-07 18:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: patches


There's no need to call ldfrexp if long double is the same size
as double, the standard frexp will be faster and more accurate.
This fixes a failure in ldbl_308.exp on ARM, where long double
is the same size as double.

gdb/ChangeLog:

2013-06-07  Will Newton  <will.newton@linaro.org>

	* doublest.c (convert_doublest_to_floatformat): If long
	double is the same size as double call frexp instead of
	ldfrexp.
---
 gdb/doublest.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gdb/doublest.c b/gdb/doublest.c
index 9ddc7a6..4bc0bd6 100644
--- a/gdb/doublest.c
+++ b/gdb/doublest.c
@@ -466,7 +466,10 @@ convert_doublest_to_floatformat (CONST struct floatformat *fmt,
     }

 #ifdef HAVE_LONG_DOUBLE
-  mant = ldfrexp (dfrom, &exponent);
+  if (sizeof (long double) > sizeof (double))
+    mant = ldfrexp (dfrom, &exponent);
+  else
+    mant = frexp (dfrom, &exponent);
 #else
   mant = frexp (dfrom, &exponent);
 #endif
-- 
1.8.1.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] gdb/doublest.c: Avoid calling ldfrexp if long double is double.
@ 2013-06-07 18:40 Will Newton
  2013-06-07 18:39 ` Will Newton
  2013-06-07 20:24 ` Mark Kettenis
  0 siblings, 2 replies; 4+ messages in thread
From: Will Newton @ 2013-06-07 18:40 UTC (permalink / raw)
  To: gdb-patches; +Cc: patches


There's no need to call ldfrexp if long double is the same size
as double, the standard frexp will be faster and more accurate.
This fixes a failure in ldbl_308.exp on ARM, where long double
is the same size as double.

gdb/ChangeLog:

2013-06-07  Will Newton  <will.newton@linaro.org>

	* doublest.c (convert_doublest_to_floatformat): If long
	double is the same size as double call frexp instead of
	ldfrexp.
---
 gdb/doublest.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gdb/doublest.c b/gdb/doublest.c
index 9ddc7a6..4bc0bd6 100644
--- a/gdb/doublest.c
+++ b/gdb/doublest.c
@@ -466,7 +466,10 @@ convert_doublest_to_floatformat (CONST struct floatformat *fmt,
     }

 #ifdef HAVE_LONG_DOUBLE
-  mant = ldfrexp (dfrom, &exponent);
+  if (sizeof (long double) > sizeof (double))
+    mant = ldfrexp (dfrom, &exponent);
+  else
+    mant = frexp (dfrom, &exponent);
 #else
   mant = frexp (dfrom, &exponent);
 #endif
-- 
1.8.1.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gdb/doublest.c: Avoid calling ldfrexp if long double is double.
  2013-06-07 18:40 [PATCH] gdb/doublest.c: Avoid calling ldfrexp if long double is double Will Newton
  2013-06-07 18:39 ` Will Newton
@ 2013-06-07 20:24 ` Mark Kettenis
  2013-06-11 13:33   ` Will Newton
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Kettenis @ 2013-06-07 20:24 UTC (permalink / raw)
  To: will.newton; +Cc: gdb-patches, patches

> Date: Fri, 07 Jun 2013 19:39:05 +0100
> From: Will Newton <will.newton@linaro.org>
> 
> There's no need to call ldfrexp if long double is the same size
> as double, the standard frexp will be faster and more accurate.
> This fixes a failure in ldbl_308.exp on ARM, where long double
> is the same size as double.
> 
> gdb/ChangeLog:
> 
> 2013-06-07  Will Newton  <will.newton@linaro.org>
> 
> 	* doublest.c (convert_doublest_to_floatformat): If long
> 	double is the same size as double call frexp instead of
> 	ldfrexp.
> ---
>  gdb/doublest.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Hmm, sounds like the real bug is in ldfrexp.  Not sure if that is
fixable though.  How many systems are still out there that have a long
double type, but don't have frexpl(3)?

Hmm, according to

  <http://www.gnu.org/software/gnulib/manual/html_node/frexpl.html>

there might still be a few.  But that means we just have to include
another gnulib module ;).

> diff --git a/gdb/doublest.c b/gdb/doublest.c
> index 9ddc7a6..4bc0bd6 100644
> --- a/gdb/doublest.c
> +++ b/gdb/doublest.c
> @@ -466,7 +466,10 @@ convert_doublest_to_floatformat (CONST struct floatformat *fmt,
>      }
> 
>  #ifdef HAVE_LONG_DOUBLE
> -  mant = ldfrexp (dfrom, &exponent);
> +  if (sizeof (long double) > sizeof (double))
> +    mant = ldfrexp (dfrom, &exponent);
> +  else
> +    mant = frexp (dfrom, &exponent);
>  #else
>    mant = frexp (dfrom, &exponent);
>  #endif
> -- 
> 1.8.1.4
> 
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gdb/doublest.c: Avoid calling ldfrexp if long double is double.
  2013-06-07 20:24 ` Mark Kettenis
@ 2013-06-11 13:33   ` Will Newton
  0 siblings, 0 replies; 4+ messages in thread
From: Will Newton @ 2013-06-11 13:33 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches, Patch Tracking

On 7 June 2013 21:09, Mark Kettenis <mark.kettenis@xs4all.nl> wrote:
>> Date: Fri, 07 Jun 2013 19:39:05 +0100
>> From: Will Newton <will.newton@linaro.org>
>>
>> There's no need to call ldfrexp if long double is the same size
>> as double, the standard frexp will be faster and more accurate.
>> This fixes a failure in ldbl_308.exp on ARM, where long double
>> is the same size as double.
>>
>> gdb/ChangeLog:
>>
>> 2013-06-07  Will Newton  <will.newton@linaro.org>
>>
>>       * doublest.c (convert_doublest_to_floatformat): If long
>>       double is the same size as double call frexp instead of
>>       ldfrexp.
>> ---
>>  gdb/doublest.c | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> Hmm, sounds like the real bug is in ldfrexp.  Not sure if that is
> fixable though.  How many systems are still out there that have a long
> double type, but don't have frexpl(3)?
>
> Hmm, according to
>
>   <http://www.gnu.org/software/gnulib/manual/html_node/frexpl.html>
>
> there might still be a few.  But that means we just have to include
> another gnulib module ;).

This sounds like a better approach than my patch. Is there a standard
set of steps to add a new gnulib module?

I tried adding frexpl to update-gnulib.sh and that seems to work, but
then all my systems are glibc-based so frexpl is present and correct
anyway.

Thanks,

--
Will Newton
Toolchain Working Group, Linaro


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-06-11 13:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-07 18:40 [PATCH] gdb/doublest.c: Avoid calling ldfrexp if long double is double Will Newton
2013-06-07 18:39 ` Will Newton
2013-06-07 20:24 ` Mark Kettenis
2013-06-11 13:33   ` Will Newton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox