This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: long double (was "strtold?")


On Thursday 02 April 2009 00:32:45 Howland Craig D (Craig) wrote:
> A few questions and two suggestions.
>
> Why is the defined(__GNUC__) term included in the general #if that is
> used?
> (It was obviously needed in the previous aliasing approach, but I don't
> see why it is present in this approach.)

My bad - this is a relict of the former patch. Thanks for the heads up.

> Why do the libm source files all have w_ as a prefix?  (e.g. w_atanl.c)
> (I have no idea why some of the existing source files are s_ and some
> are
> e_ and others are w_, along with other minor variations.  Do you know
> the naming convention?)
>
> Regardless of the w vs. s vs. e, the names are not consistent with what
> is presently there for float with respect to double.  For example,
> s_atan.c and sf_atan.c.  If we were to follow the existing convention,
> it should be wl_atan.c, for example.  Personally, I'd rather skip the
> silly prefixes and just make it the function name, e.g. atanl.c.  I
> propose that we do without the prefixes, starting clean for all of the
> long double routines (at least in libm, where the names were done that
> way).

>From looking at the sources it seems like w is for wrappers. Omitting the 
prefix sounds reasonable. In case a platform wants to override existing math 
routines there should be only one file for each routine. When implementing real 
long double routines we probably don't want them to be flagged as wrappers 
(assuming the overlay is done by matching the file names). The attached patch 
skips the prefix.

> Should libm/common/Makefile.am perhaps have a new macro named lsrc to be
> consistent with the present src and fsrc?
Sounds good, I changed that too.

> Suggestion:  instead of always using the same big expression
> +#if defined(__GNUC__) && (!defined(__STRICT_ANSI__) ||
> defined(__cplusplus) || \
> +     __STDC_VERSION__ >= 199901L) && (DBL_MANT_DIG == LDBL_MANT_DIG &&
> \
> +     LDBL_MIN_EXP == DBL_MIN_EXP && LDBL_MAX_EXP == DBL_MAX_EXP)
>
> define a shorter one that gets put into math.h.  For example:
>
> #if (!defined(__STRICT_ANSI__) || __STDC_VERSION__ > 199901L || \
> defined(__cplusplus))  &&  defined(LDBL_MANT_DIG)  &&  \
> 	(DBL_MANT_DIG == LDBL_MANT_DIG && \
> 	LDBL_MIN_EXP == DBL_MIN_EXP && LDBL_MAX_EXP == DBL_MAX_EXP)
>   #define _LDBL_EQ_DBL
> #endif
> [Notice that I added a check for LDBL_MANT_DIG being defined, as it
> is possible for long double to not exist if it's a C89 compiler but
> without STRICT_ANSI having been selected.  (This is my 2nd suggestion.)
> Since we've assumed the presence of float.h, checking any of the LDBL
> defines is the same as a configure check for AC_TYPE_LONG_DOUBLE.
> No need for configure when float.h can be assumed.]
>
> Then, in all of the libm files (and a few places in math.h, itself):
> #include <math.h>
> #if defined(_LBDL_EQ_DBL)
> ...
> #endif

The new patch defines _LBDL_EQ_DBL within _ansi.h because this header file is 
included from both stdlib.h and math.h. Let me know if there is a better place 
to put it.

