decRound.c: Move declarations to new file, update comments.
authorJanis Johnson <janis187@us.ibm.com>
Wed, 29 Nov 2006 18:34:56 +0000 (18:34 +0000)
committerJanis Johnson <janis@gcc.gnu.org>
Wed, 29 Nov 2006 18:34:56 +0000 (18:34 +0000)
libdecnumber/
* decRound.c: Move declarations to new file, update comments.
* decRound.h: New file.
gcc/
* mklibgcc.in: Fix dependencies for dfp-bit.c.
* config/dfp-bit.h (CONTEXT_ROUND): Delete.
(DFP_INIT_ROUNDMODE): Define.
* config/dfp-bit.c: Replace CONTEXT_ROUND with DFP_INIT_ROUNDMODE.

From-SVN: r119329

gcc/ChangeLog
gcc/config/dfp-bit.c
gcc/config/dfp-bit.h
gcc/mklibgcc.in
libdecnumber/ChangeLog
libdecnumber/decRound.c
libdecnumber/decRound.h [new file with mode: 0644]

index 5145756ff87348d986f6eaabbc72486be995d264..e80cb3c00fd8573e24418b70c7a54cf0c12fd139 100644 (file)
@@ -1,3 +1,10 @@
+2006-11-29  Janis Johnson  <janis187@us.ibm.com>
+
+       * config/dfp-bit.h (CONTEXT_ROUND): Delete.
+       (DFP_INIT_ROUNDMODE): Define.
+       * config/dfp-bit.c: Replace CONTEXT_ROUND with DFP_INIT_ROUNDMODE.
+       * mklibgcc.in: Fix dependencies for dfp-bit.c.
+
 2006-11-29  Tehila Meyzels  <tehila@il.ibm.com>
 
        * haifa-sched.c: Remove define LINE_NOTE(INSN).  Remove line_note_head.
index fc75a8bc604f800db3d8b5af997f6f96063410c2..9ffdd8a13f95a469306885761e631de1f6d2b737 100644 (file)
@@ -81,7 +81,7 @@ dfp_unary_op (dfp_unary_func op, DFP_C_TYPE arg)
   HOST_TO_IEEE (arg, &a);
 
   decContextDefault (&context, CONTEXT_INIT);
-  context.round = CONTEXT_ROUND;
+  DFP_INIT_ROUNDMODE (context.round);
 
   TO_INTERNAL (&a, &arg1);
 
@@ -107,7 +107,7 @@ dfp_binary_op (dfp_binary_func op, DFP_C_TYPE arg_a, DFP_C_TYPE arg_b)
   HOST_TO_IEEE (arg_b, &b);
 
   decContextDefault (&context, CONTEXT_INIT);
-  context.round = CONTEXT_ROUND;
+  DFP_INIT_ROUNDMODE (context.round);
 
   TO_INTERNAL (&a, &arg1);
   TO_INTERNAL (&b, &arg2);
@@ -134,7 +134,7 @@ dfp_compare_op (dfp_binary_func op, DFP_C_TYPE arg_a, DFP_C_TYPE arg_b)
   HOST_TO_IEEE (arg_b, &b);
 
   decContextDefault (&context, CONTEXT_INIT);
-  context.round = CONTEXT_ROUND;
+  DFP_INIT_ROUNDMODE (context.round);
 
   TO_INTERNAL (&a, &arg1);
   TO_INTERNAL (&b, &arg2);
@@ -365,7 +365,7 @@ DFP_TO_DFP (DFP_C_TYPE f_from)
   decContext context;
 
   decContextDefault (&context, CONTEXT_INIT);
-  context.round = CONTEXT_ROUND;
+  DFP_INIT_ROUNDMODE (context.round);
 
   HOST_TO_IEEE (f_from, &s_from);
   TO_INTERNAL (&s_from, &d);
@@ -394,7 +394,7 @@ DFP_TO_INT (DFP_C_TYPE x)
 
   decContextDefault (&context, CONTEXT_INIT);
   /* Need non-default rounding mode here.  */
-  context.round = DEC_ROUND_DOWN;
+  DFP_INIT_ROUNDMODE (context.round);
 
   HOST_TO_IEEE (x, &s);
   TO_INTERNAL (&s, &n1);
@@ -428,7 +428,7 @@ INT_TO_DFP (INT_TYPE i)
   decContext context;
 
   decContextDefault (&context, CONTEXT_INIT);
-  context.round = CONTEXT_ROUND;
+  DFP_INIT_ROUNDMODE (context.round);
 
   /* Use a C library function to get a floating point string.  */
   sprintf (buf, INT_FMT ".0", CAST_FOR_FMT(i));
@@ -470,7 +470,7 @@ BFP_TO_DFP (BFP_TYPE x)
   decContext context;
 
   decContextDefault (&context, CONTEXT_INIT);
-  context.round = CONTEXT_ROUND;
+  DFP_INIT_ROUNDMODE (context.round);
 
   /* Use a C library function to write the floating point value to a string.  */
 #ifdef BFP_VIA_TYPE
