2.9
[glibc/nacl-glibc.git] / sysdeps / powerpc / fpu / math_private.h
blob90021c6d3cb6463cf562617d6f34580698a91328
1 /* Private inline math functions for powerpc.
2 Copyright (C) 2006
3 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 51 Franklin St - Fifth Floor, Boston,
19 MA 02110-1301 USA */
21 #ifndef _PPC_MATH_PRIVATE_H_
22 #define _PPC_MATH_PRIVATE_H_
24 #include <sysdep.h>
25 #include <ldsodefs.h>
26 #include <dl-procinfo.h>
28 # if __WORDSIZE == 64 || defined _ARCH_PWR4
29 # define __CPU_HAS_FSQRT 1
30 # else
31 # define __CPU_HAS_FSQRT ((GLRO(dl_hwcap) & PPC_FEATURE_64) != 0)
32 # endif
34 # ifndef __LIBC_INTERNAL_MATH_INLINES
35 extern double __slow_ieee754_sqrt (double);
36 __inline double
37 __ieee754_sqrt (double __x)
39 double __z;
41 /* If the CPU is 64-bit we can use the optional FP instructions. */
42 if (__CPU_HAS_FSQRT)
44 /* Volatile is required to prevent the compiler from moving the
45 fsqrt instruction above the branch. */
46 __asm __volatile (
47 " fsqrt %0,%1\n"
48 : "=f" (__z)
49 : "f" (__x));
51 else
52 __z = __slow_ieee754_sqrt(__x);
54 return __z;
57 extern float __slow_ieee754_sqrtf (float);
59 __inline float
60 __ieee754_sqrtf (float __x)
62 float __z;
64 /* If the CPU is 64-bit we can use the optional FP instructions. */
65 if (__CPU_HAS_FSQRT)
67 /* Volatile is required to prevent the compiler from moving the
68 fsqrts instruction above the branch. */
69 __asm __volatile (
70 " fsqrts %0,%1\n"
71 : "=f" (__z)
72 : "f" (__x));
74 else
75 __z = __slow_ieee754_sqrtf(__x);
77 return __z;
79 #endif /* __LIBC_INTERNAL_MATH_INLINES */
81 #include <math/math_private.h>
83 #endif /* _PPC_MATH_PRIVATE_H_ */