> This is very similar to using AC_TYPE_LONG_DOUBLE_WIDER from one
> place, but is doing it via float.h instead of configure.
> In addition to being easier to read in the source files, it permits
> an easy modification of the if for all of the source in 1 place
> instead of needing to edit it in many, should the need ever arise.
> (An interesting future possibility is if a system used, for example,
> 128 bits for double and long double.  The present routines hard code
> 64 or 32 bits for double.  So if at that time there were 128-bit LD
> routines, _LDBL_EQ_DBL would not be defined, but _DBL_EQ_LDBL could
> be, which would then map the double routines to the long double.  And
> this will probably happen at about the same time that the US government
> actually returns to a balanced budget.)
>
> I've been planning a LDBL_EQ_DBL define for the real long double
> routines
> that I'm working on, but have it in a math library local include.
> "Promoting" it to math.h probably makes sense.
>
> A minor variation of the above is to also define something that says
> long double ought to be used, where a potential user-configured choice
> to not use long double even if it could be is also demonstrated:
> #if (!defined(__STRICT_ANSI__) || __STDC_VERSION__ > 199901L || \
> defined(__cplusplus))  &&  defined(LDBL_MANT_DIG)  &&  \
> 	!defined(SKIP_LDBL)
>   #define _USE_LDBL
> #endif
>
> Then, in all of the libm files (and a few places in math.h, itself):
> #include <math.h>
> #if defined(_USE_LDBL) && defined(_LBDL_EQ_DBL)
> ...
> #endif
> Or, down the road:
> #if defined(_USE_LDBL)
>  #if !defined(_LDBL_EQ_DBL)
> 	real function
>  # else
> 	wrapper
>  #endif
> #endif
> _USE_LDBL probably does not make sense in the source files, as would
> make more sense to leave the LDBL source out of the makefiles.  But it
> could make sense in header files.

Why would anyone with a platform where there's no difference between double and 
long double prefer the long double routine?

> Craig
Thanks
Ken

newlib/ChangeLog:

2009-04-02  Ken Werner  <ken.werner@de.ibm.com>

        * /libc/include/_ansi.h: Add _LDBL_EQ_DBL define.
        * libc/include/stdlib.h (strtold, wcstold): Declare.
        * libc/stdlib/strtold.c: New File.
        * libc/stdlib/wcstold.c: Likewise.
        * libc/stdlib/Makefile.am: Add strtold.c and wcstold.c.
        * libc/stdlib/Makefile.in: Regenerate.
        * libc/include/math.h (atanl, cosl, sinl, tanl, tanhl, frexpl, modfl, 
          ceill, fabsl, floorl, log1pl, expm1l, acosl, asinl, atan2l, coshl, 
          sinhl, expl, ldexpl, logl, log10l, powl, sqrtl, fmodl, hypotl, 
          copysignl, nanl, ilogbl, asinhl, cbrt, nextafterl, rintl, scalbnl, 
          exp2l, scalblnl, tgammal, nearbyintl, lrintl, llrintl, roundl, 
          lroundl, llround, llroundl, truncl, remquol, fdiml, fmaxl, fminl,
          fmal, acoshl, atanhl, remainderl, lgammal, erfl, erfcl): Declare.
        * src/newlib/libm/common/atanl.c: New File.
        * src/newlib/libm/common/cosl.c: Likewise.
        * src/newlib/libm/common/sinl.c: Likewise.
        * src/newlib/libm/common/modfl.c: Likewise.
        * src/newlib/libm/common/frexpl.c: Likewise.
        * src/newlib/libm/common/tanhl.c: Likewise.
        * src/newlib/libm/common/tanl.c: Likewise.
        * src/newlib/libm/common/expm1l.c: Likewise.
        * src/newlib/libm/common/log1pl.c: Likewise.
        * src/newlib/libm/common/ceill.c: Likewise.
        * src/newlib/libm/common/fabsl.c: Likewise.
        * src/newlib/libm/common/floorl.c: Likewise.
        * src/newlib/libm/common/acosl.c: Likewise.
        * src/newlib/libm/common/asinl.c: Likewise.
        * src/newlib/libm/common/atan2l.c: Likewise.
        * src/newlib/libm/common/coshl.c: Likewise.
        * src/newlib/libm/common/expl.c: Likewise.
        * src/newlib/libm/common/fmodl.c: Likewise.
        * src/newlib/libm/common/hypotl.c: Likewise.
        * src/newlib/libm/common/ldexpl.c: Likewise.
        * src/newlib/libm/common/log10l.c: Likewise.
        * src/newlib/libm/common/logl.c: Likewise.
        * src/newlib/libm/common/powl.c: Likewise.
        * src/newlib/libm/common/sqrtl.c: Likewise.
        * src/newlib/libm/common/copysignl.c: Likewise.
        * src/newlib/libm/common/ilogbl.c: Likewise.
        * src/newlib/libm/common/nanl.c: Likewise.
        * src/newlib/libm/common/cbrtl.c: Likewise.
        * src/newlib/libm/common/asinhl.c: Likewise.
        * src/newlib/libm/common/nextafterl.c: Likewise.
        * src/newlib/libm/common/rintl.c: Likewise.
        * src/newlib/libm/common/scalbnl.c: Likewise.
        * src/newlib/libm/common/exp2l.c: Likewise.
        * src/newlib/libm/common/fdiml.c: Likewise.
        * src/newlib/libm/common/fmal.c: Likewise.
        * src/newlib/libm/common/fmaxl.c: Likewise.
        * src/newlib/libm/common/fminl.c: Likewise.
        * src/newlib/libm/common/lrintl.c: Likewise.
        * src/newlib/libm/common/lroundl.c: Likewise.
        * src/newlib/libm/common/nearbyintl.c: Likewise.
        * src/newlib/libm/common/remquol.c: Likewise.
        * src/newlib/libm/common/roundl.c: Likewise.
        * src/newlib/libm/common/scalblnl.c: Likewise.
        * src/newlib/libm/common/truncl.c: Likewise.
        * src/newlib/libm/common/acoshl.c: Likewise.
        * src/newlib/libm/common/atanhl.c: Likewise.
        * src/newlib/libm/common/erfcl.c: Likewise.
        * src/newlib/libm/common/erfl.c: Likewise.
        * src/newlib/libm/common/lgammal.c: Likewise.
        * src/newlib/libm/common/remainderl.c: Likewise.
        * src/newlib/libm/common/tgammal.c: Likewise.
        * src/newlib/libm/common/sinhl.c: Likewise.
        * src/newlib/libm/common/llroundl.c: Likewise.
        * src/newlib/libm/common/Makefile.am: Add new files.
        * src/newlib/libm/common/Makefile.in: Regenerate.

