fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libm / math / wr_gamma.c
blob0092ed02c77ccc926e949abf21591a7190860714
2 /* @(#)wr_gamma.c 5.1 93/09/24 */
3 /*
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
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 * ====================================================
14 /*
15 * wrapper double gamma_r(double x, int *signgamp)
18 #include "fdlibm.h"
19 #include <errno.h>
21 #ifndef _DOUBLE_IS_32BITS
23 #ifdef __STDC__
24 double gamma_r(double x, int *signgamp) /* wrapper lgamma_r */
25 #else
26 double gamma_r(x,signgamp) /* wrapper lgamma_r */
27 double x; int *signgamp;
28 #endif
30 #ifdef _IEEE_LIBM
31 return __ieee754_gamma_r(x,signgamp);
32 #else
33 double y;
34 struct exception exc;
35 y = __ieee754_gamma_r(x,signgamp);
36 if(_LIB_VERSION == _IEEE_) return y;
37 if(!finite(y)&&finite(x)) {
38 #ifndef HUGE_VAL
39 #define HUGE_VAL inf
40 double inf = 0.0;
42 SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */
43 #endif
44 exc.name = "gamma";
45 exc.err = 0;
46 exc.arg1 = exc.arg2 = (double)x;
47 if (_LIB_VERSION == _SVID_)
48 exc.retval = HUGE;
49 else
50 exc.retval = HUGE_VAL;
51 if(floor(x)==x&&x<=0.0) {
52 /* gamma(-integer) or gamma(0) */
53 exc.type = SING;
54 if (_LIB_VERSION == _POSIX_)
55 errno = EDOM;
56 else if (!matherr(&exc)) {
57 errno = EDOM;
59 } else {
60 /* gamma(finite) overflow */
61 exc.type = OVERFLOW;
62 if (_LIB_VERSION == _POSIX_)
63 errno = ERANGE;
64 else if (!matherr(&exc)) {
65 errno = ERANGE;
68 if (exc.err != 0)
69 errno = exc.err;
70 return exc.retval;
71 } else
72 return y;
73 #endif
76 #endif /* defined(_DOUBLE_IS_32BITS) */