Debian Codegraph @

mingw-w64-crt/math/x86/cossin.c

raw
1 /**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6
7 void sincos (double __x, double *p_sin, double *p_cos);
8 void sincosf (float __x, float *p_sin, float *p_cos);
9
10 void sincos (double __x, double *p_sin, double *p_cos)
11 {
12 long double c, s;
13
14 __asm__ __volatile__ ("fsincos\n\t"
15 "fnstsw %%ax\n\t"
16 "testl $0x400, %%eax\n\t"
17 "jz 1f\n\t"
18 "fldpi\n\t"
19 "fadd %%st(0)\n\t"
20 "fxch %%st(1)\n\t"
21 "2: fprem1\n\t"
22 "fnstsw %%ax\n\t"
23 "testl $0x400, %%eax\n\t"
24 "jnz 2b\n\t"
25 "fstp %%st(1)\n\t"
26 "fsincos\n\t"
27 "1:" : "=t" (c), "=u" (s) : "0" (__x) : "eax");
28 *p_sin = (double) s;
29 *p_cos = (double) c;
30 }
31
32 void sincosf (float __x, float *p_sin, float *p_cos)
33 {
34 long double c, s;
35
36 __asm__ __volatile__ ("fsincos\n\t"
37 "fnstsw %%ax\n\t"
38 "testl $0x400, %%eax\n\t"
39 "jz 1f\n\t"
40 "fldpi\n\t"
41 "fadd %%st(0)\n\t"
42 "fxch %%st(1)\n\t"
43 "2: fprem1\n\t"
44 "fnstsw %%ax\n\t"
45 "testl $0x400, %%eax\n\t"
46 "jnz 2b\n\t"
47 "fstp %%st(1)\n\t"
48 "fsincos\n\t"
49 "1:" : "=t" (c), "=u" (s) : "0" (__x) : "eax");
50 *p_sin = (float) s;
51 *p_cos = (float) c;
52 }