Back to index

glibc  2.9
mathinline.h
Go to the documentation of this file.
00001 /* Inline math functions for s390.
00002    Copyright (C) 2004, 2007 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef _MATH_H
00021 # error "Never use <bits/mathinline.h> directly; include <math.h> instead."
00022 #endif
00023 
00024 #ifndef __extern_inline
00025 # define __MATH_INLINE __inline
00026 #else
00027 # define __MATH_INLINE __extern_inline
00028 #endif
00029 
00030 #if (!defined __NO_MATH_INLINES || defined __LIBC_INTERNAL_MATH_INLINES) \
00031     && defined __OPTIMIZE__
00032 
00033 #ifdef __USE_ISOC99
00034 
00035 /* Test for negative number.  Used in the signbit() macro.  */
00036 __MATH_INLINE int
00037 __NTH (__signbitf (float __x))
00038 {
00039   __extension__ union { float __f; int __i; } __u = { __f: __x };
00040   return __u.__i < 0;
00041 }
00042 
00043 __MATH_INLINE int
00044 __NTH (__signbit (double __x))
00045 {
00046   __extension__ union { double __d; long __i; } __u = { __d: __x };
00047   return __u.__i < 0;
00048 }
00049 
00050 # ifndef __NO_LONG_DOUBLE_MATH
00051 __MATH_INLINE int
00052 __NTH (__signbitl (long double __x))
00053 {
00054   __extension__ union { long double __l; int __i[4]; } __u = { __l: __x };
00055   return __u.__i[0] < 0;
00056 }
00057 # else
00058 __MATH_INLINE int
00059 __NTH (__signbitl (long double __x))
00060 {
00061   return __signbit ((double) __x);
00062 }
00063 # endif
00064 
00065 #endif /* C99 */
00066 
00067 /* This code is used internally in the GNU libc.  */
00068 #ifdef __LIBC_INTERNAL_MATH_INLINES
00069 
00070 __MATH_INLINE double
00071 __NTH (__ieee754_sqrt (double x))
00072 {
00073   double res;
00074 
00075   asm ( "sqdbr %0,%1" : "=f" (res) : "f" (x) );
00076   return res;
00077 }
00078 
00079 __MATH_INLINE float
00080 __NTH (__ieee754_sqrtf (float x))
00081 {
00082   float res;
00083 
00084   asm ( "sqebr %0,%1" : "=f" (res) : "f" (x) );
00085   return res;
00086 }
00087 
00088 # if !defined __NO_LONG_DOUBLE_MATH
00089 __MATH_INLINE long double
00090 __NTH (sqrtl (long double __x))
00091 {
00092   long double res;
00093 
00094   asm ( "sqxbr %0,%1" : "=f" (res) : "f" (__x) );
00095   return res;
00096 }
00097 # endif /* !__NO_LONG_DOUBLE_MATH */
00098 
00099 #endif /* __LIBC_INTERNAL_MATH_INLINES */
00100 
00101 #endif /* __NO_MATH_INLINES */