public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
* alpha, ia64, hppa ports need get-rounding-mode.h
@ 2012-09-12 23:39 Joseph S. Myers
  2012-09-13  2:51 ` Carlos O'Donell
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Joseph S. Myers @ 2012-09-12 23:39 UTC (permalink / raw)
  To: libc-ports

As of commit

commit 6c9b0f68267cf365d060d4e51e7cb8f61498b875
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Wed Sep 12 23:36:19 2012 +0000

    Make strtod respect the rounding mode (bug 14518).

the alpha, ia64 and hppa ports need a get-rounding-mode.h header to define 
how to determine the floating-point rounding mode in libc, since they do 
not have an fpu_control.h header with the functionality needed for 
sysdeps/generic/get-rounding-mode.h to work.  There are various examples 
checked in; it's likely that something similar to 
sysdeps/s390/fpu/get-rounding-mode.h, closely following the implementation 
of fegetround, is appropriate.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: alpha, ia64, hppa ports need get-rounding-mode.h
  2012-09-12 23:39 alpha, ia64, hppa ports need get-rounding-mode.h Joseph S. Myers
@ 2012-09-13  2:51 ` Carlos O'Donell
  2012-09-13 14:37 ` Richard Henderson
  2012-09-24 23:23 ` [PATCH] ia64: define new get-rounding-mode.h header Mike Frysinger
  2 siblings, 0 replies; 4+ messages in thread
From: Carlos O'Donell @ 2012-09-13  2:51 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: libc-ports

On Wed, Sep 12, 2012 at 7:39 PM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> As of commit
>
> commit 6c9b0f68267cf365d060d4e51e7cb8f61498b875
> Author: Joseph Myers <joseph@codesourcery.com>
> Date:   Wed Sep 12 23:36:19 2012 +0000
>
>     Make strtod respect the rounding mode (bug 14518).
>
> the alpha, ia64 and hppa ports need a get-rounding-mode.h header to define
> how to determine the floating-point rounding mode in libc, since they do
> not have an fpu_control.h header with the functionality needed for
> sysdeps/generic/get-rounding-mode.h to work.  There are various examples
> checked in; it's likely that something similar to
> sysdeps/s390/fpu/get-rounding-mode.h, closely following the implementation
> of fegetround, is appropriate.

Noted. Thanks for the pointer.

Cheers,
Carlos.

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

* Re: alpha, ia64, hppa ports need get-rounding-mode.h
  2012-09-12 23:39 alpha, ia64, hppa ports need get-rounding-mode.h Joseph S. Myers
  2012-09-13  2:51 ` Carlos O'Donell
@ 2012-09-13 14:37 ` Richard Henderson
  2012-09-24 23:23 ` [PATCH] ia64: define new get-rounding-mode.h header Mike Frysinger
  2 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2012-09-13 14:37 UTC (permalink / raw)
  To: libc-ports

[-- Attachment #1: Type: text/plain, Size: 130 bytes --]

On 09/12/2012 04:39 PM, Joseph S. Myers wrote:
> the alpha, ia64 and hppa ports need a get-rounding-mode.h header ...

Done.


r~

[-- Attachment #2: z --]
[-- Type: text/plain, Size: 1535 bytes --]

	* sysdeps/alpha/fpu/get-rounding-mode.h: New file.


diff --git a/ports/sysdeps/alpha/fpu/get-rounding-mode.h b/ports/sysdeps/alpha/fpu/get-rounding-mode.h
new file mode 100644
index 0000000..9d5b724
--- /dev/null
+++ b/ports/sysdeps/alpha/fpu/get-rounding-mode.h
@@ -0,0 +1,35 @@
+/* Determine floating-point rounding mode within libc.  Alpha version.
+   Copyright (C) 2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef ALPHA_GET_ROUNDING_MODE_H
+#define ALPHA_GET_ROUNDING_MODE_H	1
+
+#include <fenv.h>
+#include <fenv_libc.h>
+
+/* Return the floating-point rounding mode.  */
+
+static inline int
+get_rounding_mode (void)
+{
+  unsigned long fpcr;
+  __asm__ __volatile__("excb; mf_fpcr %0" : "=f"(fpcr));
+  return (fpcr >> FPCR_ROUND_SHIFT) & 3;
+}
+
+#endif /* get-rounding-mode.h */

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

* [PATCH] ia64: define new get-rounding-mode.h header
  2012-09-12 23:39 alpha, ia64, hppa ports need get-rounding-mode.h Joseph S. Myers
  2012-09-13  2:51 ` Carlos O'Donell
  2012-09-13 14:37 ` Richard Henderson
@ 2012-09-24 23:23 ` Mike Frysinger
  2 siblings, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2012-09-24 23:23 UTC (permalink / raw)
  To: libc-ports

