source: trunk/libs/newlib/src/newlib/libm/math/w_j1.c @ 471

Last change on this file since 471 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.6 KB
Line 
1
2/* @(#)w_j1.c 5.1 93/09/24 */
3/*
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 *
7 * Developed at SunPro, a Sun Microsystems, Inc. business.
8 * Permission to use, copy, modify, and distribute this
9 * software is freely granted, provided that this notice
10 * is preserved.
11 * ====================================================
12 */
13
14/*
15 * wrapper of j1,y1
16 */
17
18#include "fdlibm.h"
19#include <errno.h>
20
21#ifndef _DOUBLE_IS_32BITS
22
23#ifdef __STDC__
24        double j1(double x)             /* wrapper j1 */
25#else
26        double j1(x)                    /* wrapper j1 */
27        double x;
28#endif
29{
30#ifdef _IEEE_LIBM
31        return __ieee754_j1(x);
32#else
33        double z;
34        struct exception exc;
35        z = __ieee754_j1(x);
36        if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
37        if(fabs(x)>X_TLOSS) {
38            /* j1(|x|>X_TLOSS) */
39            exc.type = TLOSS;
40            exc.name = "j1";
41            exc.err = 0;
42            exc.arg1 = exc.arg2 = x;
43            exc.retval = 0.0;
44            if (_LIB_VERSION == _POSIX_)
45                errno = ERANGE;
46            else if (!matherr(&exc)) {
47                errno = ERANGE;
48            }       
49            if (exc.err != 0)
50               errno = exc.err;
51            return exc.retval; 
52        } else
53            return z;
54#endif
55}
56
57#ifdef __STDC__
58        double y1(double x)             /* wrapper y1 */
59#else
60        double y1(x)                    /* wrapper y1 */
61        double x;
62#endif
63{
64#ifdef _IEEE_LIBM
65        return __ieee754_y1(x);
66#else
67        double z;
68        struct exception exc;
69        z = __ieee754_y1(x);
70        if(_LIB_VERSION == _IEEE_ || isnan(x) ) return z;
71        if(x <= 0.0){
72#ifndef HUGE_VAL
73#define HUGE_VAL inf
74            double inf = 0.0;
75
76            SET_HIGH_WORD(inf,0x7ff00000);      /* set inf to infinite */
77#endif
78            /* y1(0) = -inf  or y1(x<0) = NaN */
79            exc.type = DOMAIN;  /* should be SING for IEEE */
80            exc.name = "y1";
81            exc.err = 0;
82            exc.arg1 = exc.arg2 = x;
83            if (_LIB_VERSION == _SVID_)
84               exc.retval = -HUGE;
85            else
86               exc.retval = -HUGE_VAL;
87            if (_LIB_VERSION == _POSIX_)
88               errno = EDOM;
89            else if (!matherr(&exc)) {
90               errno = EDOM;
91            }
92            if (exc.err != 0)
93               errno = exc.err;
94            return exc.retval;             
95        }
96        if(x>X_TLOSS) {
97            /* y1(x>X_TLOSS) */
98            exc.type = TLOSS;
99            exc.name = "y1";
100            exc.err = 0;
101            exc.arg1 = exc.arg2 = x;
102            exc.retval = 0.0;
103            if (_LIB_VERSION == _POSIX_)
104                errno = ERANGE;
105            else if (!matherr(&exc)) {
106                errno = ERANGE;
107            }       
108            if (exc.err != 0)
109               errno = exc.err;
110            return exc.retval; 
111        } else
112            return z;
113#endif
114}
115
116#endif /* defined(_DOUBLE_IS_32BITS) */
117
118
119
120
121
Note: See TracBrowser for help on using the repository browser.