mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
float128: Add conversion from float128 to mpn
Reuse the code for __mpn_extract_long_double to implement __mpn_extract_float128. * include/gmp.h: Include bits/floatn.h (__mpn_extract_float128): Declare when __HAVE_DISTINCT_FLOAT128 is 1. * stdlib/gmp-impl.h: Also check if alloca is not defined before including stack-alloc.h. It could have been defined by other header which not necessarily defines HAVE_ALLOCA. * sysdeps/ieee754/float128/Makefile: New file. * sysdeps/ieee754/float128/float1282mpn.c: New file. * sysdeps/ieee754/float128/float128_private.h: Include gmp.h before redefining __mpn_extract_long_double to __mpn_extract_float128, then redefine __mpn_extract_long_double to __mpn_extract_float128. * sysdeps/ieee754/ldbl-128/ldbl2mpn.c: Replace long double with _Float128 to allow float128_private.h overrides.
This commit is contained in:
15
ChangeLog
15
ChangeLog
@ -1,3 +1,18 @@
|
|||||||
|
2017-06-07 Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com>
|
||||||
|
|
||||||
|
* include/gmp.h: Include bits/floatn.h
|
||||||
|
(__mpn_extract_float128): Declare when __HAVE_DISTINCT_FLOAT128 is 1.
|
||||||
|
* stdlib/gmp-impl.h: Also check if alloca is not defined before
|
||||||
|
including stack-alloc.h. It could have been defined by other header
|
||||||
|
which not necessarily defines HAVE_ALLOCA.
|
||||||
|
* sysdeps/ieee754/float128/Makefile: New file.
|
||||||
|
* sysdeps/ieee754/float128/float1282mpn.c: New file.
|
||||||
|
* sysdeps/ieee754/float128/float128_private.h: Include gmp.h before
|
||||||
|
redefining __mpn_extract_long_double to __mpn_extract_float128, then
|
||||||
|
redefine __mpn_extract_long_double to __mpn_extract_float128.
|
||||||
|
* sysdeps/ieee754/ldbl-128/ldbl2mpn.c: Replace long double with
|
||||||
|
_Float128 to allow float128_private.h overrides.
|
||||||
|
|
||||||
2017-06-07 Paul E. Murphy <murphyp@linux.vnet.ibm.com>
|
2017-06-07 Paul E. Murphy <murphyp@linux.vnet.ibm.com>
|
||||||
|
|
||||||
* stdlib/fpioconst.h: Include bits/floatn.h.
|
* stdlib/fpioconst.h: Include bits/floatn.h.
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#include <stdlib/gmp.h>
|
#include <stdlib/gmp.h>
|
||||||
|
|
||||||
|
#include <bits/floatn.h>
|
||||||
|
|
||||||
/* Now define the internal interfaces. */
|
/* Now define the internal interfaces. */
|
||||||
extern mp_size_t __mpn_extract_double (mp_ptr res_ptr, mp_size_t size,
|
extern mp_size_t __mpn_extract_double (mp_ptr res_ptr, mp_size_t size,
|
||||||
int *expt, int *is_neg,
|
int *expt, int *is_neg,
|
||||||
@ -15,6 +17,12 @@ extern mp_size_t __mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
|
|||||||
int *expt, int *is_neg,
|
int *expt, int *is_neg,
|
||||||
long double value);
|
long double value);
|
||||||
|
|
||||||
|
#if __HAVE_DISTINCT_FLOAT128
|
||||||
|
extern mp_size_t __mpn_extract_float128 (mp_ptr res_ptr, mp_size_t size,
|
||||||
|
int *expt, int *is_neg,
|
||||||
|
_Float128 value);
|
||||||
|
#endif
|
||||||
|
|
||||||
extern float __mpn_construct_float (mp_srcptr frac_ptr, int expt, int sign);
|
extern float __mpn_construct_float (mp_srcptr frac_ptr, int expt, int sign);
|
||||||
|
|
||||||
extern double __mpn_construct_double (mp_srcptr frac_ptr, int expt,
|
extern double __mpn_construct_double (mp_srcptr frac_ptr, int expt,
|
||||||
|
@ -47,7 +47,8 @@ along with the GNU MP Library; see the file COPYING.LIB. If not, see
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ! defined (HAVE_ALLOCA) || defined (USE_STACK_ALLOC)
|
#if (! defined (alloca) && ! defined (HAVE_ALLOCA)) \
|
||||||
|
|| defined (USE_STACK_ALLOC)
|
||||||
#include "stack-alloc.h"
|
#include "stack-alloc.h"
|
||||||
#else
|
#else
|
||||||
#define TMP_DECL(m)
|
#define TMP_DECL(m)
|
||||||
|
3
sysdeps/ieee754/float128/Makefile
Normal file
3
sysdeps/ieee754/float128/Makefile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
ifeq ($(subdir),stdlib)
|
||||||
|
routines += float1282mpn
|
||||||
|
endif
|
20
sysdeps/ieee754/float128/float1282mpn.c
Normal file
20
sysdeps/ieee754/float128/float1282mpn.c
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/* Convert a _Float128 type to multiprecision.
|
||||||
|
Copyright (C) 2017 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/>. */
|
||||||
|
|
||||||
|
#include <float128_private.h>
|
||||||
|
#include "../ldbl-128/ldbl2mpn.c"
|
@ -17,6 +17,7 @@
|
|||||||
<http://www.gnu.org/licenses/>. */
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
/* This must be included before the function renames below. */
|
/* This must be included before the function renames below. */
|
||||||
|
#include <gmp.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#undef HUGE_VALL
|
#undef HUGE_VALL
|
||||||
#define HUGE_VALL HUGE_VAL_F128
|
#define HUGE_VALL HUGE_VAL_F128
|
||||||
@ -291,6 +292,7 @@
|
|||||||
#define __kernel_tanl __kernel_tanf128
|
#define __kernel_tanl __kernel_tanf128
|
||||||
#define __lgamma_negl __lgamma_negf128
|
#define __lgamma_negl __lgamma_negf128
|
||||||
#define __lgamma_productl __lgamma_productf128
|
#define __lgamma_productl __lgamma_productf128
|
||||||
|
#define __mpn_extract_long_double __mpn_extract_float128
|
||||||
#define __sincosl_table __sincosf128_table
|
#define __sincosl_table __sincosf128_table
|
||||||
#define mul_splitl mul_splitf128
|
#define mul_splitl mul_splitf128
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <ieee754.h>
|
#include <ieee754.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <math_private.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
/* Convert a `long double' in IEEE854 quad-precision format to a
|
/* Convert a `long double' in IEEE854 quad-precision format to a
|
||||||
@ -31,7 +32,7 @@
|
|||||||
mp_size_t
|
mp_size_t
|
||||||
__mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
|
__mpn_extract_long_double (mp_ptr res_ptr, mp_size_t size,
|
||||||
int *expt, int *is_neg,
|
int *expt, int *is_neg,
|
||||||
long double value)
|
_Float128 value)
|
||||||
{
|
{
|
||||||
union ieee854_long_double u;
|
union ieee854_long_double u;
|
||||||
u.d = value;
|
u.d = value;
|
||||||
|
Reference in New Issue
Block a user