Require GLIBC 2.32 for Decimal/_Float128 conversions.
In the patch that I applied on March 2nd, I had code to provide support for Decimal/_Float128 conversions if the user did not use at least GLIBC 2.32. It did this by using __ibm128 as an intermediate type. The trouble is __ibm128 cannot represent all of the numbers that _Float128 can, and you lose if you do this conversion. This patch removes this support. The dfp-bit.c functions now call the the __sprintfieee128 and __strtoieee128 functions to do the conversion. If the user does not have GLIBC, they will get a linker error that these functions do not exist. The float128 support functions are only built into the static libgcc, so there isn't an issue with having references to __strtoieee128 and __sprintfieee128 with older GLIBC libraries. As an added bonus, this patch eliminates the __sprintfkf function which included stdio.h to get a definition for the sprintf library function. This allows for building cross compilers without having to have a target stdio.h available. libgcc/ 2021-03-29 Michael Meissner <meissner@linux.ibm.com> * config/rs6000/t-float128 (fp128_decstr_funcs): Delete. (fp128_ppc_funcs): Do not add $(fp128_decstr_funcs). (fp128_decstr_objs): Delete. * dfp-bit.h: Call __sprintfieee128 to do conversions from _Float128 to a Decimal type. Call __strtoieee128 to do conversions from a Decimal type to _Float128. * config/rs6000/_sprintfkf.c: Delete file. * config/rs6000/_sprintfkf.h: Delete file. * config/rs6000/_strtokf.c: Delete file. * config/rs6000/_strtokf.h: Delete file.
This commit is contained in:
parent
77093a75ca
commit
645bfc1619
6 changed files with 5 additions and 181 deletions
|
@ -1,58 +0,0 @@
|
|||
/* Copyright (C) 1989-2021 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 3, 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.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Conversion to IEEE 128-bit floating point from string using snprintf. */
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <soft-fp.h>
|
||||
#include <quad-float128.h>
|
||||
#include <stdio.h>
|
||||
#include <_sprintfkf.h>
|
||||
|
||||
/* This function must be built with IBM 128-bit as long double, so that we can
|
||||
access the strfroml function if do not have an IEEE 128-bit version, and if
|
||||
that is not available, use sprintf. */
|
||||
#if !defined(__LONG_DOUBLE_128__) || !defined(__LONG_DOUBLE_IBM128__)
|
||||
#error "Long double is not IBM 128-bit"
|
||||
#endif
|
||||
|
||||
/* If the user is using GLIBC 2.32, we can use the __snprintfieee128 function.
|
||||
|
||||
If we are linked against an earlier library, we will have fake it by
|
||||
converting the value to long double, and using sprintf to do the conversion.
|
||||
This isn't ideal, as IEEE 128-bit has more exponent range than IBM
|
||||
128-bit. */
|
||||
|
||||
extern int __sprintfieee128 (char *restrict, const char *restrict, ...)
|
||||
__attribute__ ((__weak__));
|
||||
|
||||
int __sprintfkf (char *restrict string,
|
||||
const char *restrict format,
|
||||
_Float128 number)
|
||||
{
|
||||
if (__sprintfieee128)
|
||||
return __sprintfieee128 (string, format, number);
|
||||
|
||||
return sprintf (string, format, (long double) number);
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/* Copyright (C) 1989-2021 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 3, 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.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Declaration of the conversion function to IEEE 128-bit floating point from
|
||||
string using snprintf. */
|
||||
|
||||
extern int __sprintfkf (char *restrict, const char *restrict, _Float128);
|
|
@ -1,53 +0,0 @@
|
|||
/* Copyright (C) 1989-2021 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 3, 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.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Conversion to IEEE 128-bit floating point from string. */
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <soft-fp.h>
|
||||
#include <quad-float128.h>
|
||||
|
||||
/* This function must be built with IBM 128-bit as long double, so that we can
|
||||
access the strtold function if do not have an IEEE 128-bit version. */
|
||||
#if !defined(__LONG_DOUBLE_128__) || !defined(__LONG_DOUBLE_IBM128__)
|
||||
#error "Long double is not IBM 128-bit"
|
||||
#endif
|
||||
|
||||
/* If the user is using GLIBC 2.32, we can use the __strtoieee128 function.
|
||||
|
||||
If we are linked against an earlier library, we will have fake it by
|
||||
converting the string to IBM 128-bit long double, and then converting that to
|
||||
__float128. This isn't ideal, as IEEE 128-bit has more exponent range than
|
||||
IBM 128-bit. */
|
||||
|
||||
extern _Float128 __strtoieee128 (const char *, char **) __attribute__ ((__weak__));
|
||||
|
||||
_Float128
|
||||
__strtokf (const char *string, char **endptr)
|
||||
{
|
||||
if (__strtoieee128)
|
||||
return __strtoieee128 (string, endptr);
|
||||
|
||||
return strtold (string, endptr);
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/* Copyright (C) 1989-2021 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 3, 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.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Declaration of the conversion function to IEEE 128-bit floating point from
|
||||
string. */
|
||||
|
||||
extern _Float128 __strtokf (const char *, char **);
|
|
@ -26,10 +26,6 @@ fp128_softfp_obj = $(fp128_softfp_static_obj) $(fp128_softfp_shared_obj)
|
|||
fp128_dec_funcs = _kf_to_sd _kf_to_dd _kf_to_td \
|
||||
_sd_to_kf _dd_to_kf _td_to_kf
|
||||
|
||||
# _Float128 to/from string conversions that must be compiled with IBM 128-bit
|
||||
# long double.
|
||||
fp128_decstr_funcs = _strtokf _sprintfkf
|
||||
|
||||
# Decimal <-> __ibm128 conversions
|
||||
ibm128_dec_funcs = _tf_to_sd _tf_to_dd _tf_to_td \
|
||||
_sd_to_tf _dd_to_tf _td_to_tf
|
||||
|
@ -38,7 +34,7 @@ ibm128_dec_funcs = _tf_to_sd _tf_to_dd _tf_to_td \
|
|||
fp128_ppc_funcs = floattikf floatuntikf fixkfti fixunskfti \
|
||||
extendkftf2-sw trunctfkf2-sw \
|
||||
sfp-exceptions _mulkc3 _divkc3 _powikf2 \
|
||||
$(fp128_dec_funcs) $(fp128_decstr_funcs)
|
||||
$(fp128_dec_funcs)
|
||||
|
||||
fp128_ppc_src = $(addprefix $(srcdir)/config/rs6000/,$(addsuffix \
|
||||
.c,$(fp128_ppc_funcs)))
|
||||
|
@ -88,9 +84,6 @@ $(fp128_obj) : $(srcdir)/config/rs6000/quad-float128.h
|
|||
fp128_dec_objs = $(addsuffix $(objext),$(fp128_dec_funcs)) \
|
||||
$(addsuffix _s$(objext),$(fp128_dec_funcs))
|
||||
|
||||
fp128_decstr_objs = $(addsuffix $(objext),$(fp128_decstr_funcs)) \
|
||||
$(addsuffix _s$(objext),$(fp128_decstr_funcs))
|
||||
|
||||
ibm128_dec_objs = $(addsuffix $(objext),$(ibm128_dec_funcs)) \
|
||||
$(addsuffix _s$(objext),$(ibm128_dec_funcs))
|
||||
|
||||
|
@ -98,12 +91,8 @@ FP128_CFLAGS_DECIMAL = -mno-gnu-attribute -Wno-psabi -mabi=ieeelongdouble
|
|||
IBM128_CFLAGS_DECIMAL = -mno-gnu-attribute -Wno-psabi -mabi=ibmlongdouble
|
||||
|
||||
$(fp128_dec_objs) : INTERNAL_CFLAGS += $(FP128_CFLAGS_DECIMAL)
|
||||
$(fp128_decstr_objs) : INTERNAL_CFLAGS += $(IBM128_CFLAGS_DECIMAL)
|
||||
$(ibm128_dec_objs) : INTERNAL_CFLAGS += $(IBM128_CFLAGS_DECIMAL)
|
||||
|
||||
$(fp128_decstr_objs) : $(srcdir)/config/rs6000/_strtokf.h \
|
||||
$(srcdir)/config/rs6000/_sprintfkf.h \
|
||||
|
||||
$(fp128_softfp_src) : $(srcdir)/soft-fp/$(subst -sw,,$(subst kf,tf,$@)) $(fp128_dep)
|
||||
@src="$(srcdir)/soft-fp/$(subst -sw,,$(subst kf,tf,$@))"; \
|
||||
echo "Create $@"; \
|
||||
|
|
|
@ -298,8 +298,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|||
#define BFP_TYPE _Float128
|
||||
#define BFP_FMT "%.36Le"
|
||||
#define BFP_VIA_TYPE _Float128
|
||||
#define STR_TO_BFP __strtokf
|
||||
#include <_strtokf.h>
|
||||
#define STR_TO_BFP __strtoieee128
|
||||
extern _Float128 __strtoieee128 (const char *, char **);
|
||||
|
||||
#endif /* BFP_KIND */
|
||||
|
||||
|
@ -647,8 +647,8 @@ extern DFP_C_TYPE BFP_TO_DFP (BFP_TYPE);
|
|||
|
||||
#elif defined (L_kf_to_sd) || defined (L_kf_to_dd) || defined (L_kf_to_td)
|
||||
extern DFP_C_TYPE BFP_TO_DFP (BFP_TYPE);
|
||||
#include <_sprintfkf.h>
|
||||
#define BFP_SPRINTF __sprintfkf
|
||||
extern int __sprintfieee128 (char *restrict, const char *restrict, ...);
|
||||
#define BFP_SPRINTF __sprintfieee128
|
||||
#endif
|
||||
|
||||
#endif /* _DFPBIT_H */
|
||||
|
|
Loading…
Add table
Reference in a new issue