Index: common/alias.h
===================================================================
--- common/alias.h (nonexistent)
+++ common/alias.h (working copy)
@@ -0,0 +1,32 @@
+
+#if !defined (__ASSEMBLER__)
+
+#if __SIZEOF_DOUBLE__ == __SIZEOF_FLOAT__
+#define DALIAS(X) __attribute__((__weak__,__alias__(#X)))
+#else
+#define DALIAS(X) /* empty */
+#endif
+
+#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_FLOAT__
+#define LALIAS(X) __attribute__((__weak__,__alias__(#X)))
+#else
+#define LALIAS(X) /* empty */
+#endif
+
+#else /* Assembly */
+
+.macro DALIAS name
+#if __SIZEOF_DOUBLE__ == __SIZEOF_FLOAT__
+.weak \name
+\name:
+#endif
+.endm
+
+.macro LALIAS name
+#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_FLOAT__
+.weak \name
+\name:
+#endif
+.endm
+
+#endif /* Assembly */
Property changes on: common/alias.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: common/ftoa_engine.h
===================================================================
--- common/ftoa_engine.h (revision 2548)
+++ common/ftoa_engine.h (working copy)
@@ -33,7 +33,7 @@
#ifndef __ASSEMBLER__
-int __ftoa_engine (double val, char *buf,
+int __ftoa_engine (float val, char *buf,
unsigned char prec, unsigned char maxdgs);
#endif
Index: include/ctype.h
===================================================================
--- include/ctype.h (revision 2548)
+++ include/ctype.h (working copy)
@@ -40,10 +40,6 @@ ctype.h - character conversion macros an
#ifndef __CTYPE_H_
#define __CTYPE_H_ 1
-#ifndef __ATTR_CONST__
-#define __ATTR_CONST__ __attribute__((__const__))
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -71,64 +67,64 @@ extern "C" {
Checks for an alphanumeric character. It is equivalent to (isalpha(c)
|| isdigit(c)). */
-extern int isalnum(int __c) __ATTR_CONST__;
+extern int isalnum(int __c);
/** \ingroup ctype
Checks for an alphabetic character. It is equivalent to (isupper(c) ||
islower(c)). */
-extern int isalpha(int __c) __ATTR_CONST__;
+extern int isalpha(int __c);
/** \ingroup ctype
Checks whether \c c is a 7-bit unsigned char value that fits into the
ASCII character set. */
-extern int isascii(int __c) __ATTR_CONST__;
+extern int isascii(int __c);
/** \ingroup ctype
Checks for a blank character, that is, a space or a tab. */
-extern int isblank(int __c) __ATTR_CONST__;
+extern int isblank(int __c);
/** \ingroup ctype
Checks for a control character. */
-extern int iscntrl(int __c) __ATTR_CONST__;
+extern int iscntrl(int __c);
/** \ingroup ctype
Checks for a digit (0 through 9). */
-extern int isdigit(int __c) __ATTR_CONST__;
+extern int isdigit(int __c);
/** \ingroup ctype
Checks for any printable character except space. */
-extern int isgraph(int __c) __ATTR_CONST__;
+extern int isgraph(int __c);
/** \ingroup ctype
Checks for a lower-case character. */
-extern int islower(int __c) __ATTR_CONST__;
+extern int islower(int __c);
/** \ingroup ctype
Checks for any printable character including space. */
-extern int isprint(int __c) __ATTR_CONST__;
+extern int isprint(int __c);
/** \ingroup ctype
Checks for any printable character which is not a space or an alphanumeric
character. */
-extern int ispunct(int __c) __ATTR_CONST__;
+extern int ispunct(int __c);
/** \ingroup ctype
@@ -136,20 +132,20 @@ extern int ispunct(int __c) __ATTR_CONST
space, form-feed ('\\f'), newline ('\\n'), carriage return ('\\r'),
horizontal tab ('\\t'), and vertical tab ('\\v'). */
-extern int isspace(int __c) __ATTR_CONST__;
+extern int isspace(int __c);
/** \ingroup ctype
Checks for an uppercase letter. */
-extern int isupper(int __c) __ATTR_CONST__;
+extern int isupper(int __c);
/** \ingroup ctype
Checks for a hexadecimal digits, i.e. one of 0 1 2 3 4 5 6 7 8 9 a b c d e
f A B C D E F. */
-extern int isxdigit(int __c) __ATTR_CONST__;
+extern int isxdigit(int __c);
/* @} */
@@ -170,19 +166,19 @@ extern int isxdigit(int __c) __ATTR_CONS
\warning Many people will be unhappy if you use this function. This
function will convert accented letters into random characters. */
-extern int toascii(int __c) __ATTR_CONST__;
+extern int toascii(int __c);
/** \ingroup ctype
Converts the letter \c c to lower case, if possible. */
-extern int tolower(int __c) __ATTR_CONST__;
+extern int tolower(int __c);
/** \ingroup ctype
Converts the letter \c c to upper case, if possible. */
-extern int toupper(int __c) __ATTR_CONST__;
+extern int toupper(int __c);
/* @} */
Index: include/math.h
===================================================================
--- include/math.h (revision 2548)
+++ include/math.h (working copy)
@@ -124,34 +124,50 @@ extern "C" {
/**
The cos() function returns the cosine of \a __x, measured in radians.
*/
-extern double cos(double __x) __ATTR_CONST__;
-#define cosf cos /**< The alias for cos(). */
+__ATTR_CONST__ extern float cosf (float __x);
+__ATTR_CONST__ extern double cos (double __x);
+__ATTR_CONST__ extern long double cosl (long double __x);
/**
The sin() function returns the sine of \a __x, measured in radians.
*/
-extern double sin(double __x) __ATTR_CONST__;
-#define sinf sin /**< The alias for sin(). */
+__ATTR_CONST__ extern float sinf (float __x);
+__ATTR_CONST__ extern double sin (double __x);
+__ATTR_CONST__ extern long double sinl (long double __x);
/**
The tan() function returns the tangent of \a __x, measured in radians.
*/
-extern double tan(double __x) __ATTR_CONST__;
-#define tanf tan /**< The alias for tan(). */
+__ATTR_CONST__ extern float tanf (float __x);
+__ATTR_CONST__ extern double tan (double __x);
+__ATTR_CONST__ extern long double tanl (long double __x);
/**
The fabs() function computes the absolute value of a floating-point
number \a __x.
*/
-extern double fabs(double __x) __ATTR_CONST__;
-#define fabsf fabs /**< The alias for fabs(). */
+static inline float fabsf (float __x)
+{
+ return __builtin_fabsf (__x);
+}
+
+static inline double fabs (double __x)
+{
+ return __builtin_fabs (__x);
+}
+
+static inline long double fabsl (long double __x)
+{
+ return __builtin_fabsl (__x);
+}
/**
The function fmod() returns the floating-point remainder of __x /
__y.
*/
-extern double fmod(double __x, double __y) __ATTR_CONST__;
-#define fmodf fmod /**< The alias for fmod(). */
+__ATTR_CONST__ extern float fmodf (float __x, float __y);
+__ATTR_CONST__ extern double fmod (double __x, double __y);
+__ATTR_CONST__ extern long double fmodl (long double __x, long double __y);
/**
The modf() function breaks the argument \a __x into integral and
@@ -165,24 +181,23 @@ extern double fmod(double __x, double __
the GCC 4.3 can replace this function with inline code that does not
permit to use NULL address for the avoiding of storing.
*/
-extern double modf(double __x, double *__iptr);
-
-/** An alias for modf(). */
extern float modff (float __x, float *__iptr);
+extern double modf (double __x, double *__iptr);
+extern long double modfl (long double __x, long double *__iptr);
/**
The sqrt() function returns the non-negative square root of \a __x.
*/
-extern double sqrt(double __x) __ATTR_CONST__;
-
-/** An alias for sqrt(). */
-extern float sqrtf (float) __ATTR_CONST__;
+__ATTR_CONST__ extern float sqrtf (float __x);
+__ATTR_CONST__ extern double sqrt (double __x);
+__ATTR_CONST__ extern long double sqrtl (long double __x);
/**
The cbrt() function returns the cube root of \a __x.
*/
-extern double cbrt(double __x) __ATTR_CONST__;
-#define cbrtf cbrt /**< The alias for cbrt(). */
+__ATTR_CONST__ extern float cbrtf (float __x);
+__ATTR_CONST__ extern double cbrt (double __x);
+__ATTR_CONST__ extern long double cbrtl (long double __x);
/**
The hypot() function returns sqrt(__x*__x + __y*__y). This
@@ -192,30 +207,34 @@ extern double cbrt(double __x) __ATTR_CO
formula is wise, since the error is much smaller. No underflow with
small \a __x and \a __y. No overflow if result is in range.
*/
-extern double hypot (double __x, double __y) __ATTR_CONST__;
-#define hypotf hypot /**< The alias for hypot(). */
+__ATTR_CONST__ extern float hypotf (float __x, float __y);
+__ATTR_CONST__ extern double hypot (double __x, double __y);
+__ATTR_CONST__ extern long double hypotl (long double __x, long double __y);
/**
The function square() returns __x * __x.
\note This function does not belong to the C standard definition.
*/
-extern double square(double __x) __ATTR_CONST__;
-#define squaref square /**< The alias for square(). */
+__ATTR_CONST__ extern float squaref (float __x);
+__ATTR_CONST__ extern double square (double __x);
+__ATTR_CONST__ extern long double squarel (long double __x);
/**
The floor() function returns the largest integral value less than or
equal to \a __x, expressed as a floating-point number.
*/
-extern double floor(double __x) __ATTR_CONST__;
-#define floorf floor /**< The alias for floor(). */
+__ATTR_CONST__ extern float floorf (float __x);
+__ATTR_CONST__ extern double floor (double __x);
+__ATTR_CONST__ extern long double floorl (long double __x);
/**
The ceil() function returns the smallest integral value greater than
or equal to \a __x, expressed as a floating-point number.
*/
-extern double ceil(double __x) __ATTR_CONST__;
-#define ceilf ceil /**< The alias for ceil(). */
+__ATTR_CONST__ extern float ceilf (float __x);
+__ATTR_CONST__ extern double ceil (double __x);
+__ATTR_CONST__ extern long double ceill (long double __x);
/**
The frexp() function breaks a floating-point number into a normalized
@@ -232,63 +251,72 @@ extern double ceil(double __x) __ATTR_CO
\note This implementation permits a zero pointer as a directive to
skip a storing the exponent.
*/
-extern double frexp(double __x, int *__pexp);
-#define frexpf frexp /**< The alias for frexp(). */
+__ATTR_CONST__ extern float frexpf (float __x, int *__pexp);
+__ATTR_CONST__ extern double frexp (double __x, int *__pexp);
+__ATTR_CONST__ extern long double frexpl (long double __x, int *__pexp);
/**
The ldexp() function multiplies a floating-point number by an integral
power of 2. It returns the value of \a __x times 2 raised to the power
\a __exp.
*/
-extern double ldexp(double __x, int __exp) __ATTR_CONST__;
-#define ldexpf ldexp /**< The alias for ldexp(). */
+__ATTR_CONST__ extern float ldexpf (float __x, int __exp);
+__ATTR_CONST__ extern double ldexp (double __x, int __exp);
+__ATTR_CONST__ extern long double ldexpl (long double __x, int __exp);
/**
The exp() function returns the exponential value of \a __x.
*/
-extern double exp(double __x) __ATTR_CONST__;
-#define expf exp /**< The alias for exp(). */
+__ATTR_CONST__ extern float expf (float __x);
+__ATTR_CONST__ extern double exp (double __x);
+__ATTR_CONST__ extern long double expl (long double __x);
/**
The cosh() function returns the hyperbolic cosine of \a __x.
*/
-extern double cosh(double __x) __ATTR_CONST__;
-#define coshf cosh /**< The alias for cosh(). */
+__ATTR_CONST__ extern float coshf (float __x);
+__ATTR_CONST__ extern double cosh (double __x);
+__ATTR_CONST__ extern long double coshl (long double __x);
/**
The sinh() function returns the hyperbolic sine of \a __x.
*/
-extern double sinh(double __x) __ATTR_CONST__;
-#define sinhf sinh /**< The alias for sinh(). */
+__ATTR_CONST__ extern float sinhf (float __x);
+__ATTR_CONST__ extern double sinh (double __x);
+__ATTR_CONST__ extern long double sinhl (long double __x);
/**
The tanh() function returns the hyperbolic tangent of \a __x.
*/
-extern double tanh(double __x) __ATTR_CONST__;
-#define tanhf tanh /**< The alias for tanh(). */
+__ATTR_CONST__ extern float tanhf (float __x);
+__ATTR_CONST__ extern double tanh (double __x);
+__ATTR_CONST__ extern long double tanhl (long double __x);
/**
The acos() function computes the principal value of the arc cosine of
\a __x. The returned value is in the range [0, pi] radians. A domain
error occurs for arguments not in the range [-1, +1].
*/
-extern double acos(double __x) __ATTR_CONST__;
-#define acosf acos /**< The alias for acos(). */
+__ATTR_CONST__ extern float acosf (float __x);
+__ATTR_CONST__ extern double acos (double __x);
+__ATTR_CONST__ extern long double acosl (long double __x);
/**
The asin() function computes the principal value of the arc sine of
\a __x. The returned value is in the range [-pi/2, pi/2] radians. A
domain error occurs for arguments not in the range [-1, +1].
*/
-extern double asin(double __x) __ATTR_CONST__;
-#define asinf asin /**< The alias for asin(). */
+__ATTR_CONST__ extern float asinf (float __x);
+__ATTR_CONST__ extern double asin (double __x);
+__ATTR_CONST__ extern long double asinl (long double __x);
/**
The atan() function computes the principal value of the arc tangent
of \a __x. The returned value is in the range [-pi/2, pi/2] radians.
*/
-extern double atan(double __x) __ATTR_CONST__;
-#define atanf atan /**< The alias for atan(). */
+__ATTR_CONST__ extern float atanf (float __x);
+__ATTR_CONST__ extern double atan (double __x);
+__ATTR_CONST__ extern long double atanl (long double __x);
/**
The atan2() function computes the principal value of the arc tangent
@@ -296,33 +324,38 @@ extern double atan(double __x) __ATTR_CO
the quadrant of the return value. The returned value is in the range
[-pi, +pi] radians.
*/
-extern double atan2(double __y, double __x) __ATTR_CONST__;
-#define atan2f atan2 /**< The alias for atan2(). */
+__ATTR_CONST__ extern float atan2f (float __y, float __x);
+__ATTR_CONST__ extern double atan2 (double __y, double __x);
+__ATTR_CONST__ extern long double atan2l (long double __y, long double __x);
/**
The log() function returns the natural logarithm of argument \a __x.
*/
-extern double log(double __x) __ATTR_CONST__;
-#define logf log /**< The alias for log(). */
+__ATTR_CONST__ extern float logf (float __x);
+__ATTR_CONST__ extern double log (double __x);
+__ATTR_CONST__ extern long double logl (long double __x);
/**
The log10() function returns the logarithm of argument \a __x to base 10.
*/
-extern double log10(double __x) __ATTR_CONST__;
-#define log10f log10 /**< The alias for log10(). */
+__ATTR_CONST__ extern float log10f (float __x);
+__ATTR_CONST__ extern double log10 (double __x);
+__ATTR_CONST__ extern long double log10l (long double __x);
/**
The function pow() returns the value of \a __x to the exponent \a __y.
*/
-extern double pow(double __x, double __y) __ATTR_CONST__;
-#define powf pow /**< The alias for pow(). */
+__ATTR_CONST__ extern float powf (float __x, float __y);
+__ATTR_CONST__ extern double pow (double __x, double __y);
+__ATTR_CONST__ extern long double powl (long double __x, long double __y);
/**
The function isnan() returns 1 if the argument \a __x represents a
"not-a-number" (NaN) object, otherwise 0.
*/
-extern int isnan(double __x) __ATTR_CONST__;
-#define isnanf isnan /**< The alias for isnan(). */
+__ATTR_CONST__ extern int isnanf (float __x);
+__ATTR_CONST__ extern int isnan (double __x);
+__ATTR_CONST__ extern int isnanl (long double __x);
/**
The function isinf() returns 1 if the argument \a __x is positive
@@ -331,14 +364,15 @@ extern int isnan(double __x) __ATTR_CONS
\note The GCC 4.3 can replace this function with inline code that
returns the 1 value for both infinities (gcc bug #35509).
*/
-extern int isinf(double __x) __ATTR_CONST__;
-#define isinff isinf /**< The alias for isinf(). */
+__ATTR_CONST__ extern int isinff (float __x);
+__ATTR_CONST__ extern int isinf (double __x);
+__ATTR_CONST__ extern int isinfl (long double __x);
/**
The isfinite() function returns a nonzero value if \a __x is finite:
not plus or minus infinity, and not NaN.
*/
-__ATTR_CONST__ static inline int isfinite (double __x)
+__ATTR_CONST__ static inline int isfinitef (float __x)
{
unsigned char __exp;
__asm__ (
@@ -346,17 +380,34 @@ __ATTR_CONST__ static inline int isfinit
"lsl %0 \n\t"
"mov %0, %D1 \n\t"
"rol %0 "
- : "=r" (__exp)
+ : "=&r" (__exp)
: "r" (__x) );
return __exp != 0xff;
}
-#define isfinitef isfinite /**< The alias for isfinite(). */
+
+#if __SIZEOF_DOUBLE__ == __SIZEOF_FLOAT__
+static inline int isfinite (double __x)
+{
+ return isfinitef (__x);
+}
+#else
+int isfinite (double __x);
+#endif /* double = float */
+
+#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_FLOAT__
+static inline int isfinitel (long double __x)
+{
+ return isfinitef (__x);
+}
+#else
+int isfinitel (long double __x);
+#endif /* long double = float */
/**
The copysign() function returns \a __x but with the sign of \a __y.
They work even if \a __x or \a __y are NaN or zero.
*/
-__ATTR_CONST__ static inline double copysign (double __x, double __y)
+__ATTR_CONST__ static inline float copysignf (float __x, float __y)
{
__asm__ (
"bst %D2, 7 \n\t"
@@ -365,7 +416,26 @@ __ATTR_CONST__ static inline double copy
: "0" (__x), "r" (__y) );
return __x;
}
-#define copysignf copysign /**< The alias for copysign(). */
+
+__ATTR_CONST__ static inline double copysign (double __x, double __y)
+{
+ __asm__ (
+ "bst %r1+%2-1, 7" "\n\t"
+ "bld %r0+%2-1, 7"
+ : "+r" (__x)
+ : "r" (__y), "n" (__SIZEOF_DOUBLE__));
+ return __x;
+}
+
+__ATTR_CONST__ static inline long double copysignl (long double __x, long double __y)
+{
+ __asm__ (
+ "bst %r1+%2-1, 7" "\n\t"
+ "bld %r0+%2-1, 7"
+ : "+r" (__x)
+ : "r" (__y), "n" (__SIZEOF_LONG_DOUBLE__));
+ return __x;
+}
/**
The signbit() function returns a nonzero value if the value of \a __x
@@ -374,15 +444,17 @@ __ATTR_CONST__ static inline double copy
comparison `-0.0 < 0.0' is false, but `signbit (-0.0)' will return a
nonzero value.
*/
-extern int signbit (double __x) __ATTR_CONST__;
-#define signbitf signbit /**< The alias for signbit(). */
+__ATTR_CONST__ extern int signbitf (float __x);
+__ATTR_CONST__ extern int signbit (double __x);
+__ATTR_CONST__ extern int signbitl (long double __x);
/**
The fdim() function returns max(__x - __y, 0). If \a __x or
\a __y or both are NaN, NaN is returned.
*/
-extern double fdim (double __x, double __y) __ATTR_CONST__;
-#define fdimf fdim /**< The alias for fdim(). */
+__ATTR_CONST__ extern float fdimf (float __x, float __y);
+__ATTR_CONST__ extern double fdim (double __x, double __y);
+__ATTR_CONST__ extern long double fdiml (long double __x, long double __y);
/**
The fma() function performs floating-point multiply-add. This is the
@@ -390,31 +462,35 @@ extern double fdim (double __x, double _
not rounded to the destination type. This can sometimes improve the
precision of a calculation.
*/
-extern double fma (double __x, double __y, double __z) __ATTR_CONST__;
-#define fmaf fma /**< The alias for fma(). */
+__ATTR_CONST__ extern float fmaf (float __x, float __y, float __z);
+__ATTR_CONST__ extern double fma (double __x, double __y, double __z);
+__ATTR_CONST__ extern long double fmal (long double __x, long double __y, long double __z);
/**
The fmax() function returns the greater of the two values \a __x and
\a __y. If an argument is NaN, the other argument is returned. If
both arguments are NaN, NaN is returned.
*/
-extern double fmax (double __x, double __y) __ATTR_CONST__;
-#define fmaxf fmax /**< The alias for fmax(). */
+__ATTR_CONST__ extern float fmaxf (float __x, float __y);
+__ATTR_CONST__ extern double fmax (double __x, double __y);
+__ATTR_CONST__ extern long double fmaxl (long double __x, long double __y);
/**
The fmin() function returns the lesser of the two values \a __x and
\a __y. If an argument is NaN, the other argument is returned. If
both arguments are NaN, NaN is returned.
*/
-extern double fmin (double __x, double __y) __ATTR_CONST__;
-#define fminf fmin /**< The alias for fmin(). */
+__ATTR_CONST__ extern float fminf (float __x, float __y);
+__ATTR_CONST__ extern double fmin (double __x, double __y);
+__ATTR_CONST__ extern long double fminl (long double __x, long double __y);
/**
The trunc() function rounds \a __x to the nearest integer not larger
in absolute value.
*/
-extern double trunc (double __x) __ATTR_CONST__;
-#define truncf trunc /**< The alias for trunc(). */
+__ATTR_CONST__ extern float truncf (float __x);
+__ATTR_CONST__ extern double trunc (double __x);
+__ATTR_CONST__ extern long double truncl (long double __x);
/**
The round() function rounds \a __x to the nearest integer, but rounds
@@ -424,8 +500,9 @@ extern double trunc (double __x) __ATTR_
\return The rounded value. If \a __x is an integral or infinite, \a
__x itself is returned. If \a __x is \c NaN, then \c NaN is returned.
*/
-extern double round (double __x) __ATTR_CONST__;
-#define roundf round /**< The alias for round(). */
+__ATTR_CONST__ extern float roundf (float __x);
+__ATTR_CONST__ extern double round (double __x);
+__ATTR_CONST__ extern long double roundl (long double __x);
/**
The lround() function rounds \a __x to the nearest integer, but rounds
@@ -437,8 +514,9 @@ extern double round (double __x) __ATTR_
or an overflow was, this realization returns the \c LONG_MIN value
(0x80000000).
*/
-extern long lround (double __x) __ATTR_CONST__;
-#define lroundf lround /**< The alias for lround(). */
+__ATTR_CONST__ extern long lroundf (float __x);
+__ATTR_CONST__ extern long lround (double __x);
+__ATTR_CONST__ extern long lroundl (long double __x);
/**
The lrint() function rounds \a __x to the nearest integer, rounding the
@@ -451,8 +529,9 @@ extern long lround (double __x) __ATTR_C
number or an overflow was, this realization returns the \c LONG_MIN
value (0x80000000).
*/
-extern long lrint (double __x) __ATTR_CONST__;
-#define lrintf lrint /**< The alias for lrint(). */
+__ATTR_CONST__ extern long lrintf (float __x);
+__ATTR_CONST__ extern long lrint (double __x);
+__ATTR_CONST__ extern long lrintl (long double __x);
#ifdef __cplusplus
}
Index: include/stdlib.h
===================================================================
--- include/stdlib.h (revision 2548)
+++ include/stdlib.h (working copy)
@@ -107,6 +107,10 @@ typedef int (*__compar_fn_t)(const void
# endif
#endif
+#ifndef __ATTR_ALWAYS_INLINE__
+#define __ATTR_ALWAYS_INLINE__ __inline__ __attribute__((__always_inline__))
+#endif
+
#endif
/** The abort() function causes abnormal program termination to occur.
@@ -115,22 +119,30 @@ typedef int (*__compar_fn_t)(const void
effectively halted by entering an infinite loop. */
extern void abort(void) __ATTR_NORETURN__;
+#ifndef __DOXYGEN__
+static __ATTR_ALWAYS_INLINE__
+int abs (int __i)
+{
+ return __builtin_abs (__i);
+}
+#endif
/** The abs() function computes the absolute value of the integer \c i.
\note The abs() and labs() functions are builtins of gcc.
*/
extern int abs(int __i) __ATTR_CONST__;
+
#ifndef __DOXYGEN__
-#define abs(__i) __builtin_abs(__i)
+static __ATTR_ALWAYS_INLINE__
+long labs (long __i)
+{
+ return __builtin_labs (__i);
+}
#endif
-
/** The labs() function computes the absolute value of the long integer
\c i.
\note The abs() and labs() functions are builtins of gcc.
*/
extern long labs(long __i) __ATTR_CONST__;
-#ifndef __DOXYGEN__
-#define labs(__i) __builtin_labs(__i)
-#endif
/**
The bsearch() function searches an array of \c nmemb objects, the
@@ -347,7 +359,9 @@ extern void *calloc(size_t __nele, size_
*/
extern void *realloc(void *__ptr, size_t __size) __ATTR_MALLOC__;
+extern float strtof(const char *__nptr, char **__endptr);
extern double strtod(const char *__nptr, char **__endptr);
+extern long double strtold(const char *__nptr, char **__endptr);
/** \ingroup avr_stdlib
\fn double atof (const char *nptr)
@@ -358,7 +372,9 @@ extern double strtod(const char *__nptr,
It is equivalent to calling
\code strtod(nptr, (char **)0); \endcode
*/
+extern float atoff(const char *__nptr);
extern double atof(const char *__nptr);
+extern long double atofl(const char *__nptr);
/** Highest number that can be generated by rand(). */
#define RAND_MAX 0x7FFF
@@ -646,8 +662,12 @@ extern long random_r(unsigned long *__ct
The dtostre() function returns the pointer to the converted string \c s.
*/
+extern char *ftostre(float __val, char *__s, unsigned char __prec,
+ unsigned char __flags);
extern char *dtostre(double __val, char *__s, unsigned char __prec,
unsigned char __flags);
+extern char *ldtostre(long double __val, char *__s, unsigned char __prec,
+ unsigned char __flags);
/**
\ingroup avr_stdlib
@@ -663,8 +683,12 @@ extern char *dtostre(double __val, char
The dtostrf() function returns the pointer to the converted string \c s.
*/
+extern char *ftostrf(float __val, signed char __width,
+ unsigned char __prec, char *__s);
extern char *dtostrf(double __val, signed char __width,
unsigned char __prec, char *__s);
+extern char *ldtostrf(long double __val, signed char __width,
+ unsigned char __prec, char *__s);
/**
\ingroup avr_stdlib
Index: include/time.h
===================================================================
--- include/time.h (revision 2548)
+++ include/time.h (working copy)
@@ -480,7 +480,9 @@ extern "C" {
time_t sun_set(const time_t * timer);
/** Returns the declination of the sun in radians. */
+ float solar_declinationf(const time_t * timer);
double solar_declination(const time_t * timer);
+ long double solar_declinationl(const time_t * timer);
/**
Returns an approximation to the phase of the moon.
Index: libc/stdio/vfprintf.c
===================================================================
--- libc/stdio/vfprintf.c (revision 2548)
+++ libc/stdio/vfprintf.c (working copy)
@@ -123,6 +123,7 @@
#define FL_ALTLWR 0x20
#define FL_NEGATIVE 0x40
#define FL_LONG 0x80
+#define FL_LONG_DOUBLE (__SIZEOF_LONG_DOUBLE__ != __SIZEOF_DOUBLE__ ? 0x08 : 0)
ATTRIBUTE_CLIB_SECTION
int
@@ -163,13 +164,20 @@ vfprintf (FILE * stream, const char *fmt
flags |= FL_LONG;
continue;
}
+ if (c == 'L') {
+ flags |= FL_LONG_DOUBLE;
+ continue;
+ }
break;
}
/* Only a format character is valid. */
if (c && strchr_P (PSTR("EFGefg"), c)) {
- (void) va_arg (ap, double);
+ if (flags & FL_LONG_DOUBLE)
+ (void) va_arg (ap, long double);
+ else
+ (void) va_arg (ap, double);
putc ('?', stream);
continue;
}
@@ -219,7 +227,7 @@ vfprintf (FILE * stream, const char *fmt
goto ultoa;
case 'p':
flags |= FL_ALT;
- /* no break */
+ /* fallthrough */
case 'x':
flags |= (FL_ALTHEX | FL_ALTLWR);
base = 16;
@@ -282,6 +290,10 @@ vfprintf (FILE * stream, const char *fmt
#define FL_FLTEXP FL_PREC
#define FL_FLTFIX FL_LONG
+/* %Lf might not be the same like %f. */
+#define XFL_LONG ((__SIZEOF_LONG_DOUBLE__ != __SIZEOF_DOUBLE__) << 0)
+
+
ATTRIBUTE_CLIB_SECTION
int vfprintf (FILE * stream, const char *fmt, va_list ap)
{
@@ -290,6 +302,7 @@ int vfprintf (FILE * stream, const char
unsigned char width;
unsigned char prec;
unsigned char buf[11]; /* size for -1 in octal, without '\0' */
+ unsigned char xflags;
stream->len = 0;
@@ -308,6 +321,8 @@ int vfprintf (FILE * stream, const char
putc (c, stream);
}
+ if (XFL_LONG)
+ xflags = 0;
flags = 0;
width = 0;
prec = 0;
@@ -354,6 +369,10 @@ int vfprintf (FILE * stream, const char
flags |= FL_LONG;
continue;
}
+ if (c == 'L') {
+ xflags |= XFL_LONG;
+ continue;
+ }
if (c == 'h')
continue;
}
@@ -367,7 +386,19 @@ int vfprintf (FILE * stream, const char
# error
#endif
-#if PRINTF_LEVEL >= PRINTF_FLT
+ /* We only support 32-bit floating point, hence if double is 64 bits
+ wide, there is nothing to do here because ... will promote float
+ to double. */
+#if (PRINTF_LEVEL >= PRINTF_FLT) && (__SIZEOF_DOUBLE__ == __SIZEOF_FLOAT__)
+
+ if ((xflags & XFL_LONG)
+ && ((c >= 'E' && c <= 'G') || (c >= 'e' && c <= 'g')))
+ {
+ (void) va_arg (ap, long double);
+ buf[0] = '?';
+ goto buf_addr;
+ }
+
if (c >= 'E' && c <= 'G') {
flags |= FL_FLTUPP;
c += 'e' - 'E';
@@ -540,9 +571,12 @@ int vfprintf (FILE * stream, const char
# undef ndigs
}
-#else /* to: PRINTF_LEVEL >= PRINTF_FLT */
+#else /* to: PRINTF_LEVEL >= PRINTF_FLT && double == float */
if ((c >= 'E' && c <= 'G') || (c >= 'e' && c <= 'g')) {
- (void) va_arg (ap, double);
+ if (xflags & XFL_LONG)
+ (void) va_arg (ap, long double);
+ else
+ (void) va_arg (ap, double);
buf[0] = '?';
goto buf_addr;
}
@@ -557,9 +591,7 @@ int vfprintf (FILE * stream, const char
case 'c':
buf[0] = va_arg (ap, int);
-#if PRINTF_LEVEL < PRINTF_FLT
- buf_addr:
-#endif
+ buf_addr: if (0) goto buf_addr;
pnt = (char *)buf;
size = 1;
goto no_pgmstring;
@@ -618,7 +650,7 @@ int vfprintf (FILE * stream, const char
goto ultoa;
case 'p':
flags |= FL_ALT;
- /* no break */
+ /* fallthrough */
case 'x':
if (flags & FL_ALT)
flags |= FL_ALTHEX;
Index: libc/stdio/vfscanf.c
===================================================================
--- libc/stdio/vfscanf.c (revision 2548)
+++ libc/stdio/vfscanf.c (working copy)
@@ -396,7 +396,7 @@ conv_brk (FILE *stream, width_t width, c
long to float. Instead it uses a signed long to float conversion
function along with a large inline code to correct the result.
Seems, GCC 4.3 does not use it also. */
-extern double __floatunsisf (unsigned long);
+extern float __floatunsisf (unsigned long);
PROGMEM static const float pwr_p10 [6] = {
1e+1, 1e+2, 1e+4, 1e+8, 1e+16, 1e+32
@@ -598,7 +598,7 @@ static int skip_spaces (FILE *stream)
to char (rather than int).
- the character \c l indicating that the argument is a pointer
to long int (rather than int, for integer
- type conversions), or a pointer to \c double (for floating
+ type conversions), or a pointer to \c float (for floating
point conversions),
In addition, a maximal field width may be specified as a nonzero
Index: libc/stdlib/Files.am
===================================================================
--- libc/stdlib/Files.am (revision 2548)
+++ libc/stdlib/Files.am (working copy)
@@ -85,4 +85,8 @@ stdlib_a_extra_dist = \
atoi.c \
atol.c
+malloc.o: AVRLIB_CFLAGS += -Wno-maybe-uninitialized
+
+qsort.o: AVRLIB_CFLAGS += -Wno-sign-compare
+
# vim: set ft=make:
Index: libc/stdlib/abs.c
===================================================================
--- libc/stdlib/abs.c (revision 2548)
+++ libc/stdlib/abs.c (working copy)
@@ -30,8 +30,10 @@
#include "sectionname.h"
ATTRIBUTE_CLIB_SECTION
+__attribute__((__weak__)) int abs_impl (int) __asm ("abs");
+
int
-abs(int x)
+abs_impl (int x)
{
return (x < 0) ? -x : x;
}
Index: libc/stdlib/atof.S
===================================================================
--- libc/stdlib/atof.S (revision 2548)
+++ libc/stdlib/atof.S (working copy)
@@ -31,15 +31,18 @@
#ifndef __DOXYGEN__
#include "macros.inc"
+#include "alias.h"
ASSEMBLY_CLIB_SECTION
- .global atof
- .type atof, "function"
-atof:
+ .global atoff
+ .type atoff, "function"
+atoff:
+DALIAS atof
+LALIAS atofl
clr r22
clr r23
XJMP strtod
- .size atof, .-atof
+ .size atoff, .-atoff
.end
#endif /* !__DOXYGEN__ */
Index: libc/stdlib/dtoa_conv.h
===================================================================
--- libc/stdlib/dtoa_conv.h (revision 2548)
+++ libc/stdlib/dtoa_conv.h (working copy)
@@ -33,14 +33,8 @@
#include
-int dtoa_prf (double val, char *s, unsigned char width, unsigned char prec,
+int ftoa_prf (float val, char *s, unsigned char width, unsigned char prec,
unsigned char flags);
-int dtoa_lim (double val, char *s, unsigned char width, unsigned char prec,
- unsigned char flags);
-int dtoa_cln (double val, char *s, unsigned char ndigs, unsigned char flags);
-
-void d2stream (double val, FILE *stream,
- unsigned char width, unsigned char prec, unsigned char flags);
#define DTOA_SPACE 0x01 /* put space for positives */
#define DTOA_PLUS 0x02 /* put '+' for positives */
Index: libc/stdlib/dtoa_prf.c
===================================================================
--- libc/stdlib/dtoa_prf.c (revision 2548)
+++ libc/stdlib/dtoa_prf.c (working copy)
@@ -31,10 +31,11 @@
#include "ftoa_engine.h"
#include "dtoa_conv.h"
#include "sectionname.h"
+#include "alias.h"
ATTRIBUTE_CLIB_SECTION
int
-dtoa_prf (double val, char *s, unsigned char width, unsigned char prec,
+ftoa_prf (float val, char *s, unsigned char width, unsigned char prec,
unsigned char flags)
{
int exp;
@@ -149,4 +150,9 @@ dtoa_prf (double val, char *s, unsigned
return 0;
}
- /*** end of file ***/
+
+DALIAS (ftoa_prf)
+int dtoa_prf (double, char*, unsigned char, unsigned char, unsigned char);
+
+LALIAS (ftoa_prf)
+int ldtoa_prf (long double, char*, unsigned char, unsigned char, unsigned char);
Index: libc/stdlib/dtostre.c
===================================================================
--- libc/stdlib/dtostre.c (revision 2548)
+++ libc/stdlib/dtostre.c (working copy)
@@ -32,10 +32,11 @@
#include
#include "ftoa_engine.h"
#include "sectionname.h"
+#include "alias.h"
ATTRIBUTE_CLIB_SECTION
char *
-dtostre (double val, char *sbeg, unsigned char prec, unsigned char flags)
+ftostre (float val, char *sbeg, unsigned char prec, unsigned char flags)
{
__attribute__((progmem)) static const char str_nan[2][4] =
{"nan", "NAN"};
@@ -49,7 +50,7 @@ dtostre (double val, char *sbeg, unsigne
if (prec > 7) prec = 7;
exp = __ftoa_engine (val, sbeg, prec, 0);
- d = s = sbeg;
+ s = d = sbeg;
vtype = *s++;
if ((vtype & FTOA_MINUS) && !(vtype & FTOA_NAN)) /* like 'Glibc' */
@@ -106,4 +107,9 @@ dtostre (double val, char *sbeg, unsigne
ret:
return sbeg;
}
- /*** end of file ***/
+
+DALIAS (ftostre)
+char* dtostre (double, char*, unsigned char, unsigned char);
+
+LALIAS (ftostre)
+char* ldtostre (long double, char*, unsigned char, unsigned char);
Index: libc/stdlib/dtostrf.c
===================================================================
--- libc/stdlib/dtostrf.c (revision 2548)
+++ libc/stdlib/dtostrf.c (working copy)
@@ -32,6 +32,7 @@
#include "ftoa_engine.h"
#include "dtoa_conv.h"
#include "sectionname.h"
+#include "alias.h"
/* ??? Is 'width' a signed value?
dtostrf.S comment:
@@ -47,13 +48,18 @@
ATTRIBUTE_CLIB_SECTION
char *
-dtostrf (double val, signed char width, unsigned char prec, char *sout)
+ftostrf (float val, signed char width, unsigned char prec, char *sout)
{
unsigned char flags;
/* DTOA_UPPER: for compatibility with avr-libc <= 1.4 with NaNs */
flags = width < 0 ? DTOA_LEFT | DTOA_UPPER : DTOA_UPPER;
- dtoa_prf (val, sout, abs(width), prec, flags);
+ ftoa_prf (val, sout, abs(width), prec, flags);
return sout;
}
- /*** end of file ***/
+
+DALIAS (ftostrf)
+char* dtostrf (double, signed char, unsigned char, char*);
+
+LALIAS (ftostrf)
+char* ldtostrf (long double, signed char, unsigned char, char*);
Index: libc/stdlib/getenv.c
===================================================================
--- libc/stdlib/getenv.c (revision 2548)
+++ libc/stdlib/getenv.c (working copy)
@@ -3,5 +3,6 @@
char *
getenv (const char *name)
{
+ (void) name;
return NULL;
}
Index: libc/stdlib/labs.c
===================================================================
--- libc/stdlib/labs.c (revision 2548)
+++ libc/stdlib/labs.c (working copy)
@@ -30,8 +30,11 @@
#include "sectionname.h"
ATTRIBUTE_CLIB_SECTION
+__attribute__((__weak__))
+long labs_impl (long x) __asm ("labs");
+
long
-labs(long x)
+labs_impl (long x)
{
return (x < 0) ? -x : x;
}
Index: libc/stdlib/strtod.c
===================================================================
--- libc/stdlib/strtod.c (revision 2548)
+++ libc/stdlib/strtod.c (working copy)
@@ -38,14 +38,21 @@
#include
#include
#include
-#include /* INFINITY, NAN */
+#include
#include
#include "sectionname.h"
+#include "alias.h"
+
+
+#define INFINITYf (__builtin_inff())
+#define NANf (__builtin_nanf(""))
+
+extern int isfinitef (float);
/* Only GCC 4.2 calls the library function to convert an unsigned long
to float. Other GCC-es (including 4.3) use a signed long to float
conversion along with a large inline code to correct the result. */
-extern double __floatunsisf (unsigned long);
+extern float __floatunsisf (unsigned long);
PROGMEM static const float pwr_p10 [6] = {
1e+1, 1e+2, 1e+4, 1e+8, 1e+16, 1e+32
@@ -85,8 +92,8 @@ PROGMEM static const char pstr_nan[] = {
returned and \c ERANGE is stored in \c errno.
*/
ATTRIBUTE_CLIB_SECTION
-double
-strtod (const char * nptr, char ** endptr)
+float
+strtof (const char * nptr, char ** endptr)
{
union {
unsigned long u32;
@@ -123,7 +130,7 @@ strtod (const char * nptr, char ** endpt
nptr += 5;
if (endptr)
*endptr = (char *)nptr;
- return flag & FL_MINUS ? -INFINITY : +INFINITY;
+ return flag & FL_MINUS ? -INFINITYf : +INFINITYf;
}
/* NAN() construction is not realised.
@@ -131,7 +138,7 @@ strtod (const char * nptr, char ** endpt
if (!strncasecmp_P (nptr - 1, pstr_nan, 3)) {
if (endptr)
*endptr = (char *)nptr + 2;
- return NAN;
+ return NANf;
}
x.u32 = 0;
@@ -217,11 +224,17 @@ strtod (const char * nptr, char ** endpt
}
nptr -= sizeof(float);
}
- if (!isfinite(x.flt) || x.flt == 0)
+ if (!isfinitef(x.flt) || x.flt == 0)
errno = ERANGE;
}
return x.flt;
}
+DALIAS (strtof)
+double strtod (const char*, char**);
+
+LALIAS (strtof)
+long double strtold (const char*, char**);
+
#endif
Index: libc/time/daylight_seconds.c
===================================================================
--- libc/time/daylight_seconds.c (revision 2548)
+++ libc/time/daylight_seconds.c (working copy)
@@ -42,29 +42,29 @@ extern long __latitude;
long
daylight_seconds(const time_t * timer)
{
- double l, d;
+ float l, d;
long n;
/* convert latitude to radians */
- l = __latitude / 206264.806;
+ l = __latitude / 206264.806f;
- d = -solar_declination(timer);
+ d = -solar_declinationf(timer);
/* partial 'Sunrise Equation' */
- d = tan(l) * tan(d);
+ d = tanf(l) * tanf(d);
/* magnitude of d may exceed 1.0 at near solstices */
- if (d > 1.0)
- d = 1.0;
+ if (d > 1.0f)
+ d = 1.0f;
- if (d < -1.0)
- d = -1.0;
+ if (d < -1.0f)
+ d = -1.0f;
/* derive hour angle */
- d = acos(d);
+ d = acosf(d);
/* but for atmospheric refraction, this would be d /= M_PI */
- d /= 3.112505;
+ d /= 3.112505f;
n = ONE_DAY * d;
Index: libc/time/solar_declination.c
===================================================================
--- libc/time/solar_declination.c (revision 2548)
+++ libc/time/solar_declination.c (working copy)
@@ -43,35 +43,39 @@
#include
#include
#include "ephemera_common.h"
+#include "alias.h"
#define LAG 38520
-double
-solar_declination(const time_t * timer)
+float
+solar_declinationf(const time_t * timer)
{
uint32_t fT, oV;
- double dV, dT;
+ float dV, dT;
/* Determine orbital angle relative to perihelion of January 1999 */
oV = *timer % ANOM_YEAR;
- oV += PERIHELION;
+ oV += (float) PERIHELION;
dV = oV;
- dV /= ANOM_CYCLE;
+ dV /= (float) ANOM_CYCLE;
/* Derive velocity correction factor from the perihelion angle */
- dV = sin(dV);
- dV *= DELTA_V;
+ dV = sinf(dV);
+ dV *= (float) DELTA_V;
/* Determine orbital angle relative to solstice of December 1999 */
fT = *timer % TROP_YEAR;
- fT += SOLSTICE + LAG;
+ fT += (float) (SOLSTICE + LAG);
dT = fT;
- dT /= TROP_CYCLE;
+ dT /= (float) TROP_CYCLE;
dT += dV;
/* Finally having the solstice angle, we can compute the declination */
- dT = cos(dT) * INCLINATION;
+ dT = cosf(dT) * (float) INCLINATION;
return -dT;
}
+
+DALIAS (solar_declinationf) double solar_declination (const time_t*);
+LALIAS (solar_declinationf) long double solar_declinationl (const time_t*);
Index: libm/fplib/acos.S
===================================================================
--- libm/fplib/acos.S (revision 2548)
+++ libm/fplib/acos.S (working copy)
@@ -29,8 +29,8 @@
/* $Id$ */
-/* float acos (float x);
- The acos() function calculates the arc cosine of x; that is the value
+/* float acosf (float x);
+ The acosf() function calculates the arc cosine of x; that is the value
whose cosine is x.
*/
@@ -43,7 +43,7 @@
#define HI40_PI 0x40490FDA /* Pi */
#define LO40_PI 0xA2
-ENTRY acos
+ENTRY_FLOAT acosf acos acosl
; save A sign
push rA3
; A = arccos(fabs(A))
Index: libm/fplib/asin.S
===================================================================
--- libm/fplib/asin.S (revision 2548)
+++ libm/fplib/asin.S (working copy)
@@ -29,8 +29,8 @@
/* $Id$ */
-/* float asin (float A);
- The asin() function returns the arc sine in radians and the value is
+/* float asinf (float A);
+ The asinf() function returns the arc sine in radians and the value is
mathematically defined to be between -PI/2 and PI/2 (inclusive).
*/
@@ -44,7 +44,7 @@
#define HI40_PI_2 0x3fc90fda /* high 4 bytes of Pi/2 */
#define LO40_PI_2 0xa2 /* lowest byte of Pi/2 */
-ENTRY asin
+ENTRY_FLOAT asinf asin asinl
; save A sign
push rA3
; A = fabs(A)
Index: libm/fplib/asmdef.h
===================================================================
--- libm/fplib/asmdef.h (revision 2548)
+++ libm/fplib/asmdef.h (working copy)
@@ -93,16 +93,24 @@ FUNCTION \name
_U(\name):
.endm
-/* Because we define the double type to have the same representation as
- float, we want to share some code for multiple function definitions.
+/* If the layout of the double type is the same like the float layout,
+ provide a weak alias of the float symbol for double, same for long double.
While we could also provide aliases in header files using
__asm__ in the declaration to specifiy the symbol to reference,
it is preferable to provide actual symbols in the library, so
that code that expects to be able to use them directly -
like gcc/gcc/testsuite/gcc.dg/pr41963.c using sqrtf - will work. */
-.macro ALIAS_ENTRY name
- .global _U(\name)
-_U(\name):
+
+.macro ENTRY_FLOAT fname dname lname
+ENTRY \fname
+#if (__SIZEOF_DOUBLE__ == __SIZEOF_FLOAT__)
+ .weak _U(\dname)
+_U(\dname):
+#endif /* double = float */
+#if (__SIZEOF_LONG_DOUBLE__ == __SIZEOF_FLOAT__)
+ .weak _U(\lname)
+_U(\lname):
+#endif /* long double = float */
.endm
.macro ENDFUNC
Index: libm/fplib/atan.S
===================================================================
--- libm/fplib/atan.S (revision 2548)
+++ libm/fplib/atan.S (working copy)
@@ -29,15 +29,15 @@
/* $Id$ */
-/* float atan (float A);
- The atan() function calculates the arc tangent of A; that is
+/* float atanf (float A);
+ The atanf() function calculates the arc tangent of A; that is
the value whose tangent is A.
Algorithm:
if (x > 1)
- return Pi/2 - atan(1/x)
+ return Pi/2 - atanf(1/x)
elif (x < -1)
- return -Pi/2 - atan(1/x)
+ return -Pi/2 - atanf(1/x)
else
return x * (1 - C1 * x**2 + ... + C8 * x**16)
*/
@@ -54,7 +54,7 @@
#define corr YH
-ENTRY atan
+ENTRY_FLOAT atanf atan atanl
push corr
clr corr
; inverse A, if needed
@@ -74,7 +74,7 @@ ENTRY atan
push rA2
push rA1
push rA0
- XCALL _U(square)
+ XCALL _U(squaref)
ldi ZL, lo8(.L_table)
ldi ZH, hi8(.L_table)
XCALL _U(__fp_powser)
Index: libm/fplib/atan2.S
===================================================================
--- libm/fplib/atan2.S (revision 2548)
+++ libm/fplib/atan2.S (working copy)
@@ -29,11 +29,11 @@
/* $Id$ */
-/* float atan2 (float A, float B); // A is y coord, B is x coord.
- The atan2() function calculates the arc tangent of the two variables
+/* float atan2f (float A, float B); // A is y coord, B is x coord.
+ The atan2f() function calculates the arc tangent of the two variables
A and B. It is similar to calculating the arc tangent of A/B, except
that the signs of both arguments are used to determine the quadrant
- of the result. The atan2() function returns the result in radians,
+ of the result. The atan2f() function returns the result in radians,
which is between -PI and PI (inclusive).
Note:
@@ -66,7 +66,7 @@
#define disp ZL /* displacement high byte */
-FUNCTION atan2
+FUNCTION atan2f
.L_nf: XCALL _U(__fp_pscA)
brcs .L_nan
@@ -85,7 +85,7 @@ FUNCTION atan2
.L_nan: XJMP _U(__fp_nan)
.L_zr: XJMP _U(__fp_zero)
-ENTRY atan2
+ENTRY_FLOAT atan2f atan2 atan2l
; save 'y' sign
mov disp, rA3
andi disp, 0x80
@@ -126,7 +126,7 @@ ENTRY atan2
2: push disp
XCALL _U(__divsf3_pse)
XCALL _U(__fp_round)
- XCALL _U(atan)
+ XCALL _U(atanf)
; restore disp and analize
pop rB3 ; hhi8()
tst rB3
Index: libm/fplib/cbrt.S
===================================================================
--- libm/fplib/cbrt.S (revision 2548)
+++ libm/fplib/cbrt.S (working copy)
@@ -33,7 +33,7 @@
#include "fp32def.h"
#include "asmdef.h"
-/* double cbrt (double)
+/* float cbrtf (float)
Cube root function.
*/
@@ -72,7 +72,7 @@
#define REM RD0
-FUNCTION cbrt
+FUNCTION cbrtf
/* Division by 3.
Input:
@@ -112,7 +112,7 @@ FUNCTION cbrt
0: XJMP _U(__fp_mpack)
-ENTRY cbrt
+ENTRY_FLOAT cbrtf cbrt cbrtl
; split and check arg.
XCALL _U(__fp_splitA)
brcs 0b ; !isfinite(A)
Index: libm/fplib/ceil.S
===================================================================
--- libm/fplib/ceil.S (revision 2548)
+++ libm/fplib/ceil.S (working copy)
@@ -29,12 +29,12 @@
/* $Id$ */
-/* double ceil (double x);
- The ceil() function rounds x up to the nearest integer.
+/* float ceilf (float x);
+ The ceilf() function rounds x up to the nearest integer.
Examples:
- ceil(1.9) --> 2.0
- ceil(-1.9) --> -1.0
+ ceilf(1.9) --> 2.0
+ ceilf(-1.9) --> -1.0
*/
@@ -45,7 +45,7 @@
#define FL_P1 0x3f800000 /* +1.0 */
-ENTRY ceil
+ENTRY_FLOAT ceilf ceil ceill
XCALL _U(__fp_trunc)
brcs .L_nf
; A is finite
Index: libm/fplib/copysign.S
===================================================================
--- libm/fplib/copysign.S (revision 2548)
+++ libm/fplib/copysign.S (working copy)
@@ -32,12 +32,12 @@
#include "fp32def.h"
#include "asmdef.h"
-/* float copysign (float x, float y);
- The copysign() function returns x but with the sign of y.
+/* float copysignf (float x, float y);
+ The copysignf() function returns x but with the sign of y.
They work even if x or y are NaN or zero.
*/
-ENTRY copysign
+ENTRY_FLOAT copysignf copysign copysignl
bst rB3, 7
bld rA3, 7
ret
Index: libm/fplib/cos.S
===================================================================
--- libm/fplib/cos.S (revision 2548)
+++ libm/fplib/cos.S (working copy)
@@ -32,11 +32,11 @@
#include "fp32def.h"
#include "asmdef.h"
-/* float cos (float A);
- The cos() function returns the cosine of A, where A is given in
+/* float cosf (float A);
+ The cosf() function returns the cosine of A, where A is given in
radians.
*/
-ENTRY cos
+ENTRY_FLOAT cosf cos cosl
XCALL _U(__fp_rempio2)
inc ZL
XJMP _U(__fp_sinus)
Index: libm/fplib/cosh.S
===================================================================
--- libm/fplib/cosh.S (revision 2548)
+++ libm/fplib/cosh.S (working copy)
@@ -32,34 +32,34 @@
#include "fp32def.h"
#include "asmdef.h"
-/* float cosh (float x);
- The cosh() function returns the hyperbolic cosine of x, which is
+/* float coshf (float x);
+ The coshf() function returns the hyperbolic cosine of x, which is
defined mathematically as (exp(x) + exp(-x)) / 2.
Notes:
- ldexp() is called twice to avoid overflow with too big x argument.
+ ldexpf() is called twice to avoid overflow with too big x argument.
*/
#define exp_lo r20
#define exp_hi r21
-ENTRY cosh
- ; A = exp(-fabs(x))/2 negative to exclude an extra inversion
+ENTRY_FLOAT coshf cosh coshl
+ ; A = expf(-fabsf(x))/2 negative to exclude an extra inversion
ori rA3, 0x80
- XCALL _U(exp)
+ XCALL _U(expf)
ldi exp_lo, lo8(-1)
ldi exp_hi, hi8(-1)
- XCALL _U(ldexp)
- ; save A and calculate exp(fabs(x))/2
+ XCALL _U(ldexpf)
+ ; save A and calculate expf(fabsf(x))/2
push rA3
push rA2
push rA1
push rA0
ldi exp_lo, lo8(2)
ldi exp_hi, hi8(2)
- XCALL _U(ldexp)
+ XCALL _U(ldexpf)
XCALL _U(inverse)
- ; exp(x)/2 + exp(-x)/2
+ ; expf(x)/2 + expf(-x)/2
pop rB0
pop rB1
pop rB2
Index: libm/fplib/exp.S
===================================================================
--- libm/fplib/exp.S (revision 2548)
+++ libm/fplib/exp.S (working copy)
@@ -34,19 +34,19 @@
#include "fp32def.h"
#include "asmdef.h"
-/* float exp (float x);
- The exp() function returns the value of e (the base of natural
+/* float expf (float x);
+ The expf() function returns the value of e (the base of natural
logarithms) raised to the power of x.
*/
#define X2BIG 0x43000000 /* exp(-X2BIG) < 0x00000001 */
#define FL_1_LN2 0x3fb8aa3b /* 1 / ln(2) */
-/* second arg for modf(), ldexp() functions. */
+/* second arg for modff(), ldexpf() functions. */
#define exp_lo r20
#define exp_hi r21
-FUNCTION exp
+FUNCTION expf
.L_nf: brne .L_nan
.L_tb: brts .L_zr
@@ -54,7 +54,7 @@ FUNCTION exp
.L_zr: XJMP _U(__fp_zero)
.L_nan: XJMP _U(__fp_nan)
-ENTRY exp
+ENTRY_FLOAT expf exp expl
; split and analize A
XCALL _U(__fp_splitA)
brcs .L_nf ; A is not a finite number
@@ -77,7 +77,7 @@ ENTRY exp
in exp_lo, SPL_IO_ADDR
in exp_hi, SPH_IO_ADDR
push r0
- XCALL _U(modf)
+ XCALL _U(modff)
; calculate 2**(-x) for 0 <= x < 1
ldi ZL, lo8(.L_table)
ldi ZH, hi8(.L_table)
@@ -102,7 +102,7 @@ ENTRY exp
; negate and scale
neg exp_lo
sbc exp_hi, exp_hi
-2: XCALL _U(ldexp)
+2: XCALL _U(ldexpf)
; inverse for positive arg.
pop r0
sbrs r0, 7
Index: libm/fplib/fdim.S
===================================================================
--- libm/fplib/fdim.S (revision 2548)
+++ libm/fplib/fdim.S (working copy)
@@ -34,8 +34,8 @@
#include "fp32def.h"
#include "asmdef.h"
-/* float fdim (float x, float y);
- The fdim() function return max(x-y,0). If x or y or both are NaN,
+/* float fdimf (float x, float y);
+ The fdimf() function return maxf(x-y,0). If x or y or both are NaN,
NaN is returned.
Notes:
@@ -44,7 +44,7 @@
is fast if both arguments are equal.
*/
-ENTRY fdim
+ENTRY_FLOAT fdimf fdim fdiml
; sign(A) | sign(B)
mov r0, rA3
or r0, rB3
Index: libm/fplib/floor.S
===================================================================
--- libm/fplib/floor.S (revision 2548)
+++ libm/fplib/floor.S (working copy)
@@ -34,17 +34,17 @@
#include "fp32def.h"
#include "asmdef.h"
-/* double floor (double x);
- The floor() function rounds x down to the nearest integer.
+/* float floorf (float x);
+ The floorf() function rounds x down to the nearest integer.
Examples:
- floor(1.9) --> 1.0
- floor(-1.9) --> -2.0
+ floorf(1.9) --> 1.0
+ floorf(-1.9) --> -2.0
*/
#define FL_M1 0xbf800000 /* -1.0 */
-ENTRY floor
+ENTRY_FLOAT floorf floor floorl
XCALL _U(__fp_trunc)
brcs .L_nf
; A is finite
Index: libm/fplib/fma.S
===================================================================
--- libm/fplib/fma.S (revision 2548)
+++ libm/fplib/fma.S (working copy)
@@ -34,8 +34,8 @@
#include "fp32def.h"
#include "asmdef.h"
-/* double fma (double A, double B, double C)
- The `fma' function performs floating-point multiply-add. This is the
+/* float fmaf (float A, float B, float C)
+ The `fmaf' function performs floating-point multiply-add. This is the
operation (A * B) + C, but the intermediate result is not rounded to
the destination type. This can sometimes improve the precision of a
calculation.
@@ -44,7 +44,7 @@
#define rC0 r14 /* lower byte of arg. C */
#define rC2 r16
-ENTRY fma
+ENTRY_FLOAT fmaf fma fmal
XCALL _U(__mulsf3x)
X_movw rB0, rC0
X_movw rB2, rC2
Index: libm/fplib/fmax.S
===================================================================
--- libm/fplib/fmax.S (revision 2548)
+++ libm/fplib/fmax.S (working copy)
@@ -34,13 +34,13 @@
#include "fp32def.h"
#include "asmdef.h"
-/* float fmax (float x, float y);
- The fmax() function returns the greater of the two values x and y.
+/* float fmaxf (float x, float y);
+ The fmaxf() function returns the greater of the two values x and y.
If an argument is NaN, the other argument is returned. If both
arguments are NaN, NaN is returned.
*/
-ENTRY fmax
+ENTRY_FLOAT fmaxf fmax fmaxl
lsl rA3
sbc rAE, rAE ; rAE = (A < 0) ? -1 : 0
lsl rB3
Index: libm/fplib/fmin.S
===================================================================
--- libm/fplib/fmin.S (revision 2548)
+++ libm/fplib/fmin.S (working copy)
@@ -34,13 +34,13 @@
#include "fp32def.h"
#include "asmdef.h"
-/* float fmin (float x, float y);
- The fmin() function returns the lesser of the two values x and y.
+/* float fminf (float x, float y);
+ The fminf() function returns the lesser of the two values x and y.
If an argument is NaN, the other argument is returned. If both
arguments are NaN, NaN is returned.
*/
-ENTRY fmin
+ENTRY_FLOAT fminf fmin fminl
lsl rA3
sbc rAE, rAE ; rAE = (A < 0) ? -1 : 0
lsl rB3
Index: libm/fplib/fmod.S
===================================================================
--- libm/fplib/fmod.S (revision 2548)
+++ libm/fplib/fmod.S (working copy)
@@ -34,13 +34,13 @@
#include "fp32def.h"
#include "asmdef.h"
-/* double fmod (double x, double y);
- The fmod() function computes the remainder of dividing x by y. The
+/* float fmodf (float x, float y);
+ The fmodf() function computes the remainder of dividing x by y. The
return value is x - n*y, where n is the quotient of x/y, rounded
towards zero to an integer.
*/
-FUNCTION fmod
+FUNCTION fmodf
0: XCALL _U(__fp_pscA)
brcs .L_nan ; isnan(A)
@@ -51,7 +51,7 @@ FUNCTION fmod
.L_nan: XJMP _U(__fp_nan)
.L_sz: XJMP _U(__fp_szero)
-ENTRY fmod
+ENTRY_FLOAT fmodf fmod fmodl
; split and check exceptions
mov ZL, rA3 ; save
XCALL _U(__fp_split3)
Index: libm/fplib/fp_arccos.S
===================================================================
--- libm/fplib/fp_arccos.S (revision 2548)
+++ libm/fplib/fp_arccos.S (working copy)
@@ -74,7 +74,7 @@ ENTRY __fp_arccos
ldi rA2, hlo8(FL_1)
ldi rA3, hhi8(FL_1)
XCALL _U(__subsf3)
- XCALL _U(sqrt)
+ XCALL _U(sqrtf)
movw rB0, rC0
movw rB2, rC2
@@ -114,7 +114,7 @@ ENTRY __fp_arccos
ldi rA2, hlo8(FL_1)
ldi rA3, hhi8(FL_1)
XCALL _U(__subsf3)
- XCALL _U(sqrt)
+ XCALL _U(sqrtf)
; multiply
pop rB0
pop rB1
Index: libm/fplib/frexp.S
===================================================================
--- libm/fplib/frexp.S (revision 2548)
+++ libm/fplib/frexp.S (working copy)
@@ -34,15 +34,15 @@
#include "fp32def.h"
#include "asmdef.h"
-/* float frexp (float A, int *pexp);
- The frexp() function is used to split the number A into a normalized
+/* float frexpf (float A, int *pexp);
+ The frexpf() function is used to split the number A into a normalized
fraction and an exponent which is stored by pexp.
Return:
- If A is a normal float point number, the frexp() function returns the
+ If A is a normal float point number, the frexpf() function returns the
value v, such that v has a magnitude in the interval [1/2, 1) or zero,
and A equals v times 2 raised to the power *pexp. If A is zero, both
- parts of the result are zero. If A is not a finite number, the frexp()
+ parts of the result are zero. If A is not a finite number, the frexpf()
returns A as is and stores 0 by pexp.
Note:
@@ -52,7 +52,7 @@
#define pexp_lo r20
-ENTRY frexp
+ENTRY_FLOAT frexpf frexp frexpl
X_movw ZL, pexp_lo
Index: libm/fplib/hypot.S
===================================================================
--- libm/fplib/hypot.S (revision 2548)
+++ libm/fplib/hypot.S (working copy)
@@ -33,8 +33,8 @@
#include "asmdef.h"
#include "ntz.h"
-/* double hypot (double x, double y);
- The hypot() function returns `sqrt (x*x + y*y)'. This is the length
+/* float hypotf (float x, float y);
+ The hypotf() function returns `sqrtf (x*x + y*y)'. This is the length
of the hypotenuse of a right triangle with sides of length x and y,
or the distance of the point (x, y) from the origin. Using this
function instead of the direct formula is wise, since the error is
@@ -61,7 +61,7 @@
# error
#endif
-#define exp_lo r20 /* ldexp (float x, int exp); */
+#define exp_lo r20 /* ldexpf (float x, int exp); */
#define exp_hi r21
#define rC0 r14
@@ -69,12 +69,12 @@
#define rC2 r16
#define rC3 r17
-FUNCTION hypot
+FUNCTION hypotf
.L_nf: XCALL _U(__fp_pscA)
- breq 1f ; hypot(Inf, *) --> Inf
+ breq 1f ; hypotf(Inf, *) --> Inf
XCALL _U(__fp_pscB)
- breq 1f ; hypot(*, Inf) --> Inf
+ breq 1f ; hypotf(*, Inf) --> Inf
XJMP _U(__fp_nan) ; NaN and finite, or both NaN
1: XJMP _U(__fp_inf) ; T is 0 after __fp_split3()
@@ -84,7 +84,7 @@ FUNCTION hypot
.L_retA:
XJMP _U(__fp_mpack)
-ENTRY hypot
+ENTRY_FLOAT hypotf hypot hypotl
; clear signs
andi rA3, 0x7f
andi rB3, 0x7f
@@ -236,7 +236,7 @@ ENTRY hypot
XCALL _U(__addsf3x)
XCALL _U(__fp_round)
- XCALL _U(sqrt)
+ XCALL _U(sqrtf)
; restore a scale
#if (-SCALE_SMALL & SCALE_BIG) == 0
@@ -248,5 +248,5 @@ ENTRY hypot
clr exp_hi
sbrc exp_lo, 7
com exp_hi
- XJMP _U(ldexp)
+ XJMP _U(ldexpf)
ENDFUNC
Index: libm/fplib/isfinite.S
===================================================================
--- libm/fplib/isfinite.S (revision 2548)
+++ libm/fplib/isfinite.S (working copy)
@@ -32,12 +32,12 @@
#include "fp32def.h"
#include "asmdef.h"
-/* int isfinite (float x);
- The isfinite() function returns a nonzero value if x is finite: not
+/* int isfinitef (float x);
+ The isfinitef() function returns a nonzero value if x is finite: not
plus or minus infinity, and not NaN.
*/
-ENTRY isfinite
+ENTRY_FLOAT isfinitef isfinite isfinitel
/* It is not needed to return 1 if number is finite. Any nonzero value
is suitable. This realization returns 0xff in low byte and nonzero
value (1..255) in high byte. */
Index: libm/fplib/isinf.S
===================================================================
--- libm/fplib/isinf.S (revision 2548)
+++ libm/fplib/isinf.S (working copy)
@@ -34,15 +34,15 @@
#include "fp32def.h"
#include "asmdef.h"
-/* int isinf (double)
- The isinf() function returns -1 if value represents negative
+/* int isinff (float)
+ The isinff() function returns -1 if value represents negative
infinity, 1 if value represents positive infinity, and 0 otherwise.
Notes:
* It is implemented to save space, as there is a time effective
isfinite() inline function.
*/
-ENTRY isinf
+ENTRY_FLOAT isinff isinf isinfl
XCALL _U(__fp_splitA)
ldi r24, 0
ldi r25, 0
Index: libm/fplib/isnan.S
===================================================================
--- libm/fplib/isnan.S (revision 2548)
+++ libm/fplib/isnan.S (working copy)
@@ -32,15 +32,15 @@
#include "fp32def.h"
#include "asmdef.h"
-/* int isnan (double)
- The isnan() function returns a non-zero value if value is
+/* int isnanf (float)
+ The isnanf() function returns a non-zero value if value is
"not-a-number" (NaN), and 0 otherwise.
Notes:
* It is implemented to save space, as there is a time effective
isfinite() inline function.
*/
-ENTRY isnan
+ENTRY_FLOAT isnanf isnan isnanl
XCALL _U(__fp_splitA)
ldi r24, 0
ldi r25, 0
Index: libm/fplib/ldexp.S
===================================================================
--- libm/fplib/ldexp.S (revision 2548)
+++ libm/fplib/ldexp.S (working copy)
@@ -34,19 +34,19 @@
#include "fp32def.h"
#include "asmdef.h"
-/* double ldexp (double x, int exp)
- The ldexp() function returns the result of multiplying the
+/* float ldexpf (float x, int exp)
+ The ldexpf() function returns the result of multiplying the
floating-point number x by 2 raised to the power exp.
*/
#define exp_lo r20
#define exp_hi r21
-FUNCTION ldexp
+FUNCTION ldexpf
.L_inf: XJMP _U(__fp_inf)
.L_pk: XJMP _U(__fp_mpack)
-ENTRY ldexp
+ENTRY_FLOAT ldexpf ldexp ldexpl
XCALL _U(__fp_splitA)
brcs .L_pk ; as is
tst rA3
Index: libm/fplib/log.S
===================================================================
--- libm/fplib/log.S (revision 2548)
+++ libm/fplib/log.S (working copy)
@@ -34,8 +34,8 @@
#include "fp32def.h"
#include "asmdef.h"
-/* double log (double A)
- The log() function returns the natural logarithm of A.
+/* float logf (float A)
+ The logf() function returns the natural logarithm of A.
*/
#define FL_M1 0xbf800000 /* -1.0 */
@@ -47,7 +47,7 @@
#define rC0 r16
#define rCE r15
-FUNCTION log
+FUNCTION logf
.L_nf: brts .L_nan ; branch, if -Inf
XJMP _U(__fp_mpack) ; pass as is: NaN --> NaN, +Inf --> +Inf
@@ -55,7 +55,7 @@ FUNCTION log
.L_min: set
XJMP _U(__fp_inf)
-ENTRY log
+ENTRY_FLOAT logf log logl
XCALL _U(__fp_splitA)
brcs .L_nf ; !isfinite(A)
tst rA3
Index: libm/fplib/log10.S
===================================================================
--- libm/fplib/log10.S (revision 2548)
+++ libm/fplib/log10.S (working copy)
@@ -32,14 +32,14 @@
#include "fp32def.h"
#include "asmdef.h"
-/* double log (double A);
- The log10() function returns the base 10 logarithm of A.
+/* float logf (float A);
+ The log10f() function returns the base 10 logarithm of A.
*/
#define INV_LN_10 0x3ede5bd9 /* 1.0/log(10.0) */
-ENTRY log10
- XCALL _U(log)
+ENTRY_FLOAT log10f log10 log10l
+ XCALL _U(logf)
ldi rB0, lo8(INV_LN_10)
ldi rB1, hi8(INV_LN_10)
ldi rB2, hlo8(INV_LN_10)
Index: libm/fplib/lrint.S
===================================================================
--- libm/fplib/lrint.S (revision 2548)
+++ libm/fplib/lrint.S (working copy)
@@ -33,8 +33,8 @@
#include "fp32def.h"
#include "asmdef.h"
-/* long lrint (double A);
- The lrint() function rounds A to the nearest integer, rounding the
+/* long lrintf (float A);
+ The lrintf() function rounds A to the nearest integer, rounding the
halfway cases to the even integer direction. (That is both 1.5 and
2.5 values are rounded to 2). This function is similar to rint()
function, but it differs in type of return value and in that an
@@ -50,7 +50,7 @@
- restore the sign
*/
-ENTRY lrint
+ENTRY_FLOAT lrintf lrint lrintl
XCALL _U(__fp_splitA)
brcs .L_err
; A is finite
Index: libm/fplib/lround.S
===================================================================
--- libm/fplib/lround.S (revision 2548)
+++ libm/fplib/lround.S (working copy)
@@ -34,8 +34,8 @@
#include "fp32def.h"
#include "asmdef.h"
-/* long lround (double A);
- The lround() function rounds A to the nearest integer, but rounds
+/* long lroundf (float A);
+ The lroundf() function rounds A to the nearest integer, but rounds
halfway cases away from zero (instead of to the nearest even integer).
This function is similar to round() function, but it differs in
type of return value and in that an overflow is possible.
@@ -52,7 +52,7 @@
Objections to saturation are listen in __fixunssfsi.S file.
*/
-ENTRY lround
+ENTRY_FLOAT lroundf lround lroundl
XCALL _U(__fp_splitA)
brcs .L_err
; A is finite
Index: libm/fplib/modf.S
===================================================================
--- libm/fplib/modf.S (revision 2548)
+++ libm/fplib/modf.S (working copy)
@@ -34,9 +34,9 @@
#include "fp32def.h"
#include "asmdef.h"
-/* double modf (double x, double *iptr);
+/* float modff (float x, float *iptr);
- The modf() function breaks the argument x into an integral part and a
+ The modff() function breaks the argument x into an integral part and a
fractional part, each of which has the same sign as x. The integral part
is stored in iptr.
This implementation skips writing by zero pointer.
@@ -44,8 +44,7 @@
#define iptr_lo r20
-ENTRY modf
-ENTRY modff
+ENTRY_FLOAT modff modf modfl
; save iptr
X_movw ZL, iptr_lo
; XH = exponent field
Index: libm/fplib/pow.S
===================================================================
--- libm/fplib/pow.S (revision 2548)
+++ libm/fplib/pow.S (working copy)
@@ -34,8 +34,8 @@
#include "fp32def.h"
#include "asmdef.h"
-/* float pow (float x, float y);
- The pow() function returns the value of x raised to the power of y.
+/* float powf (float x, float y);
+ The powf() function returns the value of x raised to the power of y.
Args combinations:
x y pow(x,y)
@@ -105,7 +105,7 @@
#define FL_1 0x3f800000 /* +1.0 */
-ENTRY pow
+ENTRY_FLOAT powf pow powl
; ZH := exponent of y
X_movw ZL, rB2
lsl ZL
@@ -206,13 +206,13 @@ ENTRY pow
push rB2
push rB1
push rB0
- XCALL _U(log)
+ XCALL _U(logf)
pop rB0
pop rB1
pop rB2
pop rB3
XCALL _U(__mulsf3)
- XJMP _U(exp)
+ XJMP _U(expf)
ENDFUNC
#endif /* !defined(__AVR_TINY__) */
Index: libm/fplib/round.S
===================================================================
--- libm/fplib/round.S (revision 2548)
+++ libm/fplib/round.S (working copy)
@@ -48,7 +48,7 @@
- merge to float
This is a balance between space and speed.
*/
-ENTRY round
+ENTRY_FLOAT roundf round roundl
XCALL _U(__fp_splitA)
brcs .L_nf
; A is finite
Index: libm/fplib/signbit.S
===================================================================
--- libm/fplib/signbit.S (revision 2548)
+++ libm/fplib/signbit.S (working copy)
@@ -32,18 +32,18 @@
#include "fp32def.h"
#include "asmdef.h"
-/* int signbit (double x);
+/* int signbitf (float x);
- The signbit() function returns a nonzero value if the value of x has
+ The signbitf() function returns a nonzero value if the value of x has
its sign bit set. This is not the same as `x < 0.0', because IEEE 754
floating point allows zero to be signed. The comparison `-0.0 < 0.0'
- is false, but `signbit (-0.0)' will return a nonzero value.
+ is false, but `signbitf (-0.0)' will return a nonzero value.
This implementation returns 1 if sign bit is set. This corresponds
to builtin GCC realization.
*/
-ENTRY signbit
+ENTRY_FLOAT signbitf signbit signbitl
lsl rA3
sbc rA2, rA2
neg rA2
Index: libm/fplib/sin.S
===================================================================
--- libm/fplib/sin.S (revision 2548)
+++ libm/fplib/sin.S (working copy)
@@ -34,11 +34,11 @@
#include "fp32def.h"
#include "asmdef.h"
-/* float sin (float A);
- The sin() function returns the sine of A, where A is given in radians.
+/* float sinf (float A);
+ The sinf() function returns the sine of A, where A is given in radians.
*/
-ENTRY sin
+ENTRY_FLOAT sinf sin sinl
push rA3
XCALL _U(__fp_rempio2)
pop r0
Index: libm/fplib/sinh.S
===================================================================
--- libm/fplib/sinh.S (revision 2548)
+++ libm/fplib/sinh.S (working copy)
@@ -34,20 +34,20 @@
#include "fp32def.h"
#include "asmdef.h"
-/* float sinh (float x);
- The sinh() function returns the hyperbolic sine of x, which is
+/* float sinhf (float x);
+ The sinhf() function returns the hyperbolic sine of x, which is
defined mathematically as (exp(x) - exp(-x)) / 2.
Notes:
- ldexp() is used twice to avoid overflow for big x.
+ ldexpf() is used twice to avoid overflow for big x.
*/
#define X2SMALL 0x3e9fffff /* < 0.3125 */
-#define exp_lo r20 /* float ldexp (float, int exp); */
+#define exp_lo r20 /* float ldexpf (float, int exp); */
#define exp_hi r21
-ENTRY sinh
+ENTRY_FLOAT sinhf sinh sinhl
; save sign
push rA3
; is arg too small ?
@@ -61,22 +61,22 @@ ENTRY sinh
ldi ZH, hi8(.L_table)
XCALL _U(__fp_powsodd)
rjmp 2f
- ; exp(-fabs(x)) // negative to exclude an extra inversion
+ ; expf(-fabsf(x)) // negative to exclude an extra inversion
1: ori rA3, 0x80
- XCALL _U(exp)
- ; exp(-fabs(x)) / 2
+ XCALL _U(expf)
+ ; expf(-fabsf(x)) / 2
ldi exp_lo, lo8(-1)
ldi exp_hi, hi8(-1)
- XCALL _U(ldexp)
+ XCALL _U(ldexpf)
; save
push rA3
push rA2
push rA1
push rA0
- ; exp(fabs(x)) / 2
+ ; expf(fabsf(x)) / 2
ldi exp_lo, lo8(2)
ldi exp_hi, hi8(2)
- XCALL _U(ldexp)
+ XCALL _U(ldexpf)
XCALL _U(inverse)
; result (in absolute value)
pop rB0
Index: libm/fplib/sqrt.S
===================================================================
--- libm/fplib/sqrt.S (revision 2548)
+++ libm/fplib/sqrt.S (working copy)
@@ -34,19 +34,18 @@
#include "fp32def.h"
#include "asmdef.h"
-/* double sqrt (double);
+/* float sqrtf (float);
Square root function.
*/
-FUNCTION sqrt
+FUNCTION sqrtf
.L_nf: brne .L_pk ; NaN, return as is
brtc .L_pk ; sqrt(+Inf) --> +Inf
.L_nan: XJMP _U(__fp_nan)
.L_pk: XJMP _U(__fp_mpack)
-ENTRY sqrt
-ALIAS_ENTRY sqrtf
+ENTRY_FLOAT sqrtf sqrt sqrtl
; split and check arg.
XCALL _U(__fp_splitA)
brcs .L_nf ; !isfinite(A)
Index: libm/fplib/square.S
===================================================================
--- libm/fplib/square.S (revision 2548)
+++ libm/fplib/square.S (working copy)
@@ -32,11 +32,11 @@
#include "fp32def.h"
#include "asmdef.h"
-/* float square (float A);
- The square() function returns square of A.
+/* float squaref (float A);
+ The squaref() function returns square of A.
*/
-ENTRY square
+ENTRY_FLOAT squaref square squarel
X_movw rB0, rA0
X_movw rB2, rA2 ; B = A
Index: libm/fplib/tan.S
===================================================================
--- libm/fplib/tan.S (revision 2548)
+++ libm/fplib/tan.S (working copy)
@@ -32,16 +32,16 @@
#include "fp32def.h"
#include "asmdef.h"
-/* float tan (float A);
- The tan() function returns the tangent of A, where A is given
+/* float tanf (float A);
+ The tanf() function returns the tangent of A, where A is given
in radians.
*/
/* Calculation:
- 0 <= x <= Pi/4 --> tan(x) fmod
- Pi/4 < x < Pi/2 --> 1/tan(Pi/2-x) fmod, Pi/2-x, 1/x
- Pi/2 <= x <= 3*Pi/4 --> -1/tan(x-Pi/2) fmod, 1/x, -x
- 3*Pi/4 < x < Pi --> -tan(Pi-x) fmod, Pi/2-x, -x
+ 0 <= x <= Pi/4 --> tanf(x) fmodf
+ Pi/4 < x < Pi/2 --> 1/tanf(Pi/2-x) fmodf, Pi/2-x, 1/x
+ Pi/2 <= x <= 3*Pi/4 --> -1/tanf(x-Pi/2) fmodf, 1/x, -x
+ 3*Pi/4 < x < Pi --> -tanf(Pi-x) fmodf, Pi/2-x, -x
*/
#define HI40_PIO4 0x3F490FDA /* (flt40_t) Pi/4 */
#define LO40_PIO4 0xA2 /* --"-- */
@@ -50,7 +50,7 @@
#define rsign YH
-ENTRY tan
+ENTRY_FLOAT tanf tan tanl
; save sign
push rsign
mov rsign, rA3
Index: libm/fplib/tanh.S
===================================================================
--- libm/fplib/tanh.S (revision 2548)
+++ libm/fplib/tanh.S (working copy)
@@ -34,24 +34,25 @@
#include "fp32def.h"
#include "asmdef.h"
-/* float tanh (float x);
- The tanh() function returns the hyperbolic tangent of x, which is
+/* float tanhf (float x);
+ The tanhf() function returns the hyperbolic tangent of x, which is
defined mathematically as sinh(x) / cosh(x).
Algorithm:
- if (fabs(x) <= X2SMALL)
+ if (|x| <= X2SMALL)
return Polinom(x)
else
- return sign(x) * (1 - exp(-2*fabs(x))) / (1 + exp(-2*fabs(x)))
+ return sign(x) * (1 - exp(-2*|x|)) / (1 + exp(-2*|x|))
*/
#define X2SMALL 0x3e0fffff /* < 0.140625 */
#define FL_P1 0x3f800000 /* +1.0 */
-#define exp_lo r20 /* float ldexp (float, int exp); */
+#define exp_lo r20 /* float ldexpf (float, int exp); */
#define exp_hi r21
-ENTRY tanh
+
+ENTRY_FLOAT tanhf tanh tanhl
; save sign
push rA3
; is arg too small ?
@@ -69,9 +70,9 @@ ENTRY tanh
1: ori rA3, 0x80
ldi exp_lo, lo8(1)
ldi exp_hi, hi8(1)
- XCALL _U(ldexp) ; possible overflow -- no matter
- XCALL _U(exp)
- ; save result and calculate 1 + exp(-2*fabs(x))
+ XCALL _U(ldexpf) ; possible overflow -- no matter
+ XCALL _U(expf)
+ ; save result and calculate 1 + expf(-2*fabsf(x))
push rA3
push rA2
push rA1
@@ -81,7 +82,7 @@ ENTRY tanh
ldi rB2, hlo8(FL_P1)
ldi rB3, hhi8(FL_P1)
XCALL _U(__addsf3)
- ; save/restore and calculate 1 - exp(-2*fabs(x))
+ ; save/restore and calculate 1 - expf(-2*fabsf(x))
pop rB0
pop rB1
pop rB2
Index: libm/fplib/trunc.S
===================================================================
--- libm/fplib/trunc.S (revision 2548)
+++ libm/fplib/trunc.S (working copy)
@@ -32,16 +32,16 @@
#include "fp32def.h"
#include "asmdef.h"
-/* double trunc (double x);
- The trunc() function rounds x to the nearest integer not larger in
+/* float truncf (float x);
+ The truncf() function rounds x to the nearest integer not larger in
absolute value.
Examples:
- trunc(1.9) --> 1.0
- trunc(-1.9) --> -1.0
+ truncf(1.9) --> 1.0
+ truncf(-1.9) --> -1.0
*/
-ENTRY trunc
+ENTRY_FLOAT truncf trunc truncl
XCALL _U(__fp_trunc)
brcs 2f ; pass nonfinite arg as is
cpi rA3, 127