OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [newlib/] [newlib/] [libm/] [math/] [wrf_lgamma.c] - Blame information for rev 39

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
/* wrf_lgamma.c -- float version of wr_lgamma.c.
2
 * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3
 */
4
 
5
/*
6
 * ====================================================
7
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8
 *
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
 * ====================================================
14
 */
15
 
16
/*
17
 * wrapper float lgammaf_r(float x, int *signgamp)
18
 */
19
 
20
#include "fdlibm.h"
21
#include <errno.h>
22
 
23
#ifdef __STDC__
24
        float lgammaf_r(float x, int *signgamp) /* wrapper lgammaf_r */
25
#else
26
        float lgammaf_r(x,signgamp)              /* wrapper lgammaf_r */
27
        float x; int *signgamp;
28
#endif
29
{
30
#ifdef _IEEE_LIBM
31
        return __ieee754_lgammaf_r(x,signgamp);
32
#else
33
        float y;
34
        struct exception exc;
35
        y = __ieee754_lgammaf_r(x,signgamp);
36
        if(_LIB_VERSION == _IEEE_) return y;
37
        if(!finitef(y)&&finitef(x)) {
38
#ifndef HUGE_VAL 
39
#define HUGE_VAL inf
40
            double inf = 0.0;
41
 
42
            SET_HIGH_WORD(inf,0x7ff00000);      /* set inf to infinite */
43
#endif
44
            exc.name = "lgammaf";
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) or lgamma(0) */
51
                exc.type = SING;
52
                if (_LIB_VERSION == _POSIX_)
53
                   errno = EDOM;
54
                else if (!matherr(&exc)) {
55
                   errno = EDOM;
56
                }
57
 
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;
65
                }
66
            }
67
            if (exc.err != 0)
68
               errno = exc.err;
69
            return (float)exc.retval;
70
        } else
71
            return y;
72
#endif
73
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.