1 /* Inline math functions for powerpc.
2 Copyright (C) 1995,1996,1997,1998,1999,2000 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 #if defined __GNUC__ && !defined _SOFT_FLOAT
23 # if __GNUC_PREREQ (2,96)
25 # define isgreater(x, y) __builtin_isgreater (x, y)
26 # define isgreaterequal(x, y) __builtin_isgreaterequal (x, y)
27 # define isless(x, y) __builtin_isless (x, y)
28 # define islessequal(x, y) __builtin_islessequal (x, y)
29 # define islessgreater(x, y) __builtin_islessgreater (x, y)
30 # define isunordered(x, y) __builtin_isunordered (x, y)
34 # define __unordered_cmp(x, y) \
36 ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \
38 __asm__("fcmpu 7,%1,%2 ; mfcr %0" : "=r" (__r) : "f" (__x), "f"(__y) \
42 # define isgreater(x, y) (__unordered_cmp (x, y) >> 2 & 1)
43 # define isgreaterequal(x, y) ((__unordered_cmp (x, y) & 6) != 0)
44 # define isless(x, y) (__unordered_cmp (x, y) >> 3 & 1)
45 # define islessequal(x, y) ((__unordered_cmp (x, y) & 0xA) != 0)
46 # define islessgreater(x, y) ((__unordered_cmp (x, y) & 0xC) != 0)
47 # define isunordered(x, y) (__unordered_cmp (x, y) & 1)
49 # endif /* __GNUC_PREREQ (2,97) */
50 #endif /* __USE_ISOC99 */
52 #if !defined __NO_MATH_INLINES && defined __OPTIMIZE__
54 #ifndef __extern_always_inline
55 # define __MATH_INLINE __inline
57 # define __MATH_INLINE __extern_always_inline
58 #endif /* __cplusplus */
61 __MATH_INLINE
long int lrint (double __x
) __THROW
;
62 __MATH_INLINE
long int
63 lrint (double __x
) __THROW
69 __asm__ ("fctiw %0,%1" : "=f"(__u
.__d
) : "f"(__x
));
73 __MATH_INLINE
long int lrintf (float __x
) __THROW
;
74 __MATH_INLINE
long int
75 lrintf (float __x
) __THROW
81 __asm__ ("fctiw %0,%1" : "=f"(__u
.__d
) : "f"(__x
));
85 __MATH_INLINE
double fdim (double __x
, double __y
) __THROW
;
87 fdim (double __x
, double __y
) __THROW
89 return __x
< __y
? 0 : __x
- __y
;
92 __MATH_INLINE
float fdimf (float __x
, float __y
) __THROW
;
94 fdimf (float __x
, float __y
) __THROW
96 return __x
< __y
? 0 : __x
- __y
;
99 #endif /* __USE_ISOC99 */
100 #endif /* !__NO_MATH_INLINES && __OPTIMIZE__ */
101 #endif /* __GNUC__ && !_SOFT_FLOAT */