source: trunk/libs/newlib/src/newlib/libm/math/wf_log.c @ 471

Last change on this file since 471 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.8 KB
Line 
1/* 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#if __OBSOLETE_MATH
22#include <errno.h>
23
24#ifdef __STDC__
25        float logf(float x)             /* wrapper logf */
26#else
27        float logf(x)                   /* wrapper logf */
28        float x;
29#endif
30{
31#ifdef _IEEE_LIBM
32        return __ieee754_logf(x);
33#else
34        float z;
35        struct exception exc;
36        z = __ieee754_logf(x);
37        if(_LIB_VERSION == _IEEE_ || isnan(x) || x > (float)0.0) return z;
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 = "logf";
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(x==(float)0.0) {
52            /* logf(0) */
53            exc.type = SING;
54            if (_LIB_VERSION == _POSIX_)
55               errno = ERANGE;
56            else if (!matherr(&exc)) {
57               errno = ERANGE;
58            }
59        } else { 
60            /* logf(x<0) */
61            exc.type = DOMAIN;
62            if (_LIB_VERSION == _POSIX_)
63               errno = EDOM;
64            else if (!matherr(&exc)) {
65               errno = EDOM;
66            }
67            exc.retval = nan("");
68        }
69        if (exc.err != 0)
70           errno = exc.err;
71        return (float)exc.retval; 
72#endif
73}
74
75#ifdef _DOUBLE_IS_32BITS
76
77#ifdef __STDC__
78        double log(double x)
79#else
80        double log(x)
81        double x;
82#endif
83{
84        return (double) logf((float) x);
85}
86
87#endif /* defined(_DOUBLE_IS_32BITS) */
88#endif /* __OBSOLETE_MATH */
Note: See TracBrowser for help on using the repository browser.