Index: src/newlib/libc/include/math.h
===================================================================
--- src.orig/newlib/libc/include/math.h
+++ src/newlib/libc/include/math.h
@@ -337,12 +337,79 @@ extern float log2f _PARAMS((float));
 extern float hypotf _PARAMS((float, float));
 #endif /* ! defined (_REENT_ONLY) */
 
-/* Other long double precision functions.  */
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+/* Reentrant ANSI C functions.  */
+#ifndef __math_68881
+extern long double atanl _PARAMS((long double));
+extern long double cosl _PARAMS((long double));
+extern long double sinl _PARAMS((long double));
+extern long double tanl _PARAMS((long double));
+extern long double tanhl _PARAMS((long double));
+extern long double frexpl _PARAMS((long double value, int *));
+extern long double modfl _PARAMS((long double, long double *));
+extern long double ceill _PARAMS((long double));
+extern long double fabsl _PARAMS((long double));
+extern long double floorl _PARAMS((long double));
+extern long double log1pl _PARAMS((long double));
+extern long double expm1l _PARAMS((long double));
+#endif /* ! defined (__math_68881) */
+/* Non reentrant ANSI C functions.  */
+#ifndef _REENT_ONLY
+#ifndef __math_68881
+extern long double acosl _PARAMS((long double));
+extern long double asinl _PARAMS((long double));
+extern long double atan2l _PARAMS((long double, long double));
+extern long double coshl _PARAMS((long double));
+extern long double sinhl _PARAMS((long double));
+extern long double expl _PARAMS((long double));
+extern long double ldexpl _PARAMS((long double, int));
+extern long double logl _PARAMS((long double));
+extern long double log10l _PARAMS((long double));
+extern long double powl _PARAMS((long double, long double));
+extern long double sqrtl _PARAMS((long double));
+extern long double fmodl _PARAMS((long double, long double));
+extern long double hypotl _PARAMS((long double, long double));
+#endif /* ! defined (__math_68881) */
+#endif /* ! defined (_REENT_ONLY) */
+extern long double copysignl _PARAMS((long double, long double));
+extern long double nanl _PARAMS((const char *));
+extern int ilogbl _PARAMS((long double));
+extern long double asinhl _PARAMS((long double));
+extern long double cbrtl _PARAMS((long double));
+extern long double nextafterl _PARAMS((long double, long double));
+extern long double rintl _PARAMS((long double));
+extern long double scalbnl _PARAMS((long double, int));
+extern long double exp2l _PARAMS((long double));
+extern long double scalblnl _PARAMS((long double, long));
+extern long double tgammal _PARAMS((long double));
+extern long double nearbyintl _PARAMS((long double));
+extern long int lrintl _PARAMS((long double));
+extern long double roundl _PARAMS((long double));
+extern long lroundl _PARAMS((long double));
+extern _LONG_LONG_TYPE int llroundl _PARAMS((long double));
+extern long double truncl _PARAMS((long double));
+extern long double remquol _PARAMS((long double, long double, int *));
+extern long double fdiml _PARAMS((long double, long double));
+extern long double fmaxl _PARAMS((long double, long double));
+extern long double fminl _PARAMS((long double, long double));
+extern long double fmal _PARAMS((long double, long double, long double));
+#ifndef _REENT_ONLY
+extern long double acoshl _PARAMS((long double));
+extern long double atanhl _PARAMS((long double));
+extern long double remainderl _PARAMS((long double, long double));
+extern long double lgammal _PARAMS((long double));
+extern long double erfl _PARAMS((long double));
+extern long double erfcl _PARAMS((long double));
+#endif /* ! defined (_REENT_ONLY) */
+#else /* #if _LDBL_EQ_DBL */
 #ifdef __i386__
