Blame sysdeps/powerpc/fpu/s_sinf.c

Packit 6c4009
/* s_sinf.c -- float version of s_sin.c.
Packit 6c4009
   Copyright (C) 2011-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
   Contributed by Adhemerval Zanella <azanella@br.ibm.com>, 2011
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Library General Public License as
Packit 6c4009
   published by the Free Software Foundation; either version 2 of the
Packit 6c4009
   License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Library General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Library General Public
Packit 6c4009
   License along with the GNU C Library; see the file COPYING.LIB.  If
Packit 6c4009
   not, see <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <errno.h>
Packit 6c4009
#include <math.h>
Packit 6c4009
#include <math_private.h>
Packit 6c4009
#include <libm-alias-float.h>
Packit 6c4009
Packit 6c4009
static const float pio4 = 7.8539801e-1;
Packit 6c4009
Packit 6c4009
float
Packit 6c4009
__sinf (float x)
Packit 6c4009
{
Packit 6c4009
  float y[2], z = 0.0;
Packit 6c4009
  float ix;
Packit 6c4009
  int32_t n;
Packit 6c4009
Packit 6c4009
  ix = __builtin_fabsf (x);
Packit 6c4009
Packit 6c4009
  /* |x| ~< pi/4 */
Packit 6c4009
  if (ix <= pio4)
Packit 6c4009
    {
Packit 6c4009
      return __kernel_sinf (x, z, 0);
Packit 6c4009
      /* sin(Inf or NaN) is NaN */
Packit 6c4009
    }
Packit 6c4009
  else if (isnanf (ix))
Packit 6c4009
    {
Packit 6c4009
      return x - x;
Packit 6c4009
    }
Packit 6c4009
  else if (isinff (ix))
Packit 6c4009
    {
Packit 6c4009
      __set_errno (EDOM);
Packit 6c4009
      return x - x;
Packit 6c4009
    }
Packit 6c4009
Packit 6c4009
  /* argument reduction needed */
Packit 6c4009
  else
Packit 6c4009
    {
Packit 6c4009
      n = __ieee754_rem_pio2f (x, y);
Packit 6c4009
      switch (n & 3)
Packit 6c4009
	{
Packit 6c4009
	case 0:
Packit 6c4009
	  return __kernel_sinf (y[0], y[1], 1);
Packit 6c4009
	case 1:
Packit 6c4009
	  return __kernel_cosf (y[0], y[1]);
Packit 6c4009
	case 2:
Packit 6c4009
	  return -__kernel_sinf (y[0], y[1], 1);
Packit 6c4009
	default:
Packit 6c4009
	  return -__kernel_cosf (y[0], y[1]);
Packit 6c4009
	}
Packit 6c4009
    }
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
libm_alias_float (__sin, sin)