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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libm/] [math/] [wf_log.c] - Blame information for rev 1775

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

Line No. Rev Author Line
1 39 lampret
/* 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_ || isnanf(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 56 joel
        exc.err = 0;
45
        exc.arg1 = exc.arg2 = (double)x;
46 39 lampret
        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 = EDOM;
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
        }
67
        if (exc.err != 0)
68
           errno = exc.err;
69
        return (float)exc.retval;
70
#endif
71
}
72
 
73
#ifdef _DOUBLE_IS_32BITS
74
 
75
#ifdef __STDC__
76
        double log(double x)
77
#else
78
        double log(x)
79
        double x;
80
#endif
81
{
82
        return (double) logf((float) x);
83
}
84
 
85
#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.