Back to index

glibc  2.9
s_csin.c
Go to the documentation of this file.
00001 /* Complex sine function.  m68k fpu version
00002    Copyright (C) 1997, 1999 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #include <complex.h>
00022 #include <math.h>
00023 #include "mathimpl.h"
00024 
00025 #ifndef SUFF
00026 #define SUFF
00027 #endif
00028 #ifndef float_type
00029 #define float_type double
00030 #endif
00031 
00032 #define CONCATX(a,b) __CONCAT(a,b)
00033 #define s(name) CONCATX(name,SUFF)
00034 #define m81(func) __m81_u(s(func))
00035 
00036 __complex__ float_type
00037 s(__csin) (__complex__ float_type x)
00038 {
00039   __complex__ float_type retval;
00040   unsigned long rx_cond = __m81_test (__real__ x);
00041 
00042   if ((rx_cond & (__M81_COND_INF|__M81_COND_NAN)) == 0)
00043     {
00044       /* Real part is finite.  */
00045       float_type sin_rx, cos_rx;
00046 
00047       __asm ("fsincos%.x %2,%1:%0" : "=f" (sin_rx), "=f" (cos_rx)
00048             : "f" (__real__ x));
00049       if (rx_cond & __M81_COND_ZERO)
00050        __real__ retval = __real__ x;
00051       else
00052        __real__ retval = sin_rx * m81(__ieee754_cosh) (__imag__ x);
00053       __imag__ retval = cos_rx * m81(__ieee754_sinh) (__imag__ x);
00054     }
00055   else
00056     {
00057       unsigned long ix_cond = __m81_test (__imag__ x);
00058 
00059       __real__ retval = __real__ x - __real__ x;
00060       if (ix_cond & (__M81_COND_ZERO|__M81_COND_INF|__M81_COND_NAN))
00061        __imag__ retval = __imag__ x;
00062       else
00063        __imag__ retval = __real__ retval;
00064     }
00065 
00066   return retval;
00067 }
00068 #define weak_aliasx(a,b) weak_alias(a,b)
00069 weak_aliasx (s(__csin), s(csin))