iconv: Remove _STRING_ARCH_unaligned usage for get/set macros
[glibc.git] / math / s_cacos_template.c
blob719b986d28347efd6f02585b8aaf82e7fd2c7427
1 /* Return cosine of a complex type.
2 Copyright (C) 1997-2023 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 <https://www.gnu.org/licenses/>. */
19 #include <complex.h>
20 #include <math.h>
22 CFLOAT
23 M_DECL_FUNC (__cacos) (CFLOAT x)
25 CFLOAT y;
26 CFLOAT res;
27 int rcls = fpclassify (__real__ x);
28 int icls = fpclassify (__imag__ x);
30 if (rcls <= FP_INFINITE || icls <= FP_INFINITE
31 || (rcls == FP_ZERO && icls == FP_ZERO))
33 y = M_SUF (__casin) (x);
35 __real__ res = M_MLIT (M_PI_2) - __real__ y;
36 if (__real__ res == 0)
37 __real__ res = 0;
38 __imag__ res = -__imag__ y;
40 else
42 __real__ y = -__imag__ x;
43 __imag__ y = __real__ x;
45 y = M_SUF (__kernel_casinh) (y, 1);
47 __real__ res = __imag__ y;
48 __imag__ res = __real__ y;
51 return res;
54 declare_mgen_alias (__cacos, cacos);