1997-06-21 02:33:37 +00:00
|
|
|
/* Inline math functions for Alpha.
|
2007-03-14 17:44:14 +00:00
|
|
|
Copyright (C) 1996, 1997, 1999-2001, 2004, 2007
|
|
|
|
Free Software Foundation, Inc.
|
1997-06-21 02:33:37 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
Contributed by David Mosberger-Tang.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 04:56:23 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
1997-06-21 02:33:37 +00:00
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2001-07-06 04:56:23 +00:00
|
|
|
Lesser General Public License for more details.
|
1997-06-21 02:33:37 +00:00
|
|
|
|
2001-07-06 04:56:23 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-03-09 23:56:38 +00:00
|
|
|
License along with the GNU C Library. If not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
1997-06-21 02:33:37 +00:00
|
|
|
|
1998-03-01 00:56:41 +00:00
|
|
|
#ifndef _MATH_H
|
|
|
|
# error "Never use <bits/mathinline.h> directly; include <math.h> instead."
|
|
|
|
#endif
|
|
|
|
|
2007-09-15 02:31:47 +00:00
|
|
|
#ifndef __extern_inline
|
1998-03-01 00:56:41 +00:00
|
|
|
# define __MATH_INLINE __inline
|
|
|
|
#else
|
2007-03-17 17:04:09 +00:00
|
|
|
# define __MATH_INLINE __extern_inline
|
1998-03-01 00:56:41 +00:00
|
|
|
#endif
|
|
|
|
|
2004-03-10 05:58:46 +00:00
|
|
|
#if defined __USE_ISOC99 && defined __GNUC__ && !__GNUC_PREREQ(3,0)
|
|
|
|
# undef isgreater
|
|
|
|
# undef isgreaterequal
|
|
|
|
# undef isless
|
|
|
|
# undef islessequal
|
|
|
|
# undef islessgreater
|
|
|
|
# undef isunordered
|
|
|
|
# define isunordered(u, v) \
|
1998-03-01 00:56:41 +00:00
|
|
|
(__extension__ \
|
2004-03-10 05:58:46 +00:00
|
|
|
({ double __r, __u = (u), __v = (v); \
|
1998-03-01 00:56:41 +00:00
|
|
|
__asm ("cmptun/su %1,%2,%0\n\ttrapb" \
|
2004-03-10 05:58:46 +00:00
|
|
|
: "=&f" (__r) : "f" (__u), "f"(__v)); \
|
1998-03-01 00:56:41 +00:00
|
|
|
__r != 0; }))
|
1999-10-31 17:31:25 +00:00
|
|
|
#endif /* ISO C99 */
|
1998-03-01 00:56:41 +00:00
|
|
|
|
2003-06-24 16:33:49 +00:00
|
|
|
#if (!defined __NO_MATH_INLINES || defined __LIBC_INTERNAL_MATH_INLINES) \
|
|
|
|
&& defined __OPTIMIZE__
|
2001-02-07 18:20:36 +00:00
|
|
|
|
2005-02-08 04:37:48 +00:00
|
|
|
#if !__GNUC_PREREQ (4, 0)
|
|
|
|
# define __inline_copysign(NAME, TYPE) \
|
1998-03-01 00:56:41 +00:00
|
|
|
__MATH_INLINE TYPE \
|
2004-09-12 18:13:16 +00:00
|
|
|
__NTH (NAME (TYPE __x, TYPE __y)) \
|
1998-03-01 00:56:41 +00:00
|
|
|
{ \
|
|
|
|
TYPE __z; \
|
|
|
|
__asm ("cpys %1, %2, %0" : "=f" (__z) : "f" (__y), "f" (__x)); \
|
|
|
|
return __z; \
|
|
|
|
}
|
|
|
|
|
2004-09-12 18:13:16 +00:00
|
|
|
__inline_copysign (__copysignf, float)
|
|
|
|
__inline_copysign (copysignf, float)
|
|
|
|
__inline_copysign (__copysign, double)
|
|
|
|
__inline_copysign (copysign, double)
|
1998-03-01 00:56:41 +00:00
|
|
|
|
2005-02-08 04:37:48 +00:00
|
|
|
# undef __inline_copysign
|
|
|
|
#endif
|
1998-03-01 00:56:41 +00:00
|
|
|
|
|
|
|
|
2005-02-08 04:37:48 +00:00
|
|
|
#if !__GNUC_PREREQ (2, 8)
|
2004-09-12 18:13:16 +00:00
|
|
|
# define __inline_fabs(NAME, TYPE) \
|
1998-03-01 00:56:41 +00:00
|
|
|
__MATH_INLINE TYPE \
|
2004-09-12 18:13:16 +00:00
|
|
|
__NTH (NAME (TYPE __x)) \
|
1998-03-01 00:56:41 +00:00
|
|
|
{ \
|
|
|
|
TYPE __z; \
|
|
|
|
__asm ("cpys $f31, %1, %0" : "=f" (__z) : "f" (__x)); \
|
|
|
|
return __z; \
|
|
|
|
}
|
|
|
|
|
2004-09-12 18:13:16 +00:00
|
|
|
__inline_fabs (__fabsf, float)
|
|
|
|
__inline_fabs (fabsf, float)
|
|
|
|
__inline_fabs (__fabs, double)
|
|
|
|
__inline_fabs (fabs, double)
|
1998-03-01 00:56:41 +00:00
|
|
|
|
2004-09-12 18:13:16 +00:00
|
|
|
# undef __inline_fabs
|
1998-03-01 00:56:41 +00:00
|
|
|
#endif
|
|
|
|
|
2000-06-07 16:53:09 +00:00
|
|
|
#ifdef __USE_ISOC99
|
|
|
|
|
2003-06-24 16:33:49 +00:00
|
|
|
/* Test for negative number. Used in the signbit() macro. */
|
2004-09-12 18:13:16 +00:00
|
|
|
__MATH_INLINE int
|
|
|
|
__NTH (__signbitf (float __x))
|
2003-06-24 16:33:49 +00:00
|
|
|
{
|
2007-03-14 17:44:14 +00:00
|
|
|
#if !__GNUC_PREREQ (4, 0)
|
2003-06-24 16:33:49 +00:00
|
|
|
__extension__ union { float __f; int __i; } __u = { __f: __x };
|
|
|
|
return __u.__i < 0;
|
2007-03-14 17:44:14 +00:00
|
|
|
#else
|
|
|
|
return __builtin_signbitf (__x);
|
|
|
|
#endif
|
2003-06-24 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2004-09-12 18:13:16 +00:00
|
|
|
__MATH_INLINE int
|
|
|
|
__NTH (__signbit (double __x))
|
2003-06-24 16:33:49 +00:00
|
|
|
{
|
2007-03-14 17:44:14 +00:00
|
|
|
#if !__GNUC_PREREQ (4, 0)
|
2003-06-24 16:33:49 +00:00
|
|
|
__extension__ union { double __d; long __i; } __u = { __d: __x };
|
|
|
|
return __u.__i < 0;
|
2007-03-14 17:44:14 +00:00
|
|
|
#else
|
|
|
|
return __builtin_signbit (__x);
|
|
|
|
#endif
|
2003-06-24 16:33:49 +00:00
|
|
|
}
|
|
|
|
|
2007-03-14 00:40:50 +00:00
|
|
|
__MATH_INLINE int
|
|
|
|
__NTH (__signbitl (long double __x))
|
|
|
|
{
|
2007-03-14 17:44:14 +00:00
|
|
|
#if !__GNUC_PREREQ (4, 0)
|
2007-03-14 00:40:50 +00:00
|
|
|
__extension__ union {
|
|
|
|
long double __d;
|
|
|
|
long __i[sizeof(long double)/sizeof(long)];
|
|
|
|
} __u = { __d: __x };
|
|
|
|
return __u.__i[sizeof(long double)/sizeof(long) - 1] < 0;
|
2007-03-14 17:44:14 +00:00
|
|
|
#else
|
|
|
|
return __builtin_signbitl (__x);
|
|
|
|
#endif
|
2007-03-14 00:40:50 +00:00
|
|
|
}
|
|
|
|
|
2007-03-14 17:44:14 +00:00
|
|
|
/* Test for NaN. Used in the isnan() macro. */
|
|
|
|
|
|
|
|
__MATH_INLINE int
|
|
|
|
__NTH (__isnanf (float __x))
|
|
|
|
{
|
|
|
|
return isunordered (__x, __x);
|
|
|
|
}
|
|
|
|
|
|
|
|
__MATH_INLINE int
|
|
|
|
__NTH (__isnan (double __x))
|
|
|
|
{
|
|
|
|
return isunordered (__x, __x);
|
|
|
|
}
|
|
|
|
|
2007-05-07 22:57:20 +00:00
|
|
|
#ifndef __NO_LONG_DOUBLE_MATH
|
2007-03-14 17:44:14 +00:00
|
|
|
__MATH_INLINE int
|
|
|
|
__NTH (__isnanl (long double __x))
|
|
|
|
{
|
|
|
|
return isunordered (__x, __x);
|
|
|
|
}
|
2007-05-07 22:57:20 +00:00
|
|
|
#endif
|
|
|
|
|
2001-02-07 18:20:36 +00:00
|
|
|
#endif /* C99 */
|
|
|
|
|
|
|
|
#endif /* __NO_MATH_INLINES */
|