hurd: Fix building libio/tst-memstream3.c
[glibc.git] / sysdeps / powerpc / bits / mathinline.h
blob75cf7175e4ca5a42cf5672ef68bc07aaf3524c48
1 /* Inline math functions for powerpc.
2 Copyright (C) 1995-2018 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, see
17 <http://www.gnu.org/licenses/>. */
19 #ifndef _MATH_H
20 # error "Never use <bits/mathinline.h> directly; include <math.h> instead."
21 #endif
23 #ifndef __extern_inline
24 # define __MATH_INLINE __inline
25 #else
26 # define __MATH_INLINE __extern_inline
27 #endif /* __cplusplus */
29 #if defined __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_FPRS__
31 #if !defined __NO_MATH_INLINES && defined __OPTIMIZE__
33 #ifdef __USE_ISOC99
35 # ifndef __powerpc64__
36 __MATH_INLINE long int lrint (double __x) __THROW;
37 __MATH_INLINE long int
38 __NTH (lrint (double __x))
40 union {
41 double __d;
42 long long __ll;
43 } __u;
44 __asm__ ("fctiw %0,%1" : "=f"(__u.__d) : "f"(__x));
45 return __u.__ll;
48 __MATH_INLINE long int lrintf (float __x) __THROW;
49 __MATH_INLINE long int
50 __NTH (lrintf (float __x))
52 return lrint ((double) __x);
54 # endif
56 __MATH_INLINE double fdim (double __x, double __y) __THROW;
57 __MATH_INLINE double
58 __NTH (fdim (double __x, double __y))
60 return __x <= __y ? 0 : __x - __y;
63 __MATH_INLINE float fdimf (float __x, float __y) __THROW;
64 __MATH_INLINE float
65 __NTH (fdimf (float __x, float __y))
67 return __x <= __y ? 0 : __x - __y;
70 #endif /* __USE_ISOC99 */
71 #endif /* !__NO_MATH_INLINES && __OPTIMIZE__ */
72 #endif /* __GNUC__ && !_SOFT_FLOAT && !__NO_FPRS__ */