revert between 56095 -> 55830 in arch
[AROS.git] / compiler / stdc / math / s_sincos.c
blob22f838bf65c45523b3964a1a2a9f8ad125961d89
1 /* @(#)s_sincos.c 5.1 13/07/15 */
2 /*
3 * ====================================================
4 * Copyright (C) 2013 Elliot Saba. All rights reserved.
6 * Developed at the University of Washington.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
9 * is preserved.
10 * ====================================================
13 #include <aros/debug.h>
15 #include <float.h>
16 #include "math.h"
17 #define INLINE_REM_PIO2
18 #include "math_private.h"
19 #include "e_rem_pio2.c"
20 #include "k_sincos.h"
22 void
23 sincos(double x, double *sn, double *cs)
25 double y[2];
26 int32_t n, ix;
28 /* High word of x. */
29 GET_HIGH_WORD(ix,x);
31 /* |x| ~< pi/4 */
32 ix &= 0x7fffffff;
33 if(ix <= 0x3fe921fb) {
34 if (ix < 0x3e400000) { /* |x| < 2**-27 */
35 if ((int)x == 0) { /* Generate inexact. */
36 *sn = x;
37 *cs = 1;
38 return;
41 __kernel_sincos(x, 0, 0, sn, cs);
42 return;
45 /* If x = Inf or NaN, then sin(x) = NaN and cos(x) = NaN. */
46 if (ix >= 0x7ff00000) {
47 *sn = x - x;
48 *cs = x - x;
49 return;
52 /* Argument reduction. */
53 n = __ieee754_rem_pio2(x, y);
55 switch(n&3) {
56 case 0:
57 __kernel_sincos(y[0], y[1], 1, sn, cs);
58 break;
59 case 1:
60 __kernel_sincos(y[0], y[1], 1, cs, sn);
61 *cs = -*cs;
62 break;
63 case 2:
64 __kernel_sincos(y[0], y[1], 1, sn, cs);
65 *sn = -*sn;
66 *cs = -*cs;
67 break;
68 default:
69 __kernel_sincos(y[0], y[1], 1, cs, sn);
70 *sn = -*sn;
71 break;
75 #if (LDBL_MANT_DIG == 53)
76 AROS_MAKE_ASM_SYM(typeof(sincosl), sincosl, AROS_CSYM_FROM_ASM_NAME(sincosl), AROS_CSYM_FROM_ASM_NAME(sincos));
77 AROS_EXPORT_ASM_SYM(AROS_CSYM_FROM_ASM_NAME(sincosl));
78 #endif