+2010-08-29 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
+ * m4/mtype.m4 (upcase, hasmathfunc, mathfunc_macro): New macros.
+ * m4/fraction.m4: Use new macros to support quad-float types.
+ * m4/set_exponent.m4: Likewise.
+ * m4/spacing.m4: Likewise.
+ * m4/exponent.m4: Likewise.
+ * m4/nearest.m4: Likewise.
+ * m4/norm2.m4: Likewise.
+ * m4/bessel.m4: Likewise.
+ * m4/rrspacing.m4: Likewise.
+ * generated/bessel_r4.c:Regenerated.
+ * generated/bessel_r8.c: Regenerated.
+ * generated/bessel_r10.c: Regenerated.
+ * generated/bessel_r16.c: Regenerated.
+ * generated/exponent_r4.c: Regenerated.
+ * generated/exponent_r8.c: Regenerated.
+ * generated/exponent_r10.c: Regenerated.
+ * generated/exponent_r16.c: Regenerated.
+ * generated/fraction_r4.c: Regenerated.
+ * generated/fraction_r8.c: Regenerated.
+ * generated/fraction_r10.c: Regenerated.
+ * generated/fraction_r16.c: Regenerated.
+ * generated/nearest_r4.c: Regenerated.
+ * generated/nearest_r8.c: Regenerated.
+ * generated/nearest_r10.c: Regenerated.
+ * generated/nearest_r16.c: Regenerated.
+ * generated/norm2_r4.c: Regenerated.
+ * generated/norm2_r8.c: Regenerated.
+ * generated/norm2_r10.c: Regenerated.
+ * generated/norm2_r16.c: Regenerated.
+ * generated/rrspacing_r4.c: Regenerated.
+ * generated/rrspacing_r8.c: Regenerated.
+ * generated/rrspacing_r10.c: Regenerated.
+ * generated/rrspacing_r16.c: Regenerated.
+ * generated/set_exponent_r4.c: Regenerated.
+ * generated/set_exponent_r8.c: Regenerated.
+ * generated/set_exponent_r10.c: Regenerated.
+ * generated/set_exponent_r16.c: Regenerated.
+ * generated/spacing_r4.c: Regenerated.
+ * generated/spacing_r8.c: Regenerated.
+ * generated/spacing_r10.c: Regenerated.
+ * generated/spacing_r16.c: Regenerated.
+
2010-08-28 Tobias Burnus <burnus@net-b.de>
* mk-kinds-h.sh: Disable REAL(16) if REAL(10) is available.
#include <assert.h>
+
+#define MATHFUNC(funcname) funcname ## l
+
#if defined (HAVE_GFC_REAL_10)
stride = GFC_DESCRIPTOR_STRIDE(ret,0);
- if (unlikely (x == 0.0L))
+ if (unlikely (x == 0))
{
- ret->data[0] = 1.0L;
+ ret->data[0] = 1;
for (i = 1; i <= n2-n1; i++)
- ret->data[i*stride] = 0.0L;
+ ret->data[i*stride] = 0;
return;
}
ret->data = ret->data;
- last1 = jnl (n2, x);
+ last1 = MATHFUNC(jn) (n2, x);
ret->data[(n2-n1)*stride] = last1;
if (n1 == n2)
return;
- last2 = jnl (n2 - 1, x);
+ last2 = MATHFUNC(jn) (n2 - 1, x);
ret->data[(n2-n1-1)*stride] = last2;
if (n1 + 1 == n2)
return;
- x2rev = 2.0L/x;
+ x2rev = GFC_REAL_10_LITERAL(2.)/x;
for (i = n2-n1-2; i >= 0; i--)
{
stride = GFC_DESCRIPTOR_STRIDE(ret,0);
- if (unlikely (x == 0.0L))
+ if (unlikely (x == 0))
{
for (i = 0; i <= n2-n1; i++)
#if defined(GFC_REAL_10_INFINITY)
}
ret->data = ret->data;
- last1 = ynl (n1, x);
+ last1 = MATHFUNC(yn) (n1, x);
ret->data[0] = last1;
if (n1 == n2)
return;
- last2 = ynl (n1 + 1, x);
+ last2 = MATHFUNC(yn) (n1 + 1, x);
ret->data[1*stride] = last2;
if (n1 + 1 == n2)
return;
- x2rev = 2.0L/x;
+ x2rev = GFC_REAL_10_LITERAL(2.)/x;
for (i = 2; i <= n1+n2; i++)
{
#include <assert.h>
+
+#if defined(GFC_REAL_16_IS_FLOAT128)
+#define MATHFUNC(funcname) funcname ## q
+#else
+#define MATHFUNC(funcname) funcname ## l
+#endif
+
#if defined (HAVE_GFC_REAL_16)
-#if defined (HAVE_JNL)
+#if (defined(GFC_WITH_QUAD_LIB) || defined(HAVE_JNL))
extern void bessel_jn_r16 (gfc_array_r16 * const restrict ret, int n1,
int n2, GFC_REAL_16 x);
export_proto(bessel_jn_r16);
stride = GFC_DESCRIPTOR_STRIDE(ret,0);
- if (unlikely (x == 0.0L))
+ if (unlikely (x == 0))
{
- ret->data[0] = 1.0L;
+ ret->data[0] = 1;
for (i = 1; i <= n2-n1; i++)
- ret->data[i*stride] = 0.0L;
+ ret->data[i*stride] = 0;
return;
}
ret->data = ret->data;
- last1 = jnl (n2, x);
+ last1 = MATHFUNC(jn) (n2, x);
ret->data[(n2-n1)*stride] = last1;
if (n1 == n2)
return;
- last2 = jnl (n2 - 1, x);
+ last2 = MATHFUNC(jn) (n2 - 1, x);
ret->data[(n2-n1-1)*stride] = last2;
if (n1 + 1 == n2)
return;
- x2rev = 2.0L/x;
+ x2rev = GFC_REAL_16_LITERAL(2.)/x;
for (i = n2-n1-2; i >= 0; i--)
{
#endif
-#if defined (HAVE_YNL)
+#if (defined(GFC_WITH_QUAD_LIB) || defined(HAVE_YNL))
extern void bessel_yn_r16 (gfc_array_r16 * const restrict ret,
int n1, int n2, GFC_REAL_16 x);
export_proto(bessel_yn_r16);
stride = GFC_DESCRIPTOR_STRIDE(ret,0);
- if (unlikely (x == 0.0L))
+ if (unlikely (x == 0))
{
for (i = 0; i <= n2-n1; i++)
#if defined(GFC_REAL_16_INFINITY)
}
ret->data = ret->data;
- last1 = ynl (n1, x);
+ last1 = MATHFUNC(yn) (n1, x);
ret->data[0] = last1;
if (n1 == n2)
return;
- last2 = ynl (n1 + 1, x);
+ last2 = MATHFUNC(yn) (n1 + 1, x);
ret->data[1*stride] = last2;
if (n1 + 1 == n2)
return;
- x2rev = 2.0L/x;
+ x2rev = GFC_REAL_16_LITERAL(2.)/x;
for (i = 2; i <= n1+n2; i++)
{
#include <assert.h>
+
+#define MATHFUNC(funcname) funcname ## f
+
#if defined (HAVE_GFC_REAL_4)
stride = GFC_DESCRIPTOR_STRIDE(ret,0);
- if (unlikely (x == 0.0F))
+ if (unlikely (x == 0))
{
- ret->data[0] = 1.0F;
+ ret->data[0] = 1;
for (i = 1; i <= n2-n1; i++)
- ret->data[i*stride] = 0.0F;
+ ret->data[i*stride] = 0;
return;
}
ret->data = ret->data;
- last1 = jnf (n2, x);
+ last1 = MATHFUNC(jn) (n2, x);
ret->data[(n2-n1)*stride] = last1;
if (n1 == n2)
return;
- last2 = jnf (n2 - 1, x);
+ last2 = MATHFUNC(jn) (n2 - 1, x);
ret->data[(n2-n1-1)*stride] = last2;
if (n1 + 1 == n2)
return;
- x2rev = 2.0F/x;
+ x2rev = GFC_REAL_4_LITERAL(2.)/x;
for (i = n2-n1-2; i >= 0; i--)
{
stride = GFC_DESCRIPTOR_STRIDE(ret,0);
- if (unlikely (x == 0.0F))
+ if (unlikely (x == 0))
{
for (i = 0; i <= n2-n1; i++)
#if defined(GFC_REAL_4_INFINITY)
}
ret->data = ret->data;
- last1 = ynf (n1, x);
+ last1 = MATHFUNC(yn) (n1, x);
ret->data[0] = last1;
if (n1 == n2)
return;
- last2 = ynf (n1 + 1, x);
+ last2 = MATHFUNC(yn) (n1 + 1, x);
ret->data[1*stride] = last2;
if (n1 + 1 == n2)
return;
- x2rev = 2.0F/x;
+ x2rev = GFC_REAL_4_LITERAL(2.)/x;
for (i = 2; i <= n1+n2; i++)
{
#include <assert.h>
+
+#define MATHFUNC(funcname) funcname
+
#if defined (HAVE_GFC_REAL_8)
stride = GFC_DESCRIPTOR_STRIDE(ret,0);
- if (unlikely (x == 0.0))
+ if (unlikely (x == 0))
{
- ret->data[0] = 1.0;
+ ret->data[0] = 1;
for (i = 1; i <= n2-n1; i++)
- ret->data[i*stride] = 0.0;
+ ret->data[i*stride] = 0;
return;
}
ret->data = ret->data;
- last1 = jn (n2, x);
+ last1 = MATHFUNC(jn) (n2, x);
ret->data[(n2-n1)*stride] = last1;
if (n1 == n2)
return;
- last2 = jn (n2 - 1, x);
+ last2 = MATHFUNC(jn) (n2 - 1, x);
ret->data[(n2-n1-1)*stride] = last2;
if (n1 + 1 == n2)
return;
- x2rev = 2.0/x;
+ x2rev = GFC_REAL_8_LITERAL(2.)/x;
for (i = n2-n1-2; i >= 0; i--)
{
stride = GFC_DESCRIPTOR_STRIDE(ret,0);
- if (unlikely (x == 0.0))
+ if (unlikely (x == 0))
{
for (i = 0; i <= n2-n1; i++)
#if defined(GFC_REAL_8_INFINITY)
}
ret->data = ret->data;
- last1 = yn (n1, x);
+ last1 = MATHFUNC(yn) (n1, x);
ret->data[0] = last1;
if (n1 == n2)
return;
- last2 = yn (n1 + 1, x);
+ last2 = MATHFUNC(yn) (n1 + 1, x);
ret->data[1*stride] = last2;
if (n1 + 1 == n2)
return;
- x2rev = 2.0/x;
+ x2rev = GFC_REAL_8_LITERAL(2.)/x;
for (i = 2; i <= n1+n2; i++)
{
#include "libgfortran.h"
+
+#define MATHFUNC(funcname) funcname ## l
+
#if defined (HAVE_GFC_REAL_10) && defined (HAVE_FREXPL)
extern GFC_INTEGER_4 exponent_r10 (GFC_REAL_10 s);
exponent_r10 (GFC_REAL_10 s)
{
int ret;
- frexpl (s, &ret);
+ MATHFUNC(frexp) (s, &ret);
return ret;
}
#include "libgfortran.h"
-#if defined (HAVE_GFC_REAL_16) && defined (HAVE_FREXPL)
+
+#if defined(GFC_REAL_16_IS_FLOAT128)
+#define MATHFUNC(funcname) funcname ## q
+#else
+#define MATHFUNC(funcname) funcname ## l
+#endif
+
+#if defined (HAVE_GFC_REAL_16) && (defined(GFC_WITH_QUAD_LIB) || defined(HAVE_FREXPL))
extern GFC_INTEGER_4 exponent_r16 (GFC_REAL_16 s);
export_proto(exponent_r16);
exponent_r16 (GFC_REAL_16 s)
{
int ret;
- frexpl (s, &ret);
+ MATHFUNC(frexp) (s, &ret);
return ret;
}
#include "libgfortran.h"
+
+#define MATHFUNC(funcname) funcname ## f
+
#if defined (HAVE_GFC_REAL_4) && defined (HAVE_FREXPF)
extern GFC_INTEGER_4 exponent_r4 (GFC_REAL_4 s);
exponent_r4 (GFC_REAL_4 s)
{
int ret;
- frexpf (s, &ret);
+ MATHFUNC(frexp) (s, &ret);
return ret;
}
#include "libgfortran.h"
+
+#define MATHFUNC(funcname) funcname
+
#if defined (HAVE_GFC_REAL_8) && defined (HAVE_FREXP)
extern GFC_INTEGER_4 exponent_r8 (GFC_REAL_8 s);
exponent_r8 (GFC_REAL_8 s)
{
int ret;
- frexp (s, &ret);
+ MATHFUNC(frexp) (s, &ret);
return ret;
}
#include "libgfortran.h"
+
+#define MATHFUNC(funcname) funcname ## l
+
#if defined (HAVE_GFC_REAL_10) && defined (HAVE_FREXPL)
extern GFC_REAL_10 fraction_r10 (GFC_REAL_10 s);
fraction_r10 (GFC_REAL_10 s)
{
int dummy_exp;
- return frexpl (s, &dummy_exp);
+ return MATHFUNC(frexp) (s, &dummy_exp);
}
#endif
#include "libgfortran.h"
-#if defined (HAVE_GFC_REAL_16) && defined (HAVE_FREXPL)
+
+#if defined(GFC_REAL_16_IS_FLOAT128)
+#define MATHFUNC(funcname) funcname ## q
+#else
+#define MATHFUNC(funcname) funcname ## l
+#endif
+
+#if defined (HAVE_GFC_REAL_16) && (defined(GFC_WITH_QUAD_LIB) || defined(HAVE_FREXPL))
extern GFC_REAL_16 fraction_r16 (GFC_REAL_16 s);
export_proto(fraction_r16);
fraction_r16 (GFC_REAL_16 s)
{
int dummy_exp;
- return frexpl (s, &dummy_exp);
+ return MATHFUNC(frexp) (s, &dummy_exp);
}
#endif
#include "libgfortran.h"
+
+#define MATHFUNC(funcname) funcname ## f
+
#if defined (HAVE_GFC_REAL_4) && defined (HAVE_FREXPF)
extern GFC_REAL_4 fraction_r4 (GFC_REAL_4 s);
fraction_r4 (GFC_REAL_4 s)
{
int dummy_exp;
- return frexpf (s, &dummy_exp);
+ return MATHFUNC(frexp) (s, &dummy_exp);
}
#endif
#include "libgfortran.h"
+
+#define MATHFUNC(funcname) funcname
+
#if defined (HAVE_GFC_REAL_8) && defined (HAVE_FREXP)
extern GFC_REAL_8 fraction_r8 (GFC_REAL_8 s);
fraction_r8 (GFC_REAL_8 s)
{
int dummy_exp;
- return frexp (s, &dummy_exp);
+ return MATHFUNC(frexp) (s, &dummy_exp);
}
#endif
#include "libgfortran.h"
+
+#define MATHFUNC(funcname) funcname ## l
+
#if defined (HAVE_GFC_REAL_10) && defined (HAVE_COPYSIGNL) && defined (HAVE_NEXTAFTERL)
extern GFC_REAL_10 nearest_r10 (GFC_REAL_10 s, GFC_REAL_10 dir);
GFC_REAL_10
nearest_r10 (GFC_REAL_10 s, GFC_REAL_10 dir)
{
- dir = copysignl (__builtin_infl (), dir);
+ dir = MATHFUNC(copysign) (MATHFUNC(__builtin_inf) (), dir);
if (FLT_EVAL_METHOD != 0)
{
/* ??? Work around glibc bug on x86. */
- volatile GFC_REAL_10 r = nextafterl (s, dir);
+ volatile GFC_REAL_10 r = MATHFUNC(nextafter) (s, dir);
return r;
}
else
- return nextafterl (s, dir);
+ return MATHFUNC(nextafter) (s, dir);
}
#endif
#include "libgfortran.h"
-#if defined (HAVE_GFC_REAL_16) && defined (HAVE_COPYSIGNL) && defined (HAVE_NEXTAFTERL)
+
+#if defined(GFC_REAL_16_IS_FLOAT128)
+#define MATHFUNC(funcname) funcname ## q
+#else
+#define MATHFUNC(funcname) funcname ## l
+#endif
+
+#if defined (HAVE_GFC_REAL_16) && (defined(GFC_WITH_QUAD_LIB) || defined(HAVE_COPYSIGNL)) && (defined(GFC_WITH_QUAD_LIB) || defined(HAVE_NEXTAFTERL))
extern GFC_REAL_16 nearest_r16 (GFC_REAL_16 s, GFC_REAL_16 dir);
export_proto(nearest_r16);
GFC_REAL_16
nearest_r16 (GFC_REAL_16 s, GFC_REAL_16 dir)
{
- dir = copysignl (__builtin_infl (), dir);
+ dir = MATHFUNC(copysign) (MATHFUNC(__builtin_inf) (), dir);
if (FLT_EVAL_METHOD != 0)
{
/* ??? Work around glibc bug on x86. */
- volatile GFC_REAL_16 r = nextafterl (s, dir);
+ volatile GFC_REAL_16 r = MATHFUNC(nextafter) (s, dir);
return r;
}
else
- return nextafterl (s, dir);
+ return MATHFUNC(nextafter) (s, dir);
}
#endif
#include "libgfortran.h"
+
+#define MATHFUNC(funcname) funcname ## f
+
#if defined (HAVE_GFC_REAL_4) && defined (HAVE_COPYSIGNF) && defined (HAVE_NEXTAFTERF)
extern GFC_REAL_4 nearest_r4 (GFC_REAL_4 s, GFC_REAL_4 dir);
GFC_REAL_4
nearest_r4 (GFC_REAL_4 s, GFC_REAL_4 dir)
{
- dir = copysignf (__builtin_inff (), dir);
+ dir = MATHFUNC(copysign) (MATHFUNC(__builtin_inf) (), dir);
if (FLT_EVAL_METHOD != 0)
{
/* ??? Work around glibc bug on x86. */
- volatile GFC_REAL_4 r = nextafterf (s, dir);
+ volatile GFC_REAL_4 r = MATHFUNC(nextafter) (s, dir);
return r;
}
else
- return nextafterf (s, dir);
+ return MATHFUNC(nextafter) (s, dir);
}
#endif
#include "libgfortran.h"
+
+#define MATHFUNC(funcname) funcname
+
#if defined (HAVE_GFC_REAL_8) && defined (HAVE_COPYSIGN) && defined (HAVE_NEXTAFTER)
extern GFC_REAL_8 nearest_r8 (GFC_REAL_8 s, GFC_REAL_8 dir);
GFC_REAL_8
nearest_r8 (GFC_REAL_8 s, GFC_REAL_8 dir)
{
- dir = copysign (__builtin_inf (), dir);
+ dir = MATHFUNC(copysign) (MATHFUNC(__builtin_inf) (), dir);
if (FLT_EVAL_METHOD != 0)
{
/* ??? Work around glibc bug on x86. */
- volatile GFC_REAL_8 r = nextafter (s, dir);
+ volatile GFC_REAL_8 r = MATHFUNC(nextafter) (s, dir);
return r;
}
else
- return nextafter (s, dir);
+ return MATHFUNC(nextafter) (s, dir);
}
#endif
#include <assert.h>
-#if defined (HAVE_GFC_REAL_10) && defined (HAVE_GFC_REAL_10)
+
+#if defined (HAVE_GFC_REAL_10) && defined (HAVE_GFC_REAL_10) && defined (HAVE_SQRTL) && defined (HAVE_FABSL)
+
+#define MATHFUNC(funcname) funcname ## l
extern void norm2_r10 (gfc_array_r10 * const restrict,
{
GFC_REAL_10 scale;
- result = 0.0L;
- scale = 1.0L;
+ result = 0;
+ scale = 1;
if (len <= 0)
- *dest = 0.0L;
+ *dest = 0;
else
{
for (n = 0; n < len; n++, src += delta)
{
- if (*src != 0.0L)
+ if (*src != 0)
{
GFC_REAL_10 absX, val;
- absX = fabsl (*src);
+ absX = MATHFUNC(fabs) (*src);
if (scale < absX)
{
val = scale / absX;
- result = 1.0L + result * val * val;
+ result = 1 + result * val * val;
scale = absX;
}
else
}
}
}
- result = scale * sqrtl (result);
+ result = scale * MATHFUNC(sqrt) (result);
*dest = result;
}
}
#include <assert.h>
-#if defined (HAVE_GFC_REAL_16) && defined (HAVE_GFC_REAL_16)
+
+#if defined (HAVE_GFC_REAL_16) && defined (HAVE_GFC_REAL_16) && (defined(GFC_WITH_QUAD_LIB) || defined(HAVE_SQRTL)) && (defined(GFC_WITH_QUAD_LIB) || defined(HAVE_FABSL))
+
+#if defined(GFC_REAL_16_IS_FLOAT128)
+#define MATHFUNC(funcname) funcname ## q
+#else
+#define MATHFUNC(funcname) funcname ## l
+#endif
extern void norm2_r16 (gfc_array_r16 * const restrict,
{
GFC_REAL_16 scale;
- result = 0.0L;
- scale = 1.0L;
+ result = 0;
+ scale = 1;
if (len <= 0)
- *dest = 0.0L;
+ *dest = 0;
else
{
for (n = 0; n < len; n++, src += delta)
{
- if (*src != 0.0L)
+ if (*src != 0)
{
GFC_REAL_16 absX, val;
- absX = fabsl (*src);
+ absX = MATHFUNC(fabs) (*src);
if (scale < absX)
{
val = scale / absX;
- result = 1.0L + result * val * val;
+ result = 1 + result * val * val;
scale = absX;
}
else
}
}
}
- result = scale * sqrtl (result);
+ result = scale * MATHFUNC(sqrt) (result);
*dest = result;
}
}
#include <assert.h>
-#if defined (HAVE_GFC_REAL_4) && defined (HAVE_GFC_REAL_4)
+
+#if defined (HAVE_GFC_REAL_4) && defined (HAVE_GFC_REAL_4) && defined (HAVE_SQRTF) && defined (HAVE_FABSF)
+
+#define MATHFUNC(funcname) funcname ## f
extern void norm2_r4 (gfc_array_r4 * const restrict,
{
GFC_REAL_4 scale;
- result = 0.0F;
- scale = 1.0F;
+ result = 0;
+ scale = 1;
if (len <= 0)
- *dest = 0.0F;
+ *dest = 0;
else
{
for (n = 0; n < len; n++, src += delta)
{
- if (*src != 0.0F)
+ if (*src != 0)
{
GFC_REAL_4 absX, val;
- absX = fabsf (*src);
+ absX = MATHFUNC(fabs) (*src);
if (scale < absX)
{
val = scale / absX;
- result = 1.0F + result * val * val;
+ result = 1 + result * val * val;
scale = absX;
}
else
}
}
}
- result = scale * sqrtf (result);
+ result = scale * MATHFUNC(sqrt) (result);
*dest = result;
}
}
#include <assert.h>
-#if defined (HAVE_GFC_REAL_8) && defined (HAVE_GFC_REAL_8)
+
+#if defined (HAVE_GFC_REAL_8) && defined (HAVE_GFC_REAL_8) && defined (HAVE_SQRT) && defined (HAVE_FABS)
+
+#define MATHFUNC(funcname) funcname
extern void norm2_r8 (gfc_array_r8 * const restrict,
{
GFC_REAL_8 scale;
- result = 0.0;
- scale = 1.0;
+ result = 0;
+ scale = 1;
if (len <= 0)
- *dest = 0.0;
+ *dest = 0;
else
{
for (n = 0; n < len; n++, src += delta)
{
- if (*src != 0.0)
+ if (*src != 0)
{
GFC_REAL_8 absX, val;
- absX = fabs (*src);
+ absX = MATHFUNC(fabs) (*src);
if (scale < absX)
{
val = scale / absX;
- result = 1.0 + result * val * val;
+ result = 1 + result * val * val;
scale = absX;
}
else
}
}
}
- result = scale * sqrt (result);
+ result = scale * MATHFUNC(sqrt) (result);
*dest = result;
}
}
#include "libgfortran.h"
+
+#define MATHFUNC(funcname) funcname ## l
+
#if defined (HAVE_GFC_REAL_10) && defined (HAVE_FABSL) && defined (HAVE_FREXPL)
extern GFC_REAL_10 rrspacing_r10 (GFC_REAL_10 s, int p);
{
int e;
GFC_REAL_10 x;
- x = fabsl (s);
+ x = MATHFUNC(fabs) (s);
if (x == 0.)
return 0.;
- frexpl (s, &e);
+ MATHFUNC(frexp) (s, &e);
#if defined (HAVE_LDEXPL)
- return ldexpl (x, p - e);
+ return MATHFUNC(ldexp) (x, p - e);
#else
- return scalbnl (x, p - e);
+ return MATHFUNC(scalbn) (x, p - e);
#endif
}
#include "libgfortran.h"
-#if defined (HAVE_GFC_REAL_16) && defined (HAVE_FABSL) && defined (HAVE_FREXPL)
+
+#if defined(GFC_REAL_16_IS_FLOAT128)
+#define MATHFUNC(funcname) funcname ## q
+#else
+#define MATHFUNC(funcname) funcname ## l
+#endif
+
+#if defined (HAVE_GFC_REAL_16) && (defined(GFC_WITH_QUAD_LIB) || defined(HAVE_FABSL)) && (defined(GFC_WITH_QUAD_LIB) || defined(HAVE_FREXPL))
extern GFC_REAL_16 rrspacing_r16 (GFC_REAL_16 s, int p);
export_proto(rrspacing_r16);
{
int e;
GFC_REAL_16 x;
- x = fabsl (s);
+ x = MATHFUNC(fabs) (s);
if (x == 0.)
return 0.;
- frexpl (s, &e);
-#if defined (HAVE_LDEXPL)
- return ldexpl (x, p - e);
+ MATHFUNC(frexp) (s, &e);
+#if (defined(GFC_WITH_QUAD_LIB) || defined(HAVE_LDEXPL))
+ return MATHFUNC(ldexp) (x, p - e);
#else
- return scalbnl (x, p - e);
+ return MATHFUNC(scalbn) (x, p - e);
#endif
}
#include "libgfortran.h"
+
+#define MATHFUNC(funcname) funcname ## f
+
#if defined (HAVE_GFC_REAL_4) && defined (HAVE_FABSF) && defined (HAVE_FREXPF)
extern GFC_REAL_4 rrspacing_r4 (GFC_REAL_4 s, int p);
{
int e;
GFC_REAL_4 x;
- x = fabsf (s);
+ x = MATHFUNC(fabs) (s);
if (x == 0.)
return 0.;
- frexpf (s, &e);
+ MATHFUNC(frexp) (s, &e);
#if defined (HAVE_LDEXPF)
- return ldexpf (x, p - e);
+ return MATHFUNC(ldexp) (x, p - e);
#else
- return scalbnf (x, p - e);
+ return MATHFUNC(scalbn) (x, p - e);
#endif
}
#include "libgfortran.h"
+
+#define MATHFUNC(funcname) funcname
+
#if defined (HAVE_GFC_REAL_8) && defined (HAVE_FABS) && defined (HAVE_FREXP)
extern GFC_REAL_8 rrspacing_r8 (GFC_REAL_8 s, int p);
{
int e;
GFC_REAL_8 x;
- x = fabs (s);
+ x = MATHFUNC(fabs) (s);
if (x == 0.)
return 0.;
- frexp (s, &e);
+ MATHFUNC(frexp) (s, &e);
#if defined (HAVE_LDEXP)
- return ldexp (x, p - e);
+ return MATHFUNC(ldexp) (x, p - e);
#else
- return scalbn (x, p - e);
+ return MATHFUNC(scalbn) (x, p - e);
#endif
}
#include "libgfortran.h"
+
+#define MATHFUNC(funcname) funcname ## l
+
#if defined (HAVE_GFC_REAL_10) && defined (HAVE_SCALBNL) && defined (HAVE_FREXPL)
extern GFC_REAL_10 set_exponent_r10 (GFC_REAL_10 s, GFC_INTEGER_4 i);
set_exponent_r10 (GFC_REAL_10 s, GFC_INTEGER_4 i)
{
int dummy_exp;
- return scalbnl (frexpl (s, &dummy_exp), i);
+ return MATHFUNC(scalbn) (MATHFUNC(frexp) (s, &dummy_exp), i);
}
#endif
#include "libgfortran.h"
-#if defined (HAVE_GFC_REAL_16) && defined (HAVE_SCALBNL) && defined (HAVE_FREXPL)
+
+#if defined(GFC_REAL_16_IS_FLOAT128)
+#define MATHFUNC(funcname) funcname ## q
+#else
+#define MATHFUNC(funcname) funcname ## l
+#endif
+
+#if defined (HAVE_GFC_REAL_16) && (defined(GFC_WITH_QUAD_LIB) || defined(HAVE_SCALBNL)) && (defined(GFC_WITH_QUAD_LIB) || defined(HAVE_FREXPL))
extern GFC_REAL_16 set_exponent_r16 (GFC_REAL_16 s, GFC_INTEGER_4 i);
export_proto(set_exponent_r16);
set_exponent_r16 (GFC_REAL_16 s, GFC_INTEGER_4 i)
{
int dummy_exp;
- return scalbnl (frexpl (s, &dummy_exp), i);
+ return MATHFUNC(scalbn) (MATHFUNC(frexp) (s, &dummy_exp), i);
}
#endif
#include "libgfortran.h"
+
+#define MATHFUNC(funcname) funcname ## f
+
#if defined (HAVE_GFC_REAL_4) && defined (HAVE_SCALBNF) && defined (HAVE_FREXPF)
extern GFC_REAL_4 set_exponent_r4 (GFC_REAL_4 s, GFC_INTEGER_4 i);
set_exponent_r4 (GFC_REAL_4 s, GFC_INTEGER_4 i)
{
int dummy_exp;
- return scalbnf (frexpf (s, &dummy_exp), i);
+ return MATHFUNC(scalbn) (MATHFUNC(frexp) (s, &dummy_exp), i);
}
#endif
#include "libgfortran.h"
+
+#define MATHFUNC(funcname) funcname
+
#if defined (HAVE_GFC_REAL_8) && defined (HAVE_SCALBN) && defined (HAVE_FREXP)
extern GFC_REAL_8 set_exponent_r8 (GFC_REAL_8 s, GFC_INTEGER_4 i);
set_exponent_r8 (GFC_REAL_8 s, GFC_INTEGER_4 i)
{
int dummy_exp;
- return scalbn (frexp (s, &dummy_exp), i);
+ return MATHFUNC(scalbn) (MATHFUNC(frexp) (s, &dummy_exp), i);
}
#endif
#include "libgfortran.h"
+
+#define MATHFUNC(funcname) funcname ## l
+
#if defined (HAVE_GFC_REAL_10) && defined (HAVE_FREXPL)
extern GFC_REAL_10 spacing_r10 (GFC_REAL_10 s, int p, int emin, GFC_REAL_10 tiny);
int e;
if (s == 0.)
return tiny;
- frexpl (s, &e);
+ MATHFUNC(frexp) (s, &e);
e = e - p;
e = e > emin ? e : emin;
#if defined (HAVE_LDEXPL)
- return ldexpl (1., e);
+ return MATHFUNC(ldexp) (1., e);
#else
- return scalbnl (1., e);
+ return MATHFUNC(scalbn) (1., e);
#endif
}
#include "libgfortran.h"
-#if defined (HAVE_GFC_REAL_16) && defined (HAVE_FREXPL)
+
+#if defined(GFC_REAL_16_IS_FLOAT128)
+#define MATHFUNC(funcname) funcname ## q
+#else
+#define MATHFUNC(funcname) funcname ## l
+#endif
+
+#if defined (HAVE_GFC_REAL_16) && (defined(GFC_WITH_QUAD_LIB) || defined(HAVE_FREXPL))
extern GFC_REAL_16 spacing_r16 (GFC_REAL_16 s, int p, int emin, GFC_REAL_16 tiny);
export_proto(spacing_r16);
int e;
if (s == 0.)
return tiny;
- frexpl (s, &e);
+ MATHFUNC(frexp) (s, &e);
e = e - p;
e = e > emin ? e : emin;
-#if defined (HAVE_LDEXPL)
- return ldexpl (1., e);
+#if (defined(GFC_WITH_QUAD_LIB) || defined(HAVE_LDEXPL))
+ return MATHFUNC(ldexp) (1., e);
#else
- return scalbnl (1., e);
+ return MATHFUNC(scalbn) (1., e);
#endif
}
#include "libgfortran.h"
+
+#define MATHFUNC(funcname) funcname ## f
+
#if defined (HAVE_GFC_REAL_4) && defined (HAVE_FREXPF)
extern GFC_REAL_4 spacing_r4 (GFC_REAL_4 s, int p, int emin, GFC_REAL_4 tiny);
int e;
if (s == 0.)
return tiny;
- frexpf (s, &e);
+ MATHFUNC(frexp) (s, &e);
e = e - p;
e = e > emin ? e : emin;
#if defined (HAVE_LDEXPF)
- return ldexpf (1., e);
+ return MATHFUNC(ldexp) (1., e);
#else
- return scalbnf (1., e);
+ return MATHFUNC(scalbn) (1., e);
#endif
}
#include "libgfortran.h"
+
+#define MATHFUNC(funcname) funcname
+
#if defined (HAVE_GFC_REAL_8) && defined (HAVE_FREXP)
extern GFC_REAL_8 spacing_r8 (GFC_REAL_8 s, int p, int emin, GFC_REAL_8 tiny);
int e;
if (s == 0.)
return tiny;
- frexp (s, &e);
+ MATHFUNC(frexp) (s, &e);
e = e - p;
e = e > emin ? e : emin;
#if defined (HAVE_LDEXP)
- return ldexp (1., e);
+ return MATHFUNC(ldexp) (1., e);
#else
- return scalbn (1., e);
+ return MATHFUNC(scalbn) (1., e);
#endif
}
include(iparm.m4)dnl
include(`mtype.m4')dnl
+mathfunc_macro
+
`#if defined (HAVE_'rtype_name`)
-#if defined (HAVE_JN'Q`)
+#if 'hasmathfunc(jn)`
extern void bessel_jn_r'rtype_kind` ('rtype` * const restrict ret, int n1,
int n2, 'rtype_name` x);
export_proto(bessel_jn_r'rtype_kind`);
stride = GFC_DESCRIPTOR_STRIDE(ret,0);
- if (unlikely (x == 0.0'Q`))
+ if (unlikely (x == 0))
{
- ret->data[0] = 1.0'Q`;
+ ret->data[0] = 1;
for (i = 1; i <= n2-n1; i++)
- ret->data[i*stride] = 0.0'Q`;
+ ret->data[i*stride] = 0;
return;
}
ret->data = ret->data;
- last1 = jn'q` (n2, x);
+ last1 = MATHFUNC(jn) (n2, x);
ret->data[(n2-n1)*stride] = last1;
if (n1 == n2)
return;
- last2 = jn'q` (n2 - 1, x);
+ last2 = MATHFUNC(jn) (n2 - 1, x);
ret->data[(n2-n1-1)*stride] = last2;
if (n1 + 1 == n2)
return;
- x2rev = 2.0'Q`/x;
+ x2rev = GFC_REAL_'rtype_kind`_LITERAL(2.)/x;
for (i = n2-n1-2; i >= 0; i--)
{
#endif
-#if defined (HAVE_YN'Q`)
+#if 'hasmathfunc(yn)`
extern void bessel_yn_r'rtype_kind` ('rtype` * const restrict ret,
int n1, int n2, 'rtype_name` x);
export_proto(bessel_yn_r'rtype_kind`);
stride = GFC_DESCRIPTOR_STRIDE(ret,0);
- if (unlikely (x == 0.0'Q`))
+ if (unlikely (x == 0))
{
for (i = 0; i <= n2-n1; i++)
#if defined('rtype_name`_INFINITY)
}
ret->data = ret->data;
- last1 = yn'q` (n1, x);
+ last1 = MATHFUNC(yn) (n1, x);
ret->data[0] = last1;
if (n1 == n2)
return;
- last2 = yn'q` (n1 + 1, x);
+ last2 = MATHFUNC(yn) (n1 + 1, x);
ret->data[1*stride] = last2;
if (n1 + 1 == n2)
return;
- x2rev = 2.0'Q`/x;
+ x2rev = GFC_REAL_'rtype_kind`_LITERAL(2.)/x;
for (i = 2; i <= n1+n2; i++)
{
include(`mtype.m4')dnl
-`#if defined (HAVE_'real_type`) && defined (HAVE_FREXP'Q`)
+mathfunc_macro
+
+`#if defined (HAVE_'real_type`) && 'hasmathfunc(frexp)`
extern GFC_INTEGER_4 exponent_r'kind` ('real_type` s);
export_proto(exponent_r'kind`);
exponent_r'kind` ('real_type` s)
{
int ret;
- frexp'q` (s, &ret);
+ MATHFUNC(frexp) (s, &ret);
return ret;
}
include(`mtype.m4')dnl
-`#if defined (HAVE_'real_type`) && defined (HAVE_FREXP'Q`)
+mathfunc_macro
+
+`#if defined (HAVE_'real_type`) && 'hasmathfunc(frexp)`
extern 'real_type` fraction_r'kind` ('real_type` s);
export_proto(fraction_r'kind`);
fraction_r'kind` ('real_type` s)
{
int dummy_exp;
- return frexp'q` (s, &dummy_exp);
+ return MATHFUNC(frexp) (s, &dummy_exp);
}
#endif'
define(kind,regexp(file, `_.\([0-9]+\).c$', `\1'))dnl
define(complex_type, `GFC_COMPLEX_'kind)dnl
define(real_type, `GFC_REAL_'kind)dnl
+define(`upcase', `translit(`$*', `a-z', `A-Z')')dnl
define(q,ifelse(kind,4,f,ifelse(kind,8,`',ifelse(kind,10,l,ifelse(kind,16,l,`_'kind)))))dnl
define(Q,translit(q,`a-z',`A-Z'))dnl
+define(hasmathfunc,`ifelse(kind,4,`defined (HAVE_'upcase($1)`F)',ifelse(kind,8,`defined (HAVE_'upcase($1)`)',ifelse(kind,10,`defined (HAVE_'upcase($1)`L)',ifelse(kind,16,`(defined(GFC_WITH_QUAD_LIB) || defined(HAVE_'upcase($1)`L))',`error out'))))')
+define(mathfunc_macro,`ifelse(kind,16,`#if defined(GFC_REAL_16_IS_FLOAT128)
+#define MATHFUNC(funcname) funcname ## q
+#else
+#define MATHFUNC(funcname) funcname ## l
+#endif',ifelse(kind,8,``#''`define MATHFUNC(funcname) funcname',```#'''`define MATHFUNC(funcname) funcname '```#'''```#'''` 'q))')dnl
include(`mtype.m4')dnl
-`#if defined (HAVE_'real_type`) && defined (HAVE_COPYSIGN'Q`) && defined (HAVE_NEXTAFTER'Q`)
+mathfunc_macro
+
+`#if defined (HAVE_'real_type`) && 'hasmathfunc(copysign) && hasmathfunc(nextafter)`
extern 'real_type` nearest_r'kind` ('real_type` s, 'real_type` dir);
export_proto(nearest_r'kind`);
'real_type`
nearest_r'kind` ('real_type` s, 'real_type` dir)
{
- dir = copysign'q` (__builtin_inf'q` (), dir);
+ dir = MATHFUNC(copysign) (MATHFUNC(__builtin_inf) (), dir);
if (FLT_EVAL_METHOD != 0)
{
/* ??? Work around glibc bug on x86. */
- volatile 'real_type` r = nextafter'q` (s, dir);
+ volatile 'real_type` r = MATHFUNC(nextafter) (s, dir);
return r;
}
else
- return nextafter'q` (s, dir);
+ return MATHFUNC(nextafter) (s, dir);
}
#endif'
include(ifunction.m4)dnl
include(`mtype.m4')dnl
-`#if defined (HAVE_'atype_name`) && defined (HAVE_'rtype_name`)'
+`#if defined (HAVE_'atype_name`) && defined (HAVE_'rtype_name`) && 'hasmathfunc(sqrt) && hasmathfunc(fabs)
-ARRAY_FUNCTION(`0.0'Q,
+mathfunc_macro
+
+ARRAY_FUNCTION(0,
` 'rtype_name` scale;
- result = 0.0'Q`;
- scale = 1.0'Q`;',
-` if (*src != 0.0'Q`)
+ result = 0;
+ scale = 1;',
+` if (*src != 0)
{
'rtype_name` absX, val;
- absX = fabs'q` (*src);
+ absX = MATHFUNC(fabs) (*src);
if (scale < absX)
{
val = scale / absX;
- result = 1.0'Q` + result * val * val;
+ result = 1 + result * val * val;
scale = absX;
}
else
result += val * val;
}
}',
-` result = scale * sqrt'q` (result);')
+` result = scale * MATHFUNC(sqrt) (result);')
#endif
include(`mtype.m4')dnl
-`#if defined (HAVE_'real_type`) && defined (HAVE_FABS'Q`) && defined (HAVE_FREXP'Q`)
+mathfunc_macro
+
+`#if defined (HAVE_'real_type`) && 'hasmathfunc(fabs) && hasmathfunc(frexp)`
extern 'real_type` rrspacing_r'kind` ('real_type` s, int p);
export_proto(rrspacing_r'kind`);
{
int e;
'real_type` x;
- x = fabs'q` (s);
+ x = MATHFUNC(fabs) (s);
if (x == 0.)
return 0.;
- frexp'q` (s, &e);
-#if defined (HAVE_LDEXP'Q`)
- return ldexp'q` (x, p - e);
+ MATHFUNC(frexp) (s, &e);
+#if 'hasmathfunc(ldexp)`
+ return MATHFUNC(ldexp) (x, p - e);
#else
- return scalbn'q` (x, p - e);
+ return MATHFUNC(scalbn) (x, p - e);
#endif
}
include(`mtype.m4')dnl
-`#if defined (HAVE_'real_type`) && defined (HAVE_SCALBN'Q`) && defined (HAVE_FREXP'Q`)
+mathfunc_macro
+
+`#if defined (HAVE_'real_type`) && 'hasmathfunc(scalbn) && hasmathfunc(frexp)`
extern 'real_type` set_exponent_r'kind` ('real_type` s, GFC_INTEGER_4 i);
export_proto(set_exponent_r'kind`);
set_exponent_r'kind` ('real_type` s, GFC_INTEGER_4 i)
{
int dummy_exp;
- return scalbn'q` (frexp'q` (s, &dummy_exp), i);
+ return MATHFUNC(scalbn) (MATHFUNC(frexp) (s, &dummy_exp), i);
}
#endif'
include(`mtype.m4')dnl
-`#if defined (HAVE_'real_type`) && defined (HAVE_FREXP'Q`)
+mathfunc_macro
+
+`#if defined (HAVE_'real_type`) && 'hasmathfunc(frexp)`
extern 'real_type` spacing_r'kind` ('real_type` s, int p, int emin, 'real_type` tiny);
export_proto(spacing_r'kind`);
int e;
if (s == 0.)
return tiny;
- frexp'q` (s, &e);
+ MATHFUNC(frexp) (s, &e);
e = e - p;
e = e > emin ? e : emin;
-#if defined (HAVE_LDEXP'Q`)
- return ldexp'q` (1., e);
+#if 'hasmathfunc(ldexp)`
+ return MATHFUNC(ldexp) (1., e);
#else
- return scalbn'q` (1., e);
+ return MATHFUNC(scalbn) (1., e);
#endif
}