2
* This file has no copyright assigned and is placed in the Public Domain.
3
* This file is part of the w64 mingw-runtime package.
4
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
6
#ifndef _MINGWEX_FASTMATH_H_
7
#define _MINGWEX_FASTMATH_H_
10
No range or domain checks. No setting of errno. No tweaks to
11
protect precision near range limits. */
13
/* For now this is an internal header with just the functions that
14
are currently used in building libmingwex.a math components */
16
/* FIXME: We really should get rid of the code duplication using euther
17
C++ templates or tgmath-type macros. */
19
static __inline__ double __fast_sqrt (double x)
22
asm __volatile__ ("fsqrt" : "=t" (res) : "0" (x));
26
static __inline__ long double __fast_sqrtl (long double x)
29
asm __volatile__ ("fsqrt" : "=t" (res) : "0" (x));
33
static __inline__ float __fast_sqrtf (float x)
36
asm __volatile__ ("fsqrt" : "=t" (res) : "0" (x));
41
static __inline__ double __fast_log (double x)
48
: "=t" (res) : "0" (x) : "st(1)");
52
static __inline__ long double __fast_logl (long double x)
59
: "=t" (res) : "0" (x) : "st(1)");
64
static __inline__ float __fast_logf (float x)
71
: "=t" (res) : "0" (x) : "st(1)");
75
static __inline__ double __fast_log1p (double x)
78
/* fyl2xp1 accurate only for |x| <= 1.0 - 0.5 * sqrt (2.0) */
79
if (fabs (x) >= 1.0 - 0.5 * 1.41421356237309504880)
80
res = __fast_log (1.0 + x);
86
: "=t" (res) : "0" (x) : "st(1)");
90
static __inline__ long double __fast_log1pl (long double x)
93
/* fyl2xp1 accurate only for |x| <= 1.0 - 0.5 * sqrt (2.0) */
94
if (fabsl (x) >= 1.0L - 0.5L * 1.41421356237309504880L)
95
res = __fast_logl (1.0L + x);
101
: "=t" (res) : "0" (x) : "st(1)");
105
static __inline__ float __fast_log1pf (float x)
108
/* fyl2xp1 accurate only for |x| <= 1.0 - 0.5 * sqrt (2.0) */
109
if (fabsf (x) >= 1.0 - 0.5 * 1.41421356237309504880)
110
res = __fast_logf (1.0 + x);
116
: "=t" (res) : "0" (x) : "st(1)");
2
* This file has no copyright assigned and is placed in the Public Domain.
3
* This file is part of the w64 mingw-runtime package.
4
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
6
#ifndef _MINGWEX_FASTMATH_H_
7
#define _MINGWEX_FASTMATH_H_
10
No range or domain checks. No setting of errno. No tweaks to
11
protect precision near range limits. */
13
/* For now this is an internal header with just the functions that
14
are currently used in building libmingwex.a math components */
16
/* FIXME: We really should get rid of the code duplication using euther
17
C++ templates or tgmath-type macros. */
19
static __inline__ double __fast_sqrt (double x)
22
asm __volatile__ ("fsqrt" : "=t" (res) : "0" (x));
26
static __inline__ long double __fast_sqrtl (long double x)
29
asm __volatile__ ("fsqrt" : "=t" (res) : "0" (x));
33
static __inline__ float __fast_sqrtf (float x)
36
asm __volatile__ ("fsqrt" : "=t" (res) : "0" (x));
41
static __inline__ double __fast_log (double x)
48
: "=t" (res) : "0" (x) : "st(1)");
52
static __inline__ long double __fast_logl (long double x)
59
: "=t" (res) : "0" (x) : "st(1)");
64
static __inline__ float __fast_logf (float x)
71
: "=t" (res) : "0" (x) : "st(1)");
75
static __inline__ double __fast_log1p (double x)
78
/* fyl2xp1 accurate only for |x| <= 1.0 - 0.5 * sqrt (2.0) */
79
if (fabs (x) >= 1.0 - 0.5 * 1.41421356237309504880)
80
res = __fast_log (1.0 + x);
86
: "=t" (res) : "0" (x) : "st(1)");
90
static __inline__ long double __fast_log1pl (long double x)
93
/* fyl2xp1 accurate only for |x| <= 1.0 - 0.5 * sqrt (2.0) */
94
if (fabsl (x) >= 1.0L - 0.5L * 1.41421356237309504880L)
95
res = __fast_logl (1.0L + x);
101
: "=t" (res) : "0" (x) : "st(1)");
105
static __inline__ float __fast_log1pf (float x)
108
/* fyl2xp1 accurate only for |x| <= 1.0 - 0.5 * sqrt (2.0) */
109
if (fabsf (x) >= 1.0 - 0.5 * 1.41421356237309504880)
110
res = __fast_logf (1.0 + x);
116
: "=t" (res) : "0" (x) : "st(1)");