From 08fd13d44702391da6e367876b74ce8ed71c0bab Mon Sep 17 00:00:00 2001 From: Francois-Xavier Coudert Date: Sat, 28 Aug 2010 22:10:52 +0000 Subject: [PATCH] mtype.m4 (upcase, [...]): New macros. * 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. From-SVN: r163620 --- libgfortran/ChangeLog | 44 ++++++++++++++++++++++++ libgfortran/generated/bessel_r10.c | 23 +++++++------ libgfortran/generated/bessel_r16.c | 31 ++++++++++------- libgfortran/generated/bessel_r4.c | 23 +++++++------ libgfortran/generated/bessel_r8.c | 23 +++++++------ libgfortran/generated/exponent_r10.c | 5 ++- libgfortran/generated/exponent_r16.c | 11 ++++-- libgfortran/generated/exponent_r4.c | 5 ++- libgfortran/generated/exponent_r8.c | 5 ++- libgfortran/generated/fraction_r10.c | 5 ++- libgfortran/generated/fraction_r16.c | 11 ++++-- libgfortran/generated/fraction_r4.c | 5 ++- libgfortran/generated/fraction_r8.c | 5 ++- libgfortran/generated/nearest_r10.c | 9 +++-- libgfortran/generated/nearest_r16.c | 15 +++++--- libgfortran/generated/nearest_r4.c | 9 +++-- libgfortran/generated/nearest_r8.c | 9 +++-- libgfortran/generated/norm2_r10.c | 19 +++++----- libgfortran/generated/norm2_r16.c | 23 ++++++++----- libgfortran/generated/norm2_r4.c | 19 +++++----- libgfortran/generated/norm2_r8.c | 19 +++++----- libgfortran/generated/rrspacing_r10.c | 11 +++--- libgfortran/generated/rrspacing_r16.c | 19 ++++++---- libgfortran/generated/rrspacing_r4.c | 11 +++--- libgfortran/generated/rrspacing_r8.c | 11 +++--- libgfortran/generated/set_exponent_r10.c | 5 ++- libgfortran/generated/set_exponent_r16.c | 11 ++++-- libgfortran/generated/set_exponent_r4.c | 5 ++- libgfortran/generated/set_exponent_r8.c | 5 ++- libgfortran/generated/spacing_r10.c | 9 +++-- libgfortran/generated/spacing_r16.c | 17 ++++++--- libgfortran/generated/spacing_r4.c | 9 +++-- libgfortran/generated/spacing_r8.c | 9 +++-- libgfortran/m4/bessel.m4 | 26 +++++++------- libgfortran/m4/exponent.m4 | 6 ++-- libgfortran/m4/fraction.m4 | 6 ++-- libgfortran/m4/mtype.m4 | 7 ++++ libgfortran/m4/nearest.m4 | 10 +++--- libgfortran/m4/norm2.m4 | 18 +++++----- libgfortran/m4/rrspacing.m4 | 14 ++++---- libgfortran/m4/set_exponent.m4 | 6 ++-- libgfortran/m4/spacing.m4 | 12 ++++--- 42 files changed, 370 insertions(+), 175 deletions(-) diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 0c31d7287151..b6fa20f8b77a 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,47 @@ +2010-08-29 Francois-Xavier Coudert + + * 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 * mk-kinds-h.sh: Disable REAL(16) if REAL(10) is available. diff --git a/libgfortran/generated/bessel_r10.c b/libgfortran/generated/bessel_r10.c index 579de8445b0d..efef45051885 100644 --- a/libgfortran/generated/bessel_r10.c +++ b/libgfortran/generated/bessel_r10.c @@ -29,6 +29,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include + +#define MATHFUNC(funcname) funcname ## l + #if defined (HAVE_GFC_REAL_10) @@ -67,28 +70,28 @@ bessel_jn_r10 (gfc_array_r10 * const restrict ret, int n1, int n2, GFC_REAL_10 x 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--) { @@ -135,7 +138,7 @@ bessel_yn_r10 (gfc_array_r10 * const restrict ret, int n1, int n2, 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) @@ -147,19 +150,19 @@ bessel_yn_r10 (gfc_array_r10 * const restrict ret, int n1, int n2, } 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++) { diff --git a/libgfortran/generated/bessel_r16.c b/libgfortran/generated/bessel_r16.c index a3ef181012e1..d5ca883e8990 100644 --- a/libgfortran/generated/bessel_r16.c +++ b/libgfortran/generated/bessel_r16.c @@ -29,11 +29,18 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include + +#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); @@ -67,28 +74,28 @@ bessel_jn_r16 (gfc_array_r16 * const restrict ret, int n1, int n2, GFC_REAL_16 x 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--) { @@ -100,7 +107,7 @@ bessel_jn_r16 (gfc_array_r16 * const restrict ret, int n1, int n2, GFC_REAL_16 x #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); @@ -135,7 +142,7 @@ bessel_yn_r16 (gfc_array_r16 * const restrict ret, int n1, int n2, 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) @@ -147,19 +154,19 @@ bessel_yn_r16 (gfc_array_r16 * const restrict ret, int n1, int n2, } 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++) { diff --git a/libgfortran/generated/bessel_r4.c b/libgfortran/generated/bessel_r4.c index 961c67cb5649..794a5f6b7f9e 100644 --- a/libgfortran/generated/bessel_r4.c +++ b/libgfortran/generated/bessel_r4.c @@ -29,6 +29,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include + +#define MATHFUNC(funcname) funcname ## f + #if defined (HAVE_GFC_REAL_4) @@ -67,28 +70,28 @@ bessel_jn_r4 (gfc_array_r4 * const restrict ret, int n1, int n2, GFC_REAL_4 x) 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--) { @@ -135,7 +138,7 @@ bessel_yn_r4 (gfc_array_r4 * const restrict ret, int n1, int n2, 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) @@ -147,19 +150,19 @@ bessel_yn_r4 (gfc_array_r4 * const restrict ret, int n1, int n2, } 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++) { diff --git a/libgfortran/generated/bessel_r8.c b/libgfortran/generated/bessel_r8.c index c896ae41a91d..e9f84b4ce546 100644 --- a/libgfortran/generated/bessel_r8.c +++ b/libgfortran/generated/bessel_r8.c @@ -29,6 +29,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include + +#define MATHFUNC(funcname) funcname + #if defined (HAVE_GFC_REAL_8) @@ -67,28 +70,28 @@ bessel_jn_r8 (gfc_array_r8 * const restrict ret, int n1, int n2, GFC_REAL_8 x) 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--) { @@ -135,7 +138,7 @@ bessel_yn_r8 (gfc_array_r8 * const restrict ret, int n1, int n2, 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) @@ -147,19 +150,19 @@ bessel_yn_r8 (gfc_array_r8 * const restrict ret, int n1, int n2, } 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++) { diff --git a/libgfortran/generated/exponent_r10.c b/libgfortran/generated/exponent_r10.c index 1b56765b3b16..ceafda30e2c1 100644 --- a/libgfortran/generated/exponent_r10.c +++ b/libgfortran/generated/exponent_r10.c @@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -35,7 +38,7 @@ GFC_INTEGER_4 exponent_r10 (GFC_REAL_10 s) { int ret; - frexpl (s, &ret); + MATHFUNC(frexp) (s, &ret); return ret; } diff --git a/libgfortran/generated/exponent_r16.c b/libgfortran/generated/exponent_r16.c index 23f04152ddb0..899a2aef3591 100644 --- a/libgfortran/generated/exponent_r16.c +++ b/libgfortran/generated/exponent_r16.c @@ -26,7 +26,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -35,7 +42,7 @@ GFC_INTEGER_4 exponent_r16 (GFC_REAL_16 s) { int ret; - frexpl (s, &ret); + MATHFUNC(frexp) (s, &ret); return ret; } diff --git a/libgfortran/generated/exponent_r4.c b/libgfortran/generated/exponent_r4.c index b2df840a48d5..04aee1c922c9 100644 --- a/libgfortran/generated/exponent_r4.c +++ b/libgfortran/generated/exponent_r4.c @@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -35,7 +38,7 @@ GFC_INTEGER_4 exponent_r4 (GFC_REAL_4 s) { int ret; - frexpf (s, &ret); + MATHFUNC(frexp) (s, &ret); return ret; } diff --git a/libgfortran/generated/exponent_r8.c b/libgfortran/generated/exponent_r8.c index ed4319ffa078..5c35c5d0de90 100644 --- a/libgfortran/generated/exponent_r8.c +++ b/libgfortran/generated/exponent_r8.c @@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -35,7 +38,7 @@ GFC_INTEGER_4 exponent_r8 (GFC_REAL_8 s) { int ret; - frexp (s, &ret); + MATHFUNC(frexp) (s, &ret); return ret; } diff --git a/libgfortran/generated/fraction_r10.c b/libgfortran/generated/fraction_r10.c index 46aa65d2ceea..38cbdf8b44db 100644 --- a/libgfortran/generated/fraction_r10.c +++ b/libgfortran/generated/fraction_r10.c @@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -35,7 +38,7 @@ GFC_REAL_10 fraction_r10 (GFC_REAL_10 s) { int dummy_exp; - return frexpl (s, &dummy_exp); + return MATHFUNC(frexp) (s, &dummy_exp); } #endif diff --git a/libgfortran/generated/fraction_r16.c b/libgfortran/generated/fraction_r16.c index 1ae3262a43ae..97e283dddc8e 100644 --- a/libgfortran/generated/fraction_r16.c +++ b/libgfortran/generated/fraction_r16.c @@ -26,7 +26,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -35,7 +42,7 @@ GFC_REAL_16 fraction_r16 (GFC_REAL_16 s) { int dummy_exp; - return frexpl (s, &dummy_exp); + return MATHFUNC(frexp) (s, &dummy_exp); } #endif diff --git a/libgfortran/generated/fraction_r4.c b/libgfortran/generated/fraction_r4.c index f2ea9e27918a..a42e1468f516 100644 --- a/libgfortran/generated/fraction_r4.c +++ b/libgfortran/generated/fraction_r4.c @@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -35,7 +38,7 @@ GFC_REAL_4 fraction_r4 (GFC_REAL_4 s) { int dummy_exp; - return frexpf (s, &dummy_exp); + return MATHFUNC(frexp) (s, &dummy_exp); } #endif diff --git a/libgfortran/generated/fraction_r8.c b/libgfortran/generated/fraction_r8.c index 1e0f9361add8..1e267091f376 100644 --- a/libgfortran/generated/fraction_r8.c +++ b/libgfortran/generated/fraction_r8.c @@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -35,7 +38,7 @@ GFC_REAL_8 fraction_r8 (GFC_REAL_8 s) { int dummy_exp; - return frexp (s, &dummy_exp); + return MATHFUNC(frexp) (s, &dummy_exp); } #endif diff --git a/libgfortran/generated/nearest_r10.c b/libgfortran/generated/nearest_r10.c index 9601e32332cc..eb7a3b15a0de 100644 --- a/libgfortran/generated/nearest_r10.c +++ b/libgfortran/generated/nearest_r10.c @@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -34,15 +37,15 @@ export_proto(nearest_r10); 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 diff --git a/libgfortran/generated/nearest_r16.c b/libgfortran/generated/nearest_r16.c index 85499cbad147..474cf3609aec 100644 --- a/libgfortran/generated/nearest_r16.c +++ b/libgfortran/generated/nearest_r16.c @@ -26,7 +26,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -34,15 +41,15 @@ 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 diff --git a/libgfortran/generated/nearest_r4.c b/libgfortran/generated/nearest_r4.c index 8ef4f3164005..076df4b33e83 100644 --- a/libgfortran/generated/nearest_r4.c +++ b/libgfortran/generated/nearest_r4.c @@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -34,15 +37,15 @@ export_proto(nearest_r4); 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 diff --git a/libgfortran/generated/nearest_r8.c b/libgfortran/generated/nearest_r8.c index 40e6590252b2..8ac00b17c6d8 100644 --- a/libgfortran/generated/nearest_r8.c +++ b/libgfortran/generated/nearest_r8.c @@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -34,15 +37,15 @@ export_proto(nearest_r8); 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 diff --git a/libgfortran/generated/norm2_r10.c b/libgfortran/generated/norm2_r10.c index 64cf404e0a65..475a8cfa1104 100644 --- a/libgfortran/generated/norm2_r10.c +++ b/libgfortran/generated/norm2_r10.c @@ -29,7 +29,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include -#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, @@ -144,23 +147,23 @@ norm2_r10 (gfc_array_r10 * const restrict retarray, { 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 @@ -170,7 +173,7 @@ norm2_r10 (gfc_array_r10 * const restrict retarray, } } } - result = scale * sqrtl (result); + result = scale * MATHFUNC(sqrt) (result); *dest = result; } } diff --git a/libgfortran/generated/norm2_r16.c b/libgfortran/generated/norm2_r16.c index 1fc79ae278ba..acd57790a3d6 100644 --- a/libgfortran/generated/norm2_r16.c +++ b/libgfortran/generated/norm2_r16.c @@ -29,7 +29,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include -#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, @@ -144,23 +151,23 @@ norm2_r16 (gfc_array_r16 * const restrict retarray, { 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 @@ -170,7 +177,7 @@ norm2_r16 (gfc_array_r16 * const restrict retarray, } } } - result = scale * sqrtl (result); + result = scale * MATHFUNC(sqrt) (result); *dest = result; } } diff --git a/libgfortran/generated/norm2_r4.c b/libgfortran/generated/norm2_r4.c index 78f28dc77fd0..83e034fa613d 100644 --- a/libgfortran/generated/norm2_r4.c +++ b/libgfortran/generated/norm2_r4.c @@ -29,7 +29,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include -#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, @@ -144,23 +147,23 @@ norm2_r4 (gfc_array_r4 * const restrict retarray, { 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 @@ -170,7 +173,7 @@ norm2_r4 (gfc_array_r4 * const restrict retarray, } } } - result = scale * sqrtf (result); + result = scale * MATHFUNC(sqrt) (result); *dest = result; } } diff --git a/libgfortran/generated/norm2_r8.c b/libgfortran/generated/norm2_r8.c index fd9aba7416d2..88599e83c7f1 100644 --- a/libgfortran/generated/norm2_r8.c +++ b/libgfortran/generated/norm2_r8.c @@ -29,7 +29,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #include -#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, @@ -144,23 +147,23 @@ norm2_r8 (gfc_array_r8 * const restrict retarray, { 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 @@ -170,7 +173,7 @@ norm2_r8 (gfc_array_r8 * const restrict retarray, } } } - result = scale * sqrt (result); + result = scale * MATHFUNC(sqrt) (result); *dest = result; } } diff --git a/libgfortran/generated/rrspacing_r10.c b/libgfortran/generated/rrspacing_r10.c index 1889d0ffcf1e..298c9d1388bd 100644 --- a/libgfortran/generated/rrspacing_r10.c +++ b/libgfortran/generated/rrspacing_r10.c @@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -36,14 +39,14 @@ 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 } diff --git a/libgfortran/generated/rrspacing_r16.c b/libgfortran/generated/rrspacing_r16.c index 10de2448ebfa..3812435ba807 100644 --- a/libgfortran/generated/rrspacing_r16.c +++ b/libgfortran/generated/rrspacing_r16.c @@ -26,7 +26,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -36,14 +43,14 @@ rrspacing_r16 (GFC_REAL_16 s, int p) { 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 } diff --git a/libgfortran/generated/rrspacing_r4.c b/libgfortran/generated/rrspacing_r4.c index 48683db343f5..74a2826065b4 100644 --- a/libgfortran/generated/rrspacing_r4.c +++ b/libgfortran/generated/rrspacing_r4.c @@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -36,14 +39,14 @@ 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 } diff --git a/libgfortran/generated/rrspacing_r8.c b/libgfortran/generated/rrspacing_r8.c index 75f2244551cf..cf3641893078 100644 --- a/libgfortran/generated/rrspacing_r8.c +++ b/libgfortran/generated/rrspacing_r8.c @@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -36,14 +39,14 @@ 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 } diff --git a/libgfortran/generated/set_exponent_r10.c b/libgfortran/generated/set_exponent_r10.c index 3f5238ded518..f6435f89b500 100644 --- a/libgfortran/generated/set_exponent_r10.c +++ b/libgfortran/generated/set_exponent_r10.c @@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -35,7 +38,7 @@ GFC_REAL_10 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 diff --git a/libgfortran/generated/set_exponent_r16.c b/libgfortran/generated/set_exponent_r16.c index 4cd1ed5a4413..8842dad89936 100644 --- a/libgfortran/generated/set_exponent_r16.c +++ b/libgfortran/generated/set_exponent_r16.c @@ -26,7 +26,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -35,7 +42,7 @@ GFC_REAL_16 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 diff --git a/libgfortran/generated/set_exponent_r4.c b/libgfortran/generated/set_exponent_r4.c index 4d765c2f0354..f88060237e87 100644 --- a/libgfortran/generated/set_exponent_r4.c +++ b/libgfortran/generated/set_exponent_r4.c @@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -35,7 +38,7 @@ GFC_REAL_4 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 diff --git a/libgfortran/generated/set_exponent_r8.c b/libgfortran/generated/set_exponent_r8.c index ad8c3af5ebe7..9d6fd1395a11 100644 --- a/libgfortran/generated/set_exponent_r8.c +++ b/libgfortran/generated/set_exponent_r8.c @@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -35,7 +38,7 @@ GFC_REAL_8 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 diff --git a/libgfortran/generated/spacing_r10.c b/libgfortran/generated/spacing_r10.c index 10a907345f50..abf6784b3eed 100644 --- a/libgfortran/generated/spacing_r10.c +++ b/libgfortran/generated/spacing_r10.c @@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -37,13 +40,13 @@ 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 } diff --git a/libgfortran/generated/spacing_r16.c b/libgfortran/generated/spacing_r16.c index 82ef8353d493..c95c0bafde85 100644 --- a/libgfortran/generated/spacing_r16.c +++ b/libgfortran/generated/spacing_r16.c @@ -26,7 +26,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -37,13 +44,13 @@ spacing_r16 (GFC_REAL_16 s, int p, int emin, GFC_REAL_16 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); +#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 } diff --git a/libgfortran/generated/spacing_r4.c b/libgfortran/generated/spacing_r4.c index 7936ba982bfc..2be2906536df 100644 --- a/libgfortran/generated/spacing_r4.c +++ b/libgfortran/generated/spacing_r4.c @@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -37,13 +40,13 @@ 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 } diff --git a/libgfortran/generated/spacing_r8.c b/libgfortran/generated/spacing_r8.c index 3debe49249c8..aa140b53e518 100644 --- a/libgfortran/generated/spacing_r8.c +++ b/libgfortran/generated/spacing_r8.c @@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #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); @@ -37,13 +40,13 @@ 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 } diff --git a/libgfortran/m4/bessel.m4 b/libgfortran/m4/bessel.m4 index a4790dd8bf50..3df8f1d18490 100644 --- a/libgfortran/m4/bessel.m4 +++ b/libgfortran/m4/bessel.m4 @@ -31,11 +31,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 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`); @@ -69,28 +71,28 @@ bessel_jn_r'rtype_kind` ('rtype` * const restrict ret, int n1, int n2, 'rtype_na 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--) { @@ -102,7 +104,7 @@ bessel_jn_r'rtype_kind` ('rtype` * const restrict ret, int n1, int n2, 'rtype_na #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`); @@ -137,7 +139,7 @@ bessel_yn_r'rtype_kind` ('rtype` * const restrict ret, int n1, int n2, 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) @@ -149,19 +151,19 @@ bessel_yn_r'rtype_kind` ('rtype` * const restrict ret, int n1, int n2, } 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++) { diff --git a/libgfortran/m4/exponent.m4 b/libgfortran/m4/exponent.m4 index bb9cda8a1502..7302eb8b1a9a 100644 --- a/libgfortran/m4/exponent.m4 +++ b/libgfortran/m4/exponent.m4 @@ -27,7 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 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`); @@ -36,7 +38,7 @@ GFC_INTEGER_4 exponent_r'kind` ('real_type` s) { int ret; - frexp'q` (s, &ret); + MATHFUNC(frexp) (s, &ret); return ret; } diff --git a/libgfortran/m4/fraction.m4 b/libgfortran/m4/fraction.m4 index 2878127f52e0..419e801321f1 100644 --- a/libgfortran/m4/fraction.m4 +++ b/libgfortran/m4/fraction.m4 @@ -27,7 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 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`); @@ -36,7 +38,7 @@ 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' diff --git a/libgfortran/m4/mtype.m4 b/libgfortran/m4/mtype.m4 index 8e7e889bf0e7..fc4cecac5f5e 100644 --- a/libgfortran/m4/mtype.m4 +++ b/libgfortran/m4/mtype.m4 @@ -2,5 +2,12 @@ dnl Get type kind from filename. 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 diff --git a/libgfortran/m4/nearest.m4 b/libgfortran/m4/nearest.m4 index 98b417f3cba0..8fbe5000794c 100644 --- a/libgfortran/m4/nearest.m4 +++ b/libgfortran/m4/nearest.m4 @@ -27,7 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 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`); @@ -35,15 +37,15 @@ 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' diff --git a/libgfortran/m4/norm2.m4 b/libgfortran/m4/norm2.m4 index e1d6b972df4a..b2162ac23ed4 100644 --- a/libgfortran/m4/norm2.m4 +++ b/libgfortran/m4/norm2.m4 @@ -32,20 +32,22 @@ include(iparm.m4)dnl 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 @@ -54,6 +56,6 @@ ARRAY_FUNCTION(`0.0'Q, result += val * val; } }', -` result = scale * sqrt'q` (result);') +` result = scale * MATHFUNC(sqrt) (result);') #endif diff --git a/libgfortran/m4/rrspacing.m4 b/libgfortran/m4/rrspacing.m4 index f66bb3b758e6..3d75c66fa220 100644 --- a/libgfortran/m4/rrspacing.m4 +++ b/libgfortran/m4/rrspacing.m4 @@ -27,7 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 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`); @@ -37,14 +39,14 @@ rrspacing_r'kind` ('real_type` s, int p) { 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 } diff --git a/libgfortran/m4/set_exponent.m4 b/libgfortran/m4/set_exponent.m4 index 84200fd339bd..0d35d11c875a 100644 --- a/libgfortran/m4/set_exponent.m4 +++ b/libgfortran/m4/set_exponent.m4 @@ -27,7 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 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`); @@ -36,7 +38,7 @@ 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' diff --git a/libgfortran/m4/spacing.m4 b/libgfortran/m4/spacing.m4 index 62fa739c7888..9b43b740262b 100644 --- a/libgfortran/m4/spacing.m4 +++ b/libgfortran/m4/spacing.m4 @@ -27,7 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 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`); @@ -38,13 +40,13 @@ spacing_r'kind` ('real_type` s, int p, int emin, 'real_type` tiny) 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 } -- 2.43.5