+/* Other long double precision functions.  */
 extern _LONG_DOUBLE rintl _PARAMS((_LONG_DOUBLE));
 extern long int lrintl _PARAMS((_LONG_DOUBLE));
 extern _LONG_LONG_TYPE llrintl _PARAMS((_LONG_DOUBLE));
 #endif /* __i386__ */
+#endif /* _LDBL_EQ_DBL */
 
 #endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L */
 
Index: src/newlib/libc/include/stdlib.h
===================================================================
--- src.orig/newlib/libc/include/stdlib.h
+++ src/newlib/libc/include/stdlib.h
@@ -198,6 +198,12 @@ int	_EXFUN(_system_r,(struct _reent *, c
 
 _VOID	_EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *));
 
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+extern long double strtold (const char *, char **);
+extern long double wcstold (const wchar_t *, wchar_t **);
+#endif /* LDBL_EQ_DBL */
+
 _END_STD_C
 
 #endif /* _STDLIB_H_ */
Index: src/newlib/libc/stdlib/Makefile.am
===================================================================
--- src.orig/newlib/libc/stdlib/Makefile.am
+++ src/newlib/libc/stdlib/Makefile.am
@@ -50,9 +50,11 @@ GENERAL_SOURCES = \
 	reallocf.c	\
 	sb_charsets.c	\
 	strtod.c	\
+	strtold.c	\
 	strtol.c	\
 	strtoul.c	\
 	wcstod.c	\
+	wcstold.c	\
 	wcstol.c	\
 	wcstoul.c	\
 	wcstombs.c	\
