diff options
author | janis <janis@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-09-11 01:11:16 +0000 |
---|---|---|
committer | janis <janis@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-09-11 01:11:16 +0000 |
commit | dfab6fc1cc8bcb98181f2304830c1f7ec6991a14 (patch) | |
tree | 200c6b2a83392535448b0fad1e529f6969081b6a /gcc/config/dfp-bit.c | |
parent | d20b198feed0219466ad6bb8cba7bdd64d6b7520 (diff) | |
download | gcc-dfab6fc1cc8bcb98181f2304830c1f7ec6991a14.tar.gz |
gcc/
PR c/30013
* config/dfp-bit.c: Don't skip TFmode conversions; move strto*
declarations to top.
(DFP_TO_BFP): Use for either XFmode or TFmode.
(BFP_TO_DFP): Use for either XFmode or TFmode; always use cast
of BFP_VIA_TYPE.
* config/dfp-bit.h: Include float.h.
(LONG_DOUBLE_HAS_XF_MODE, LONG_DOUBLE_HAS_TF_MODE): Define if long
double is one of these modes, rather than using LIBGCC_HAS_*F_MODE
which doesn't mean the same thing.
(BFP_KIND): Use 4 to mean TFmode.
(BFP_FMT): Specify the number of decimal digits based on the
number of mantissa digits.
(BFP_VIA_TYPE): Binary float type to use as cast for sprintf.
(BFP_TO_DFP, DFP_TO_BFP): Define names for TFmode variants.
(STR_TO_BFP): Use strtold for XFmode or TFmode.
(TFtype): Define if TFmode is supported.
* doc/libgcc.texi (Decimal float library routines): Document
TF conversion functions.
gcc/testsuite/
* gcc.dg/dfp/convert-bfp.c: Replace SKIP_LONG_DOUBLE with runtime
checks for size of long double.
* gcc.dg/dfp/convert.h: New file.
* gcc.dg/dfp/convert-bfp-2.c: New test.
* gcc.dg/dfp/convert-bfp-3.c: Ditto.
* gcc.dg/dfp/convert-bfp-4.c: Ditto.
* gcc.dg/dfp/convert-bfp-5.c: Ditto.
* gcc.dg/dfp/convert-bfp-6.c: Ditto.
* gcc.dg/dfp/convert-bfp-7.c: Ditto.
* gcc.dg/dfp/convert-bfp-8.c: Ditto.
* gcc.dg/dfp/convert-bfp-9.c: Ditto.
* gcc.dg/dfp/convert-bfp-10.c: Ditto.
* gcc.dg/dfp/convert-bfp-11.c: Ditto.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128361 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/dfp-bit.c')
-rw-r--r-- | gcc/config/dfp-bit.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/gcc/config/dfp-bit.c b/gcc/config/dfp-bit.c index 6a1bc30a21a..8ee4dec6f44 100644 --- a/gcc/config/dfp-bit.c +++ b/gcc/config/dfp-bit.c @@ -34,16 +34,11 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA Contributed by Ben Elliston <bje@au.ibm.com>. */ -/* The intended way to use this file is to make two copies, add `#define ' - to one copy, then compile both copies and add them to libgcc.a. */ - -/* FIXME: This implementation doesn't support TFmode conversions. */ -#if !(defined (L_sd_to_tf) || defined (L_dd_to_tf) \ - || defined (L_td_to_tf) || defined (L_tf_to_sd) \ - || defined (L_tf_to_dd) || defined (L_tf_to_td)) - #include <stdio.h> #include <stdlib.h> +/* FIXME: compile with -std=gnu99 to get these from stdlib.h */ +extern float strtof (const char *, char **); +extern long double strtold (const char *, char **); #include <string.h> #include <limits.h> @@ -471,7 +466,9 @@ INT_TO_DFP (INT_TYPE i) #if defined (L_sd_to_sf) || defined (L_dd_to_sf) || defined (L_td_to_sf) \ || defined (L_sd_to_df) || defined (L_dd_to_df) || defined (L_td_to_df) \ || ((defined (L_sd_to_xf) || defined (L_dd_to_xf) || defined (L_td_to_xf)) \ - && LIBGCC2_HAS_XF_MODE) + && LONG_DOUBLE_HAS_XF_MODE) \ + || ((defined (L_sd_to_tf) || defined (L_dd_to_tf) || defined (L_td_to_tf)) \ + && LONG_DOUBLE_HAS_TF_MODE) BFP_TYPE DFP_TO_BFP (DFP_C_TYPE f) { @@ -489,7 +486,9 @@ DFP_TO_BFP (DFP_C_TYPE f) #if defined (L_sf_to_sd) || defined (L_sf_to_dd) || defined (L_sf_to_td) \ || defined (L_df_to_sd) || defined (L_df_to_dd) || defined (L_df_to_td) \ || ((defined (L_xf_to_sd) || defined (L_xf_to_dd) || defined (L_xf_to_td)) \ - && LIBGCC2_HAS_XF_MODE) + && LONG_DOUBLE_HAS_XF_MODE) \ + || ((defined (L_tf_to_sd) || defined (L_tf_to_dd) || defined (L_tf_to_td)) \ + && LONG_DOUBLE_HAS_TF_MODE) DFP_C_TYPE BFP_TO_DFP (BFP_TYPE x) { @@ -502,12 +501,7 @@ BFP_TO_DFP (BFP_TYPE x) DFP_INIT_ROUNDMODE (context.round); /* Use a C library function to write the floating point value to a string. */ -#ifdef BFP_VIA_TYPE - /* FIXME: Is there a better way to output an XFmode variable in C? */ sprintf (buf, BFP_FMT, (BFP_VIA_TYPE) x); -#else - sprintf (buf, BFP_FMT, x); -#endif /* Convert from the floating point string to a decimal* type. */ FROM_STRING (&s, buf, &context); @@ -543,7 +537,3 @@ DFP_UNORD (DFP_C_TYPE arg_a, DFP_C_TYPE arg_b) return (decNumberIsNaN (&arg1) || decNumberIsNaN (&arg2)); } #endif /* L_unord_sd || L_unord_dd || L_unord_td */ - -/* !(L_sd_to_tf || L_dd_to_tf || L_td_to_tf \ - || L_tf_to_sd || L_tf_to_dd || L_tf_to_td) */ -#endif |