fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / newlib / libm / math / wf_lgamma.c
blobf1bf0c0193f7d749486d74858d01c42b5ae1c8c4
1 /* wf_lgamma.c -- float version of w_lgamma.c.
2 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3 */
5 /*
6 * ====================================================
7 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9 * Developed at SunPro, a Sun Microsystems, Inc. business.
10 * Permission to use, copy, modify, and distribute this
11 * software is freely granted, provided that this notice
12 * is preserved.
13 * ====================================================
17 #include "fdlibm.h"
18 #include <reent.h>
19 #include <errno.h>
21 #ifdef __STDC__
22 float lgammaf(float x)
23 #else
24 float lgammaf(x)
25 float x;
26 #endif
28 #ifdef _IEEE_LIBM
29 return __ieee754_lgammaf_r(x,&(_REENT_SIGNGAM(_REENT)));
30 #else
31 float y;
32 struct exception exc;
33 y = __ieee754_lgammaf_r(x,&(_REENT_SIGNGAM(_REENT)));
34 if(_LIB_VERSION == _IEEE_) return y;
35 if(!finitef(y)&&finitef(x)) {
36 #ifndef HUGE_VAL
37 #define HUGE_VAL inf
38 double inf = 0.0;
40 SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */
41 #endif
42 exc.name = "lgammaf";
43 exc.err = 0;
44 exc.arg1 = exc.arg2 = (double)x;
45 if (_LIB_VERSION == _SVID_)
46 exc.retval = HUGE;
47 else
48 exc.retval = HUGE_VAL;
49 if(floorf(x)==x&&x<=(float)0.0) {
50 /* lgammaf(-integer) */
51 exc.type = SING;
52 if (_LIB_VERSION == _POSIX_)
53 errno = EDOM;
54 else if (!matherr(&exc)) {
55 errno = EDOM;
58 } else {
59 /* lgammaf(finite) overflow */
60 exc.type = OVERFLOW;
61 if (_LIB_VERSION == _POSIX_)
62 errno = ERANGE;
63 else if (!matherr(&exc)) {
64 errno = ERANGE;
67 if (exc.err != 0)
68 errno = exc.err;
69 return (float)exc.retval;
70 } else
71 return y;
72 #endif
75 #ifdef _DOUBLE_IS_32BITS
77 #ifdef __STDC__
78 double lgamma(double x)
79 #else
80 double lgamma(x)
81 double x;
82 #endif
84 return (double) lgammaf((float) x);
87 #endif /* defined(_DOUBLE_IS_32BITS) */