Index: src/newlib/libc/stdlib/strtold.c
===================================================================
--- /dev/null
+++ src/newlib/libc/stdlib/strtold.c
@@ -0,0 +1,11 @@
+#include <stdlib.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+strtold (const char *s00, char **se)
+{
+  return strtod(s00, se);
+}
+#endif /* _LDBL_EQ_DBL */
+
Index: src/newlib/libm/common/atanl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/atanl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+atanl (long double x)
+{
+  return atan(x);
+}
+#endif
+
Index: src/newlib/libm/common/cosl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/cosl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+cosl (long double x)
+{
+  return cos(x);
+}
+#endif
+
Index: src/newlib/libm/common/sinl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/sinl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+sinl (long double x)
+{
+  return sin(x);
+}
+#endif
+
Index: src/newlib/libm/common/Makefile.am
===================================================================
--- src.orig/newlib/libm/common/Makefile.am
+++ src/newlib/libm/common/Makefile.am
@@ -22,15 +22,23 @@ fsrc =	sf_finite.c sf_copysign.c sf_modf
 	sf_lround.c sf_llround.c sf_nearbyint.c sf_remquo.c sf_round.c \
 	sf_scalbln.c sf_trunc.c
 
+lsrc =	atanl.c cosl.c sinl.c tanl.c tanhl.c frexpl.c modfl.c ceill.c fabsl.c \
+	floorl.c log1pl.c expm1l.c acosl.c asinl.c atan2l.c coshl.c sinhl.c \
+	expl.c ldexpl.c logl.c log10l.c powl.c sqrtl.c fmodl.c hypotl.c \
+	copysignl.c nanl.c ilogbl.c asinhl.c cbrtl.c nextafterl.c rintl.c \
+	scalbnl.c exp2l.c scalblnl.c tgammal.c nearbyintl.c lrintl.c roundl.c \
+	lroundl.c llroundl.c truncl.c remquol.c fdiml.c fmaxl.c fminl.c fmal.c \
+	acoshl.c atanhl.c remainderl.c lgammal.c erfl.c erfcl.c
+
 libcommon_la_LDFLAGS = -Xcompiler -nostdlib
 
 if USE_LIBTOOL
 noinst_LTLIBRARIES = libcommon.la
-libcommon_la_SOURCES = $(src) $(fsrc)
+libcommon_la_SOURCES = $(src) $(fsrc) $(lsrc)
 noinst_DATA = objectlist.awk.in
 else
 noinst_LIBRARIES = lib.a
-lib_a_SOURCES = $(src) $(fsrc)
+lib_a_SOURCES = $(src) $(fsrc) $(lsrc)
 lib_a_CFLAGS = $(AM_CFLAGS)
 noinst_DATA =
 endif # USE_LIBTOOL
