Mail Archives: djgpp/2015/07/19/04:18:53
On 07/18/2015 08:16 PM, cvs-juan DOT guerrero AT delorie DOT com wrote:
> Update by cvs id: juan.guerrero
> Update of /cvs/djgpp/djgpp/src/libm/math
>
> Added Files:
> Tag: v2_05_1
> wf_log2.c
> Log Message:
> Wrapper function for log2f.
Did You tried to compile it:
Konsole output
[andris AT ap include]$ grep -r log2 *
libm/math.h:extern double log2 __P((double));
libm/math.h:#define log2f(x) (logf (x) / (float) M_LOG2_E)
math.h:double log2(double _x);
math.h:extern float log2f(float);
As result:
> ===================================================================
> RCS file: /cvs/djgpp/djgpp/src/libm/math/wf_log2.c,v
> retrieving revision 1.1.2.2
> diff -p -2 /dev/null -r1.1.2.2
> --- /dev/null 2015-07-02 13:23:02.739999979 -0400
> +++ notify.23223 2015-07-18 13:16:29.811861406 -0400
> @@ -0,0 +1,64 @@
> +/* wf_log2.c -- float version of w_log2.c.
> + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian AT cygnus DOT com.
> + */
> +
> +/*
> + * ====================================================
> + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
> + *
> + * Developed at SunPro, a Sun Microsystems, Inc. business.
> + * Permission to use, copy, modify, and distribute this
> + * software is freely granted, provided that this notice
> + * is preserved.
> + * ====================================================
> + */
> +
> +/*
> + * wrapper log2f(X)
> + */
> +
> +#include "fdlibm.h"
> +#include <libc/ieee.h>
> +
> +#ifdef __STDC__
> + float log2f(float x) /* wrapper log2f */
> +#else
> + float log2f(x) /* wrapper log2f */
> + float x;
> +#endif
> +{
> +#ifdef _IEEE_LIBM
> + return __ieee754_log2f(x);
> +#else
> + _float_long_union ux;
> + float z;
> +
> + ux.f = x;
> +
> + z = __ieee754_log2f(x);
> + if(_LIB_VERSION == _IEEE_ || isnanf(ux.l)) return z;
> + if(x<=(float)0.0) {
> + if(x==(float)0.0)
> + /* log2(0) */
> + return (float)__kernel_standard((double)x,(double)x,127);
> + else
> + /* log2(x<0) */
> + return (float)__kernel_standard((double)x,(double)x,128);
> + } else
> + return z;
> +#endif
> +}
> +
> +#ifdef _DOUBLE_IS_32BITS
> +
> +#ifdef __STDC__
> + double log2(double x)
> +#else
> + double log2(x)
> + double x;
> +#endif
> +{
> + return (double) log2f((float) x);
> +}
> +
> +#endif /* defined(_DOUBLE_IS_32BITS) */
>
>
- Raw text -