Blame stdlib/fpioconst.h

Packit 6c4009
/* Header file for constants used in floating point <-> decimal conversions.
Packit 6c4009
   Copyright (C) 1995-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef _FPIOCONST_H
Packit 6c4009
#define	_FPIOCONST_H
Packit 6c4009
Packit 6c4009
#include <float.h>
Packit 6c4009
#include <math.h>
Packit 6c4009
#include <gmp.h>
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* These values are used by __printf_fp, where they are noncritical (if the
Packit 6c4009
   value is not large enough, it will just be slower); and by
Packit 6c4009
   strtof/strtod/strtold, where it is critical (it's used for overflow
Packit 6c4009
   detection).
Packit 6c4009
Packit 6c4009
   XXX These should be defined in <float.h>.  For the time being, we have the
Packit 6c4009
   IEEE754 values here.  */
Packit 6c4009
Packit 6c4009
#if !defined __NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__ > 1024
Packit 6c4009
# define LDBL_MAX_10_EXP_LOG	12 /* = floor(log_2(LDBL_MAX_10_EXP)) */
Packit 6c4009
#else
Packit 6c4009
# define LDBL_MAX_10_EXP_LOG	8 /* = floor(log_2(LDBL_MAX_10_EXP)) */
Packit 6c4009
#endif
Packit 6c4009
#define DBL_MAX_10_EXP_LOG	8 /* = floor(log_2(DBL_MAX_10_EXP)) */
Packit 6c4009
#define FLT_MAX_10_EXP_LOG	5 /* = floor(log_2(FLT_MAX_10_EXP)) */
Packit 6c4009
Packit 6c4009
/* On some machines, _Float128 may be ABI-distinct from long double (e.g
Packit 6c4009
   IBM extended precision).  */
Packit 6c4009
#include <bits/floatn.h>
Packit 6c4009
Packit 6c4009
#if __HAVE_DISTINCT_FLOAT128
Packit 6c4009
# define FLT128_MAX_10_EXP_LOG	12 /* = floor(log_2(FLT128_MAX_10_EXP)) */
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* For strtold, we need powers of 10 up to floor (log_2 (LDBL_MANT_DIG
Packit 6c4009
   - LDBL_MIN_EXP + 2)).  When _Float128 is enabled in libm and it is
Packit 6c4009
   ABI-distinct from long double (e.g. on powerpc64le), we also need powers
Packit 6c4009
   of 10 up to floor (log_2 (FLT128_MANT_DIG - FLT128_MIN_EXP + 2)).  */
Packit 6c4009
#define FPIOCONST_HAVE_EXTENDED_RANGE \
Packit 6c4009
  ((!defined __NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__ > 1024) \
Packit 6c4009
   || __HAVE_DISTINCT_FLOAT128)
Packit 6c4009
Packit 6c4009
#if FPIOCONST_HAVE_EXTENDED_RANGE
Packit 6c4009
# define FPIOCONST_POW10_ARRAY_SIZE	15
Packit 6c4009
#else
Packit 6c4009
# define FPIOCONST_POW10_ARRAY_SIZE	11
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* The array with the number representation. */
Packit 6c4009
extern const mp_limb_t __tens[] attribute_hidden;
Packit 6c4009
Packit 6c4009
/* Table of powers of ten.  This is used by __printf_fp and by
Packit 6c4009
   strtof/strtod/strtold.  */
Packit 6c4009
struct mp_power
Packit 6c4009
  {
Packit 6c4009
    size_t arrayoff;		/* Offset in `__tens'.  */
Packit 6c4009
    mp_size_t arraysize;	/* Size of the array.  */
Packit 6c4009
    int p_expo;			/* Exponent of the number 10^(2^i).  */
Packit 6c4009
    int m_expo;			/* Exponent of the number 10^-(2^i-1).  */
Packit 6c4009
  };
Packit 6c4009
extern const struct mp_power _fpioconst_pow10[FPIOCONST_POW10_ARRAY_SIZE]
Packit 6c4009
     attribute_hidden;
Packit 6c4009
Packit 6c4009
/* The constants in the array `_fpioconst_pow10' have an offset.  */
Packit 6c4009
#if BITS_PER_MP_LIMB == 32
Packit 6c4009
# define _FPIO_CONST_OFFSET	2
Packit 6c4009
#else
Packit 6c4009
# define _FPIO_CONST_OFFSET	1
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
#endif	/* fpioconst.h */