index dfad7d308b13efb56743b441111cb067cba7f7e9..e68f7df416b7885ee6c09da1a70f5d76e071c04a 100644 (file)
@@ -30,6 +30,8 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
 #ifndef _DFPBIT_H
 #define _DFPBIT_H
 
+#include <fenv.h>
+#include <decRound.h>
 #include "tconfig.h"
 #include "coretypes.h"
 #include "tm.h"
@@ -114,9 +116,9 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
 #define CONTEXT_INIT DEC_INIT_DECIMAL128
 #endif
 
-/* Define CONTEXT_ROUND to obtain the current decNumber rounding mode.  */
-extern enum rounding   __decGetRound (void);
-#define CONTEXT_ROUND  __decGetRound ()
+#ifndef DFP_INIT_ROUNDMODE
+#define DFP_INIT_ROUNDMODE(A) A = DEC_ROUND_HALF_EVEN
+#endif
 
 /* Conversions between different decimal float types use WIDTH_TO to
    determine additional macros to define.  */
index 60e390500ea03d3d5c30bdfa47409d6808bc28a6..8987ff9a2ade26bf22c70c6f88297461234d742b 100644 (file)
@@ -145,6 +145,9 @@ decnumber_dep='stmp-dirs $(srcdir)/../libdecnumber/decContext.h $(srcdir)/../lib
        $(srcdir)/../libdecnumber/decNumberLocal.h $(srcdir)/../libdecnumber/decimal32.h $(srcdir)/../libdecnumber/decimal64.h
        $(srcdir)/../libdecnumber/decimal128.h $(srcdir)/../libdecnumber/decDPD.h $(srcdir)/../libdecnumber/decUtility.h'
 
+# Dependencies for dfp-bit.c
+dfpbit_c_dep='$(srcdir)/../libdecnumber/decRound.h'" $libgcc_dep $decnumber_dep"
+
 # Flag whether we need eh_dummy.c
 need_eh_dummy=
 
@@ -456,7 +459,7 @@ for ml in $MULTILIBS; do
       if [ "$dpbit" ]; then
         for name in $dpfuncs; do
           out="libgcc/${dir}/${name}${objext}"
-         echo $out: config/dfp-bit.h config/dfp-bit.c $fpbit_c_dep
+         echo $out: config/dfp-bit.h config/dfp-bit.c $dfpbit_c_dep
          echo "        $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name -DWIDTH=$dpwidth \
              $DFP_CFLAGS -c $\(srcdir\)/config/dfp-bit.c -o $out
          echo $libgcc_a: $out
index 0068a92bfade1f69915cedc315dc84ea85bcf462..0994aee40e74b783364d182d795f5da4593fe4e3 100644 (file)
@@ -1,3 +1,8 @@
+2006-11-29  Janis Johnson  <janis187@us.ibm.com>
+
+       * decRound.c: Move declarations to new file, update comments.
+       * decRound.h: New file.
+
 2006-11-21  Janis Johnson  <janis187@us.ibm.com>
 
        * decLibrary.c (__dec_type_swap): Add prototype.
index 3a643f34af274bf4e401845f53db492be593340c..45c642f1c76d9bcd21e9f6bcb6f9713fa8161b6a 100644 (file)
@@ -1,5 +1,6 @@
-/* Temporary support for a libc-like fp environment for decimal float.
-   Copyright (C) 2005 Free Software Foundation, Inc.
+/* Internal testing support for rounding for decimal float.
+
+   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
 
    This file is part of GCC.
 
 
 #include "config.h"
 #include "decContext.h"
+#include "decRound.h"
+
+/* Internal, non-documented functions for testing libgcc functions.
+   This support is not sufficient for application use.  */
 
 #define FE_DEC_DOWNWARD 0
 #define FE_DEC_TONEAREST 1
 #define FE_DEC_UPWARD 4
 #define FE_DEC_MAX 5
 
-extern void __dfp_set_round (int);
-extern int __dfp_get_round (void);
-extern enum rounding __decGetRound (void);
-
-/* FIXME: these should be in thread-local storage for runtime support.  */
 static enum rounding __dfp_rounding_mode = DEC_ROUND_HALF_EVEN;
 
 /* Set the decNumber rounding mode from the FE_DEC_* value in MODE.  */ 
diff --git a/libdecnumber/decRound.h b/libdecnumber/decRound.h
new file mode 100644 (file)
index 0000000..2a708f8
--- /dev/null
@@ -0,0 +1,28 @@
+/* Internal testing support for rounding for decimal float.
+
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   GCC 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 General Public
+   License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING.  If not, write to the Free
+   Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+#include "decContext.h"
+
+#define DFP_INIT_ROUNDMODE(A)  A = __decGetRound()
+
+extern void __dfp_set_round (int);
+extern int __dfp_get_round (void);
+extern enum rounding __decGetRound (void);