Blame sysdeps/ieee754/flt-32/math_config.h

Packit 6c4009
/* Configuration for math routines.
Packit 6c4009
   Copyright (C) 2017-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 _MATH_CONFIG_H
Packit 6c4009
#define _MATH_CONFIG_H
Packit 6c4009
Packit 6c4009
#include <math.h>
Packit 6c4009
#include <math_private.h>
Packit 6c4009
#include <nan-high-order-bit.h>
Packit 6c4009
#include <stdint.h>
Packit 6c4009
Packit 6c4009
#ifndef WANT_ROUNDING
Packit 6c4009
/* Correct special case results in non-nearest rounding modes.  */
Packit 6c4009
# define WANT_ROUNDING 1
Packit 6c4009
#endif
Packit 6c4009
#ifndef WANT_ERRNO
Packit 6c4009
/* Set errno according to ISO C with (math_errhandling & MATH_ERRNO) != 0.  */
Packit 6c4009
# define WANT_ERRNO 1
Packit 6c4009
#endif
Packit 6c4009
#ifndef WANT_ERRNO_UFLOW
Packit 6c4009
/* Set errno to ERANGE if result underflows to 0 (in all rounding modes).  */
Packit 6c4009
# define WANT_ERRNO_UFLOW (WANT_ROUNDING && WANT_ERRNO)
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#ifndef TOINT_INTRINSICS
Packit 6c4009
# define TOINT_INTRINSICS 0
Packit 6c4009
#endif
Packit 6c4009
#ifndef TOINT_RINT
Packit 6c4009
# define TOINT_RINT 0
Packit 6c4009
#endif
Packit 6c4009
#ifndef TOINT_SHIFT
Packit 6c4009
# define TOINT_SHIFT 1
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
static inline uint32_t
Packit 6c4009
asuint (float f)
Packit 6c4009
{
Packit 6c4009
  union
Packit 6c4009
  {
Packit 6c4009
    float f;
Packit 6c4009
    uint32_t i;
Packit 6c4009
  } u = {f};
Packit 6c4009
  return u.i;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
static inline float
Packit 6c4009
asfloat (uint32_t i)
Packit 6c4009
{
Packit 6c4009
  union
Packit 6c4009
  {
Packit 6c4009
    uint32_t i;
Packit 6c4009
    float f;
Packit 6c4009
  } u = {i};
Packit 6c4009
  return u.f;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
static inline uint64_t
Packit 6c4009
asuint64 (double f)
Packit 6c4009
{
Packit 6c4009
  union
Packit 6c4009
  {
Packit 6c4009
    double f;
Packit 6c4009
    uint64_t i;
Packit 6c4009
  } u = {f};
Packit 6c4009
  return u.i;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
static inline double
Packit 6c4009
asdouble (uint64_t i)
Packit 6c4009
{
Packit 6c4009
  union
Packit 6c4009
  {
Packit 6c4009
    uint64_t i;
Packit 6c4009
    double f;
Packit 6c4009
  } u = {i};
Packit 6c4009
  return u.f;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
static inline int
Packit 6c4009
issignalingf_inline (float x)
Packit 6c4009
{
Packit 6c4009
  uint32_t ix = asuint (x);
Packit 6c4009
  if (HIGH_ORDER_BIT_IS_SET_FOR_SNAN)
Packit 6c4009
    return (ix & 0x7fc00000) == 0x7fc00000;
Packit 6c4009
  return 2 * (ix ^ 0x00400000) > 2u * 0x7fc00000;
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
#define NOINLINE __attribute__ ((noinline))
Packit 6c4009
Packit 6c4009
attribute_hidden float __math_oflowf (uint32_t);
Packit 6c4009
attribute_hidden float __math_uflowf (uint32_t);
Packit 6c4009
attribute_hidden float __math_may_uflowf (uint32_t);
Packit 6c4009
attribute_hidden float __math_divzerof (uint32_t);
Packit 6c4009
attribute_hidden float __math_invalidf (float);
Packit 6c4009
Packit 6c4009
/* Shared between expf, exp2f and powf.  */
Packit 6c4009
#define EXP2F_TABLE_BITS 5
Packit 6c4009
#define EXP2F_POLY_ORDER 3
Packit 6c4009
extern const struct exp2f_data
Packit 6c4009
{
Packit 6c4009
  uint64_t tab[1 << EXP2F_TABLE_BITS];
Packit 6c4009
  double shift_scaled;
Packit 6c4009
  double poly[EXP2F_POLY_ORDER];
Packit 6c4009
  double shift;
Packit 6c4009
  double invln2_scaled;
Packit 6c4009
  double poly_scaled[EXP2F_POLY_ORDER];
Packit 6c4009
} __exp2f_data attribute_hidden;
Packit 6c4009
Packit 6c4009
#define LOGF_TABLE_BITS 4
Packit 6c4009
#define LOGF_POLY_ORDER 4
Packit 6c4009
extern const struct logf_data
Packit 6c4009
{
Packit 6c4009
  struct
Packit 6c4009
  {
Packit 6c4009
    double invc, logc;
Packit 6c4009
  } tab[1 << LOGF_TABLE_BITS];
Packit 6c4009
  double ln2;
Packit 6c4009
  double poly[LOGF_POLY_ORDER - 1]; /* First order coefficient is 1.  */
Packit 6c4009
} __logf_data attribute_hidden;
Packit 6c4009
Packit 6c4009
#define LOG2F_TABLE_BITS 4
Packit 6c4009
#define LOG2F_POLY_ORDER 4
Packit 6c4009
extern const struct log2f_data
Packit 6c4009
{
Packit 6c4009
  struct
Packit 6c4009
  {
Packit 6c4009
    double invc, logc;
Packit 6c4009
  } tab[1 << LOG2F_TABLE_BITS];
Packit 6c4009
  double poly[LOG2F_POLY_ORDER];
Packit 6c4009
} __log2f_data attribute_hidden;
Packit 6c4009
Packit 6c4009
#define POWF_LOG2_TABLE_BITS 4
Packit 6c4009
#define POWF_LOG2_POLY_ORDER 5
Packit 6c4009
#if TOINT_INTRINSICS
Packit 6c4009
# define POWF_SCALE_BITS EXP2F_TABLE_BITS
Packit 6c4009
#else
Packit 6c4009
# define POWF_SCALE_BITS 0
Packit 6c4009
#endif
Packit 6c4009
#define POWF_SCALE ((double) (1 << POWF_SCALE_BITS))
Packit 6c4009
extern const struct powf_log2_data
Packit 6c4009
{
Packit 6c4009
  struct
Packit 6c4009
  {
Packit 6c4009
    double invc, logc;
Packit 6c4009
  } tab[1 << POWF_LOG2_TABLE_BITS];
Packit 6c4009
  double poly[POWF_LOG2_POLY_ORDER];
Packit 6c4009
} __powf_log2_data attribute_hidden;
Packit 6c4009
Packit 6c4009
#endif