Index: src/newlib/libm/common/modfl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/modfl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+modfl (long double x, long double *iptr)
+{
+  return modf(x, iptr);
+}
+#endif
+
Index: src/newlib/libm/common/frexpl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/frexpl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+frexpl (long double x, int *eptr)
+{
+  return frexp(x, eptr);
+}
+#endif
+
Index: src/newlib/libm/common/tanhl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/tanhl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+tanhl (long double x)
+{
+  return tanh(x);
+}
+#endif
+
Index: src/newlib/libm/common/tanl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/tanl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+tanl (long double x)
+{
+  return tan(x);
+}
+#endif
+
Index: src/newlib/libm/common/expm1l.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/expm1l.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+expm1l (long double x)
+{
+  return expm1(x);
+}
+#endif
+
Index: src/newlib/libm/common/log1pl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/log1pl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+log1pl (long double x)
+{
+  return log1p(x);
+}
+#endif
+
Index: src/newlib/libm/common/ceill.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/ceill.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+ceill (long double x)
+{
+  return ceil(x);
+}
+#endif
+
Index: src/newlib/libm/common/fabsl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/fabsl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+fabsl (long double x)
+{
+  return fabs(x);
+}
+#endif
+
Index: src/newlib/libm/common/floorl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/floorl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+floorl (long double x)
+{
+  return floor(x);
+}
+#endif
+
Index: src/newlib/libm/common/acosl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/acosl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+acosl (long double x)
+{
+  return acos(x);
+}
+#endif
+
Index: src/newlib/libm/common/asinl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/asinl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+asinl (long double x)
+{
+  return asin(x);
+}
+#endif
+
Index: src/newlib/libm/common/atan2l.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/atan2l.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+atan2l (long double v, long double u)
+{
+  return atan2(v, u);
+}
+#endif
+
Index: src/newlib/libm/common/coshl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/coshl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+coshl (long double x)
+{
+  return cosh(x);
+}
+#endif
+
Index: src/newlib/libm/common/expl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/expl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+expl (long double x)
+{
+  return exp(x);
+}
+#endif
+
Index: src/newlib/libm/common/fmodl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/fmodl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+fmodl (long double x, long double y)
+{
+  return fmod(x, y);
+}
+#endif
+
Index: src/newlib/libm/common/hypotl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/hypotl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+hypotl (long double x, long double y)
+{
+  return hypot(x, y);
+}
+#endif
+
Index: src/newlib/libm/common/ldexpl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/ldexpl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+ldexpl (long double value, int exp)
+{
+  return ldexp(value, exp);
+}
+#endif
+
Index: src/newlib/libm/common/log10l.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/log10l.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+log10l (long double x)
+{
+  return log10(x);
+}
+#endif
+
Index: src/newlib/libm/common/logl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/logl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+logl (long double x)
+{
+  return log(x);
+}
+#endif
+
Index: src/newlib/libm/common/powl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/powl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+powl (long double x, long double y)
+{
+  return pow(x, y);
+}
+#endif
+
Index: src/newlib/libm/common/sqrtl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/sqrtl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+sqrtl (long double x)
+{
+  return sqrt(x);
+}
+#endif
+
Index: src/newlib/libm/common/copysignl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/copysignl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+copysignl (long double x, long double y)
+{
+  return copysign(x, y);
+}
+#endif
+
Index: src/newlib/libm/common/ilogbl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/ilogbl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+int
+ilogbl (long double x)
+{
+  return ilogb(x);
+}
+#endif
+
Index: src/newlib/libm/common/nanl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/nanl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+nanl (const char *tagp)
+{
+  return nan(tagp);
+}
+#endif
+
Index: src/newlib/libm/common/cbrtl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/cbrtl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+cbrtl (long double x)
+{
+  return cbrt(x);
+}
+#endif
+
Index: src/newlib/libm/common/asinhl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/asinhl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+asinhl (long double x)
+{
+  return asinh(x);
+}
+#endif
+
Index: src/newlib/libm/common/nextafterl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/nextafterl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+nextafterl (long double x, long double y)
+{
+  return nextafter(x, y);
+}
+#endif
+
Index: src/newlib/libm/common/rintl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/rintl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+rintl (long double x)
+{
+  return rint(x);
+}
+#endif
+
Index: src/newlib/libm/common/scalbnl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/scalbnl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+scalbnl (long double x, int n)
+{
+  return scalbn(x, n);
+}
+#endif
+
Index: src/newlib/libm/common/exp2l.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/exp2l.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+exp2l (long double x)
+{
+  return exp2(x);
+}
+#endif
+
Index: src/newlib/libm/common/fdiml.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/fdiml.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+fdiml (long double x, long double y)
+{
+  return fdim(x, y);
+}
+#endif
+
Index: src/newlib/libm/common/fmal.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/fmal.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+fmal (long double x, long double y, long double z)
+{
+  return fma(x, y, z);
+}
+#endif
+
Index: src/newlib/libm/common/fmaxl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/fmaxl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+fmaxl (long double x, long double y)
+{
+  return fmax(x, y);
+}
+#endif
+
Index: src/newlib/libm/common/fminl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/fminl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+fminl (long double x, long double y)
+{
+  return fmin(x, y);
+}
+#endif
+
Index: src/newlib/libm/common/lrintl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/lrintl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long int
+lrintl (long double x)
+{
+  return lrint(x);
+}
+#endif
+
Index: src/newlib/libm/common/lroundl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/lroundl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long
+lroundl (long double x)
+{
+  return lround(x);
+}
+#endif
+
Index: src/newlib/libm/common/nearbyintl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/nearbyintl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+nearbyintl (long double x)
+{
+  return nearbyint(x);
+}
+#endif
+
Index: src/newlib/libm/common/remquol.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/remquol.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+remquol (long double x, long double y, int *quo)
+{
+  return remquo(x, y, quo);
+}
+#endif
+
Index: src/newlib/libm/common/roundl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/roundl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+roundl (long double x)
+{
+  return round(x);
+}
+#endif
+
Index: src/newlib/libm/common/scalblnl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/scalblnl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+scalblnl (long double x, long n)
+{
+  return scalbln(x, n);
+}
+#endif
+
Index: src/newlib/libm/common/truncl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/truncl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+truncl (long double x)
+{
+  return trunc(x);
+}
+#endif
+
Index: src/newlib/libm/common/acoshl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/acoshl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+acoshl (long double x)
+{
+  return acosh(x);
+}
+#endif
+
Index: src/newlib/libm/common/atanhl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/atanhl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+atanhl (long double x)
+{
+  return atanh(x);
+}
+#endif
+
Index: src/newlib/libm/common/erfcl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/erfcl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+erfcl (long double x)
+{
+  return erfc(x);
+}
+#endif
+
Index: src/newlib/libm/common/erfl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/erfl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+erfl (long double x)
+{
+  return erf(x);
+}
+#endif
+
Index: src/newlib/libm/common/lgammal.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/lgammal.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+lgammal (long double x)
+{
+  return lgamma(x);
+}
+#endif
+
Index: src/newlib/libm/common/remainderl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/remainderl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+remainderl (long double x, long double p)
+{
+  return remainder(x, p);
+}
+#endif
+
Index: src/newlib/libm/common/tgammal.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/tgammal.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+tgammal (long double x)
+{
+  return tgamma(x);
+}
+#endif
+
Index: src/newlib/libm/common/sinhl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/sinhl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+sinhl (long double x)
+{
+  return sinh(x);
+}
+#endif
+
Index: src/newlib/libm/common/llroundl.c
===================================================================
--- /dev/null
+++ src/newlib/libm/common/llroundl.c
@@ -0,0 +1,11 @@
+#include <math.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long long int
+llroundl (long double x)
+{
+  return llround(x);
+}
+#endif
+
Index: src/newlib/libc/stdlib/wcstold.c
===================================================================
--- /dev/null
+++ src/newlib/libc/stdlib/wcstold.c
@@ -0,0 +1,11 @@
+#include <stdlib.h>
+
+/* On platforms where long double is as wide as double.  */
+#ifdef _LDBL_EQ_DBL
+long double
+wcstold (const wchar_t *nptr, wchar_t **endptr)
+{
+  return wcstod(nptr, endptr);
+}
+#endif /* _LDBL_EQ_DBL */
+
Index: src/newlib/libc/include/_ansi.h
===================================================================
--- src.orig/newlib/libc/include/_ansi.h
+++ src/newlib/libc/include/_ansi.h
@@ -96,4 +96,12 @@
 #define _END_STD_C
 #endif
 
+/* Check if long double is as wide as double. */
+#if (!defined(__STRICT_ANSI__) || __STDC_VERSION__ > 199901L || \
+  defined(__cplusplus)) && defined(LDBL_MANT_DIG) && \
+    (DBL_MANT_DIG == LDBL_MANT_DIG && LDBL_MIN_EXP == DBL_MIN_EXP && \
+    LDBL_MAX_EXP == DBL_MAX_EXP)
+ #define _LDBL_EQ_DBL
+#endif
+
 #endif /* _ANSIDECL_H_ */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]