1996-03-05 21:41:30 +00:00
|
|
|
/*
|
|
|
|
* ====================================================
|
|
|
|
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
|
|
* Permission to use, copy, modify, and distribute this
|
|
|
|
* software is freely granted, provided that this notice
|
|
|
|
* is preserved.
|
|
|
|
* ====================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* from: @(#)fdlibm.h 5.1 93/09/24
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MATH_PRIVATE_H_
|
|
|
|
#define _MATH_PRIVATE_H_
|
|
|
|
|
1999-07-14 00:54:57 +00:00
|
|
|
#include <endian.h>
|
2018-08-28 20:48:49 +00:00
|
|
|
#include <stdbool.h>
|
2009-08-25 01:05:48 +00:00
|
|
|
#include <stdint.h>
|
1996-03-05 21:41:30 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
2017-05-04 20:00:33 +00:00
|
|
|
/* Gather machine dependent _Floatn support. */
|
|
|
|
#include <bits/floatn.h>
|
|
|
|
|
1996-03-05 21:41:30 +00:00
|
|
|
/* The original fdlibm code used statements like:
|
|
|
|
n0 = ((*(int*)&one)>>29)^1; * index of high word *
|
|
|
|
ix0 = *(n0+(int*)&x); * high word of x *
|
|
|
|
ix1 = *((1-n0)+(int*)&x); * low word of x *
|
|
|
|
to dig two 32 bit words out of the 64 bit IEEE floating point
|
|
|
|
value. That is non-ANSI, and, moreover, the gcc instruction
|
|
|
|
scheduler gets it wrong. We instead use the following macros.
|
|
|
|
Unlike the original code, we determine the endianness at compile
|
|
|
|
time, not at run time; I don't see much benefit to selecting
|
|
|
|
endianness at run time. */
|
|
|
|
|
|
|
|
/* A union which permits us to convert between a double and two 32 bit
|
|
|
|
ints. */
|
|
|
|
|
2016-11-21 01:46:30 +00:00
|
|
|
#if __FLOAT_WORD_ORDER == __BIG_ENDIAN
|
1996-03-05 21:41:30 +00:00
|
|
|
|
|
|
|
typedef union
|
|
|
|
{
|
|
|
|
double value;
|
|
|
|
struct
|
|
|
|
{
|
2017-08-03 19:55:04 +00:00
|
|
|
uint32_t msw;
|
|
|
|
uint32_t lsw;
|
1996-03-05 21:41:30 +00:00
|
|
|
} parts;
|
2009-08-25 01:05:48 +00:00
|
|
|
uint64_t word;
|
1996-03-05 21:41:30 +00:00
|
|
|
} ieee_double_shape_type;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2016-11-21 01:46:30 +00:00
|
|
|
#if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN
|
1996-03-05 21:41:30 +00:00
|
|
|
|
|
|
|
typedef union
|
|
|
|
{
|
|
|
|
double value;
|
|
|
|
struct
|
|
|
|
{
|
2017-08-03 19:55:04 +00:00
|
|
|
uint32_t lsw;
|
|
|
|
uint32_t msw;
|
1996-03-05 21:41:30 +00:00
|
|
|
} parts;
|
2009-08-25 01:05:48 +00:00
|
|
|
uint64_t word;
|
1996-03-05 21:41:30 +00:00
|
|
|
} ieee_double_shape_type;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Get two 32 bit ints from a double. */
|
|
|
|
|
|
|
|
#define EXTRACT_WORDS(ix0,ix1,d) \
|
|
|
|
do { \
|
|
|
|
ieee_double_shape_type ew_u; \
|
|
|
|
ew_u.value = (d); \
|
|
|
|
(ix0) = ew_u.parts.msw; \
|
|
|
|
(ix1) = ew_u.parts.lsw; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
/* Get the more significant 32 bit int from a double. */
|
|
|
|
|
2012-03-09 20:38:23 +00:00
|
|
|
#ifndef GET_HIGH_WORD
|
|
|
|
# define GET_HIGH_WORD(i,d) \
|
1996-03-05 21:41:30 +00:00
|
|
|
do { \
|
|
|
|
ieee_double_shape_type gh_u; \
|
|
|
|
gh_u.value = (d); \
|
|
|
|
(i) = gh_u.parts.msw; \
|
|
|
|
} while (0)
|
2012-03-09 20:38:23 +00:00
|
|
|
#endif
|
1996-03-05 21:41:30 +00:00
|
|
|
|
|
|
|
/* Get the less significant 32 bit int from a double. */
|
|
|
|
|
2012-03-09 20:38:23 +00:00
|
|
|
#ifndef GET_LOW_WORD
|
|
|
|
# define GET_LOW_WORD(i,d) \
|
1996-03-05 21:41:30 +00:00
|
|
|
do { \
|
|
|
|
ieee_double_shape_type gl_u; \
|
|
|
|
gl_u.value = (d); \
|
|
|
|
(i) = gl_u.parts.lsw; \
|
|
|
|
} while (0)
|
2012-03-09 20:38:23 +00:00
|
|
|
#endif
|
1996-03-05 21:41:30 +00:00
|
|
|
|
2009-08-25 01:05:48 +00:00
|
|
|
/* Get all in one, efficient on 64-bit machines. */
|
2012-03-09 20:38:23 +00:00
|
|
|
#ifndef EXTRACT_WORDS64
|
|
|
|
# define EXTRACT_WORDS64(i,d) \
|
2009-08-25 01:05:48 +00:00
|
|
|
do { \
|
|
|
|
ieee_double_shape_type gh_u; \
|
|
|
|
gh_u.value = (d); \
|
|
|
|
(i) = gh_u.word; \
|
|
|
|
} while (0)
|
2012-03-09 20:38:23 +00:00
|
|
|
#endif
|
2009-08-25 01:05:48 +00:00
|
|
|
|
1996-03-05 21:41:30 +00:00
|
|
|
/* Set a double from two 32 bit ints. */
|
2012-03-09 20:38:23 +00:00
|
|
|
#ifndef INSERT_WORDS
|
|
|
|
# define INSERT_WORDS(d,ix0,ix1) \
|
1996-03-05 21:41:30 +00:00
|
|
|
do { \
|
|
|
|
ieee_double_shape_type iw_u; \
|
|
|
|
iw_u.parts.msw = (ix0); \
|
|
|
|
iw_u.parts.lsw = (ix1); \
|
|
|
|
(d) = iw_u.value; \
|
|
|
|
} while (0)
|
2012-03-09 20:38:23 +00:00
|
|
|
#endif
|
1996-03-05 21:41:30 +00:00
|
|
|
|
2009-08-25 01:05:48 +00:00
|
|
|
/* Get all in one, efficient on 64-bit machines. */
|
2012-03-09 20:38:23 +00:00
|
|
|
#ifndef INSERT_WORDS64
|
|
|
|
# define INSERT_WORDS64(d,i) \
|
2009-08-25 01:05:48 +00:00
|
|
|
do { \
|
|
|
|
ieee_double_shape_type iw_u; \
|
|
|
|
iw_u.word = (i); \
|
|
|
|
(d) = iw_u.value; \
|
|
|
|
} while (0)
|
2012-03-09 20:38:23 +00:00
|
|
|
#endif
|
2009-08-25 01:05:48 +00:00
|
|
|
|
1996-03-05 21:41:30 +00:00
|
|
|
/* Set the more significant 32 bits of a double from an int. */
|
2012-03-09 20:38:23 +00:00
|
|
|
#ifndef SET_HIGH_WORD
|
1996-03-05 21:41:30 +00:00
|
|
|
#define SET_HIGH_WORD(d,v) \
|
|
|
|
do { \
|
|
|
|
ieee_double_shape_type sh_u; \
|
|
|
|
sh_u.value = (d); \
|
|
|
|
sh_u.parts.msw = (v); \
|
|
|
|
(d) = sh_u.value; \
|
|
|
|
} while (0)
|
2012-03-09 20:38:23 +00:00
|
|
|
#endif
|
1996-03-05 21:41:30 +00:00
|
|
|
|
|
|
|
/* Set the less significant 32 bits of a double from an int. */
|
2012-03-09 20:38:23 +00:00
|
|
|
#ifndef SET_LOW_WORD
|
|
|
|
# define SET_LOW_WORD(d,v) \
|
1996-03-05 21:41:30 +00:00
|
|
|
do { \
|
|
|
|
ieee_double_shape_type sl_u; \
|
|
|
|
sl_u.value = (d); \
|
|
|
|
sl_u.parts.lsw = (v); \
|
|
|
|
(d) = sl_u.value; \
|
|
|
|
} while (0)
|
2012-03-09 20:38:23 +00:00
|
|
|
#endif
|
1996-03-05 21:41:30 +00:00
|
|
|
|
2017-05-04 17:47:27 +00:00
|
|
|
/* We need to guarantee an expansion of name when building
|
|
|
|
ldbl-128 files as another type (e.g _Float128). */
|
|
|
|
#define mathx_hidden_def(name) hidden_def(name)
|
|
|
|
|
1999-07-14 00:54:57 +00:00
|
|
|
/* Get long double macros from a separate header. */
|
|
|
|
#include <math_ldbl.h>
|
Thu May 30 11:24:05 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
* po/header.pot: Replace with exact boilerplate pinard dictates.
* sysdeps/i386/strtok.S (Lillegal_argument): Remove this code to set
errno and the check that jumped to it.
* sysdeps/mach/hurd/Makefile (errnos.d): Use $(sed-remove-objpfx).
Thu May 30 03:21:57 1996 Ulrich Drepper <drepper@cygnus.com>
* FAQ: Document need of gperf program for developers.
* elf/elf.h: Fix typos in comments.
* libio/stdio.h [!__STRICT_ANSI__ || _POSIX_SOURCE]: Add
prototypes for `ctermid' and `cuserid'.
* locale/programs/locale.c: Switch to user selected locale
before printing variables.
* math/Makefile [$(long-double-fcts)==yes]: Define long-m-routines
and long-c-routines. Only if the `long double' data type is
available we need to compile the functions.
(libm-routines): Add $(long-m-routines).
(routines): Remove isinfl, isnanl. Use new file s_isinfl and
s_isnanl instead if `long double' is available.
* math/math.h: Include <mathcalls.h> again to define `long double'
functions.
* math/math_private.h: Define data types, prototypes and access
macros for `long double'.
* stdlib/stdlib.h: Add prototypes for `strtoll' and `strtoull'.
[GCC2 && OPTIMIZE]: Define strto{,u}ll as inline function which
calls __strto{,u}q_internal.
* stdlib/strfmon.c: Replace PTR by `void *'.
* stdlib/strtoq.c: Define strtoll as weak alias.
* stdlib/strtouq.c: Define strtoull as weak alias.
* string/tester.c: Correct `strsep' test.
* sysdeps/generic/strsep.c: Make compatible with BSD version.
Trailing characters of skip set are not skipped. In this case
empty tokens are returned.
* sysdeps/i386/isinfl.c, sysdeps/i386/isnanl.c,
sysdeps/ieee754/isinf.c, sysdeps/ieee754/isinfl.c,
sysdeps/ieee754/isnan.c, sysdeps/ieee754/isnanl.c: Removed. We
now use the versions part of libm.
* sysdeps/i386/strsep.S: Removed. Generic C version is of
similar speed.
* sysdeps/i386/strtok.S: Remove support for `strsep'.
* sysdeps/libm-i387/e_acosl.S, sysdeps/libm-i387/s_ceill.S,
sysdeps/libm-i387/s_copysignl.S, sysdeps/libm-i387/s_finitel.S,
sysdeps/libm-i387/s_floorl.S, sysdeps/libm-i387/s_isinfl.c,
sysdeps/libm-i387/s_isnanl.c, sysdeps/libm-i387/s_nextafterl.c,
sysdeps/libm-i387/s_rintl.S, sysdeps/libm-i387/s_significandl.S:
New i387 specific math functions implementing `long double'
versions.
* sysdeps/libm-ieee754/s_ceill.c,
sysdeps/libm-ieee754/s_copysignl.c,
sysdeps/libm-ieee754/s_fabsl.c, sysdeps/libm-ieee754/s_finitel.c,
sysdeps/libm-ieee754/s_floorl.c, sysdeps/libm-ieee754/s_isinfl.c,
sysdeps/libm-ieee754/s_isnanl.c,
sysdeps/libm-ieee754/s_nextafterl.c,
sysdeps/libm-ieee754/s_rintl.c, sysdeps/libm-ieee754/s_scalbnl.c,
sysdeps/libm-ieee754/s_significandl.c: New generic `long double'
versions of libm functions.
* sysdeps/libm-i387/e_exp.S: Add a few comments to explain the
Intel FPU nonsense.
* sysdeps/libm-i387/s_ceil.S, sysdeps/libm-i387/s_ceilf.S,
sysdeps/libm-i387/s_floor.S, sysdeps/libm-i387/s_floorf.S: Correct
handling of local variables. The old version created a stack
frame but stored the values outside.
* sysdeps/libm-ieee754/s_isinf.c, sysdeps/libm-ieee754/s_isnan.c
[!NO_LONG_DOUBLE]: Define alias with `long double' versions name.
* login/pututline_r.c: Include sys/stat.h. Fix typos.
according to currently used locale for category LC_CTYPE by
inet_nsap_ntoa. Now in <arpa/inet.h>.
_IO_dup2 to contain complete parameter list.
1996-05-30 16:12:42 +00:00
|
|
|
|
2017-03-28 12:48:42 +00:00
|
|
|
/* Include function declarations for each floating-point. */
|
|
|
|
#define _Mdouble_ double
|
|
|
|
#define _MSUF_
|
|
|
|
#include <math_private_calls.h>
|
|
|
|
#undef _MSUF_
|
|
|
|
#undef _Mdouble_
|
|
|
|
|
|
|
|
#define _Mdouble_ float
|
|
|
|
#define _MSUF_ f
|
|
|
|
#define __MATH_DECLARING_FLOAT
|
|
|
|
#include <math_private_calls.h>
|
|
|
|
#undef __MATH_DECLARING_FLOAT
|
|
|
|
#undef _MSUF_
|
|
|
|
#undef _Mdouble_
|
|
|
|
|
|
|
|
#define _Mdouble_ long double
|
|
|
|
#define _MSUF_ l
|
|
|
|
#define __MATH_DECLARING_LONG_DOUBLE
|
|
|
|
#include <math_private_calls.h>
|
|
|
|
#undef __MATH_DECLARING_LONG_DOUBLE
|
|
|
|
#undef _MSUF_
|
|
|
|
#undef _Mdouble_
|
1996-03-05 21:41:30 +00:00
|
|
|
|
2017-05-04 20:00:33 +00:00
|
|
|
#if __HAVE_DISTINCT_FLOAT128
|
|
|
|
# define _Mdouble_ _Float128
|
|
|
|
# define _MSUF_ f128
|
|
|
|
# define __MATH_DECLARING_FLOATN
|
|
|
|
# include <math_private_calls.h>
|
|
|
|
# undef __MATH_DECLARING_FLOATN
|
|
|
|
# undef _MSUF_
|
|
|
|
# undef _Mdouble_
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-05-12 20:15:01 +00:00
|
|
|
/* Prototypes for functions of the IBM Accurate Mathematical Library. */
|
|
|
|
extern double __sin (double __x);
|
|
|
|
extern double __cos (double __x);
|
|
|
|
extern int __branred (double __x, double *__a, double *__aa);
|
|
|
|
extern void __doasin (double __x, double __dx, double __v[]);
|
|
|
|
extern void __dubsin (double __x, double __dx, double __v[]);
|
|
|
|
extern void __dubcos (double __x, double __dx, double __v[]);
|
|
|
|
extern double __sin32 (double __x, double __res, double __res1);
|
|
|
|
extern double __cos32 (double __x, double __res, double __res1);
|
2013-10-08 06:20:17 +00:00
|
|
|
extern double __mpsin (double __x, double __dx, bool __range_reduce);
|
|
|
|
extern double __mpcos (double __x, double __dx, bool __range_reduce);
|
2001-05-12 20:15:01 +00:00
|
|
|
extern void __docos (double __x, double __dx, double __v[]);
|
|
|
|
|
1996-03-05 21:41:30 +00:00
|
|
|
#endif /* _MATH_PRIVATE_H_ */
|