The new strtod function wants rounding information from the C lib, so
move the guts of the ia64 version into a header file for it to use.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 ports/ChangeLog.ia64                       |  6 +++++
 ports/sysdeps/ia64/fpu/fegetround.c        | 10 +++-----
 ports/sysdeps/ia64/fpu/get-rounding-mode.h | 37 ++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 7 deletions(-)
 create mode 100644 ports/sysdeps/ia64/fpu/get-rounding-mode.h

diff --git a/ports/ChangeLog.ia64 b/ports/ChangeLog.ia64
index 3566b37..39ec5ff 100644
--- a/ports/ChangeLog.ia64
+++ b/ports/ChangeLog.ia64
@@ -1,5 +1,11 @@
 2012-09-24  Mike Frysinger  <vapier@gentoo.org>
 
+	* ports/sysdeps/ia64/fpu/fegetround.c (fegetround): Move contents
+	of function to ...
+	* ports/sysdeps/ia64/fpu/get-rounding-mode.h: ... here.
+
+2012-09-24  Mike Frysinger  <vapier@gentoo.org>
+
 	* sysdeps/ia64/Makeconfig: New file.
 
 2012-08-16  Carlos O'Donell  <carlos_odonell@mentor.com>
diff --git a/ports/sysdeps/ia64/fpu/fegetround.c b/ports/sysdeps/ia64/fpu/fegetround.c
index e672f61..403aadb 100644
--- a/ports/sysdeps/ia64/fpu/fegetround.c
+++ b/ports/sysdeps/ia64/fpu/fegetround.c
@@ -1,5 +1,5 @@
 /* Return current rounding direction.
-   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1999-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Christian Boissat <Christian.Boissat@cern.ch>, 1999.
 
@@ -17,14 +17,10 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <fenv.h>
+#include <get-rounding-mode.h>
 
 int
 fegetround (void)
 {
-  fenv_t fpsr;
-
-  __asm__ __volatile__ ("mov.m %0=ar.fpsr" : "=r" (fpsr));
-
-  return (fpsr >> 10) & 3;
+  return get_rounding_mode ();
 }
diff --git a/ports/sysdeps/ia64/fpu/get-rounding-mode.h b/ports/sysdeps/ia64/fpu/get-rounding-mode.h
new file mode 100644
index 0000000..1e18473
--- /dev/null
+++ b/ports/sysdeps/ia64/fpu/get-rounding-mode.h
@@ -0,0 +1,37 @@
+/* Return current rounding direction within libc.  IA64 version.
+   Copyright (C) 1999-2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Christian Boissat <Christian.Boissat@cern.ch>, 1999.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef IA64_GET_ROUNDING_MODE_H
+#define IA64_GET_ROUNDING_MODE_H	1
+
+#include <fenv.h>
+
+/* Return the floating-point rounding mode.  */
+
+static inline int
+get_rounding_mode (void)
+{
+  fenv_t fpsr;
+
+  __asm__ __volatile__ ("mov.m %0=ar.fpsr" : "=r" (fpsr));
+
+  return (fpsr >> 10) & 3;
+}
+
+#endif /* get-rounding-mode.h */
-- 
1.7.12

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

end of thread, other threads:[~2012-09-24 23:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-12 23:39 alpha, ia64, hppa ports need get-rounding-mode.h Joseph S. Myers
2012-09-13  2:51 ` Carlos O'Donell
2012-09-13 14:37 ` Richard Henderson
2012-09-24 23:23 ` [PATCH] ia64: define new get-rounding-mode.h header Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).