• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 sincosl (long double __x, long double *p_sin, long double *p_cos);
9 void sincosf (float __x, float *p_sin, float *p_cos);
10 
sincos(double __x,double * p_sin,double * p_cos)11 void sincos (double __x, double *p_sin, double *p_cos)
12 {
13   long double c, s;
14 
15   __asm__ __volatile__ ("fsincos\n\t"
16     "fnstsw    %%ax\n\t"
17     "testl     $0x400, %%eax\n\t"
18     "jz        1f\n\t"
19     "fldpi\n\t"
20     "fadd      %%st(0)\n\t"
21     "fxch      %%st(1)\n\t"
22     "2: fprem1\n\t"
23     "fnstsw    %%ax\n\t"
24     "testl     $0x400, %%eax\n\t"
25     "jnz       2b\n\t"
26     "fstp      %%st(1)\n\t"
27     "fsincos\n\t"
28     "1:" : "=t" (c), "=u" (s) : "0" (__x) : "eax");
29   *p_sin = (double) s;
30   *p_cos = (double) c;
31 }
32 
sincosf(float __x,float * p_sin,float * p_cos)33 void sincosf (float __x, float *p_sin, float *p_cos)
34 {
35   long double c, s;
36 
37   __asm__ __volatile__ ("fsincos\n\t"
38     "fnstsw    %%ax\n\t"
39     "testl     $0x400, %%eax\n\t"
40     "jz        1f\n\t"
41     "fldpi\n\t"
42     "fadd      %%st(0)\n\t"
43     "fxch      %%st(1)\n\t"
44     "2: fprem1\n\t"
45     "fnstsw    %%ax\n\t"
46     "testl     $0x400, %%eax\n\t"
47     "jnz       2b\n\t"
48     "fstp      %%st(1)\n\t"
49     "fsincos\n\t"
50     "1:" : "=t" (c), "=u" (s) : "0" (__x) : "eax");
51   *p_sin = (float) s;
52   *p_cos = (float) c;
53 }
54 
sincosl(long double __x,long double * p_sin,long double * p_cos)55 void sincosl (long double __x, long double *p_sin, long double *p_cos)
56 {
57   long double c, s;
58 
59   __asm__ __volatile__ ("fsincos\n\t"
60     "fnstsw    %%ax\n\t"
61     "testl     $0x400, %%eax\n\t"
62     "jz        1f\n\t"
63     "fldpi\n\t"
64     "fadd      %%st(0)\n\t"
65     "fxch      %%st(1)\n\t"
66     "2: fprem1\n\t"
67     "fnstsw    %%ax\n\t"
68     "testl     $0x400, %%eax\n\t"
69     "jnz       2b\n\t"
70     "fstp      %%st(1)\n\t"
71     "fsincos\n\t"
72     "1:" : "=t" (c), "=u" (s) : "0" (__x) : "eax");
73   *p_sin = s;
74   *p_cos = c;
75 }
76