OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc1/] [newlib/] [libm/] [math/] [wf_log.c] - Blame information for rev 345

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/* wf_log.c -- float version of w_log.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 logf(x)
18
 */
19
 
20
#include "fdlibm.h"
21
#include <errno.h>
22
 
23
#ifdef __STDC__
24
        float logf(float x)             /* wrapper logf */
25
#else
26
        float logf(x)                   /* wrapper logf */
27
        float x;
28
#endif
29
{
30
#ifdef _IEEE_LIBM
31
        return __ieee754_logf(x);
32
#else
33
        float z;
34
        struct exception exc;
35
        z = __ieee754_logf(x);
36
        if(_LIB_VERSION == _IEEE_ || isnan(x) || x > (float)0.0) return z;
37
#ifndef HUGE_VAL 
38
#define HUGE_VAL inf
39
        double inf = 0.0;
40
 
41
        SET_HIGH_WORD(inf,0x7ff00000);  /* set inf to infinite */
42
#endif
43
        exc.name = "logf";
44
        exc.err = 0;
45
        exc.arg1 = exc.arg2 = (double)x;
46
        if (_LIB_VERSION == _SVID_)
47
           exc.retval = -HUGE;
48
        else
49
           exc.retval = -HUGE_VAL;
50
        if(x==(float)0.0) {
51
            /* logf(0) */
52
            exc.type = SING;
53
            if (_LIB_VERSION == _POSIX_)
54
               errno = ERANGE;
55
            else if (!matherr(&exc)) {
56
               errno = ERANGE;
57
            }
58
        } else {
59
            /* logf(x<0) */
60
            exc.type = DOMAIN;
61
            if (_LIB_VERSION == _POSIX_)
62
               errno = EDOM;
63
            else if (!matherr(&exc)) {
64
               errno = EDOM;
65
            }
66
            exc.retval = nan("");
67
        }
68
        if (exc.err != 0)
69
           errno = exc.err;
70
        return (float)exc.retval;
71
#endif
72
}
73
 
74
#ifdef _DOUBLE_IS_32BITS
75
 
76
#ifdef __STDC__
77
        double log(double x)
78
#else
79
        double log(x)
80
        double x;
81
#endif
82
{
83
        return (double) logf((float) x);
84
}
85
 
86
#endif /* defined(_DOUBLE_IS_32BITS) */

powered by: WebSVN 2.1.0

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