Add logbl(3) to libm.
This commit is contained in:
parent
c5f411515c
commit
6821aba9e5
@ -78,8 +78,8 @@ SYMBOL_MAPS= ${SYM_MAPS}
|
|||||||
COMMON_SRCS+= s_copysignl.c s_fabsl.c s_modfl.c
|
COMMON_SRCS+= s_copysignl.c s_fabsl.c s_modfl.c
|
||||||
.if ${LDBL_PREC} != 53
|
.if ${LDBL_PREC} != 53
|
||||||
# If long double != double use these; otherwise, we alias the double versions.
|
# If long double != double use these; otherwise, we alias the double versions.
|
||||||
COMMON_SRCS+= s_fmal.c s_frexpl.c s_nanl.c s_nextafterl.c s_nexttoward.c \
|
COMMON_SRCS+= s_fmal.c s_frexpl.c s_logbl.c s_nanl.c \
|
||||||
s_scalbnl.c
|
s_nextafterl.c s_nexttoward.c s_scalbnl.c
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
# C99 complex functions
|
# C99 complex functions
|
||||||
@ -146,7 +146,7 @@ MLINKS+=hypot.3 cabs.3 hypot.3 cabsf.3 hypot.3 hypotf.3
|
|||||||
MLINKS+=ieee_test.3 scalb.3 ieee_test.3 scalbf.3
|
MLINKS+=ieee_test.3 scalb.3 ieee_test.3 scalbf.3
|
||||||
MLINKS+=ieee_test.3 significand.3 ieee_test.3 significandf.3
|
MLINKS+=ieee_test.3 significand.3 ieee_test.3 significandf.3
|
||||||
MLINKS+=ilogb.3 ilogbf.3 ilogb.3 ilogbl.3 \
|
MLINKS+=ilogb.3 ilogbf.3 ilogb.3 ilogbl.3 \
|
||||||
ilogb.3 logb.3 ilogb.3 logbf.3
|
ilogb.3 logb.3 ilogb.3 logbf.3 ilogb.3 logbl.3
|
||||||
MLINKS+=j0.3 j1.3 j0.3 jn.3 j0.3 y0.3 j0.3 y1.3 j0.3 y1f.3 j0.3 yn.3
|
MLINKS+=j0.3 j1.3 j0.3 jn.3 j0.3 y0.3 j0.3 y1.3 j0.3 y1f.3 j0.3 yn.3
|
||||||
MLINKS+=j0.3 j0f.3 j0.3 j1f.3 j0.3 jnf.3 j0.3 y0f.3 j0.3 ynf.3
|
MLINKS+=j0.3 j0f.3 j0.3 j1f.3 j0.3 jnf.3 j0.3 y0f.3 j0.3 ynf.3
|
||||||
MLINKS+=lgamma.3 gamma.3 lgamma.3 gammaf.3 lgamma.3 lgammaf.3 lgamma.3 tgamma.3
|
MLINKS+=lgamma.3 gamma.3 lgamma.3 gammaf.3 lgamma.3 lgammaf.3 lgamma.3 tgamma.3
|
||||||
|
@ -190,6 +190,7 @@ FBSD_1.1 {
|
|||||||
cargf;
|
cargf;
|
||||||
csqrt;
|
csqrt;
|
||||||
csqrtf;
|
csqrtf;
|
||||||
|
logbl;
|
||||||
nan;
|
nan;
|
||||||
nanf;
|
nanf;
|
||||||
nanl;
|
nanl;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# $FreeBSD$
|
# $FreeBSD$
|
||||||
|
|
||||||
ARCH_SRCS = e_sqrt.S e_sqrtf.S s_llrint.S s_llrintf.S s_lrint.S s_lrintf.S \
|
ARCH_SRCS = e_sqrt.S e_sqrtf.S s_llrint.S s_llrintf.S \
|
||||||
|
s_logbl.S s_lrint.S s_lrintf.S \
|
||||||
s_remquo.S s_remquof.S s_scalbn.S s_scalbnf.S s_scalbnl.S
|
s_remquo.S s_remquof.S s_scalbn.S s_scalbnf.S s_scalbnl.S
|
||||||
LDBL_PREC = 64
|
LDBL_PREC = 64
|
||||||
SYM_MAPS += ${.CURDIR}/amd64/Symbol.map
|
SYM_MAPS += ${.CURDIR}/amd64/Symbol.map
|
||||||
|
44
lib/msun/amd64/s_logbl.S
Normal file
44
lib/msun/amd64/s_logbl.S
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1993,94 Winning Strategies, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Winning Strategies, Inc.
|
||||||
|
* 4. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Written by:
|
||||||
|
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <machine/asm.h>
|
||||||
|
|
||||||
|
RCSID("$FreeBSD$")
|
||||||
|
|
||||||
|
ENTRY(logbl)
|
||||||
|
fldt 4(%esp)
|
||||||
|
fxtract
|
||||||
|
fstp %st
|
||||||
|
ret
|
@ -13,7 +13,7 @@ ARCH_SRCS+= e_log10f.S e_logf.S e_remainderf.S \
|
|||||||
s_remquof.S s_rintf.S s_scalbnf.S s_significandf.S s_truncf.S
|
s_remquof.S s_rintf.S s_scalbnf.S s_significandf.S s_truncf.S
|
||||||
|
|
||||||
# long double counterparts
|
# long double counterparts
|
||||||
ARCH_SRCS+= s_ceill.S s_copysignl.S s_floorl.S s_scalbnl.S s_truncl.S
|
ARCH_SRCS+= s_ceill.S s_copysignl.S s_floorl.S s_logbl.S s_scalbnl.S s_truncl.S
|
||||||
|
|
||||||
LDBL_PREC = 64 # XXX 64-bit format, but truncated to 53 bits
|
LDBL_PREC = 64 # XXX 64-bit format, but truncated to 53 bits
|
||||||
SYM_MAPS += ${.CURDIR}/i387/Symbol.map
|
SYM_MAPS += ${.CURDIR}/i387/Symbol.map
|
||||||
|
44
lib/msun/i387/s_logbl.S
Normal file
44
lib/msun/i387/s_logbl.S
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1993,94 Winning Strategies, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by Winning Strategies, Inc.
|
||||||
|
* 4. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Written by:
|
||||||
|
* J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <machine/asm.h>
|
||||||
|
|
||||||
|
RCSID("$FreeBSD$")
|
||||||
|
|
||||||
|
ENTRY(logbl)
|
||||||
|
fldt 4(%esp)
|
||||||
|
fxtract
|
||||||
|
fstp %st
|
||||||
|
ret
|
@ -28,7 +28,7 @@
|
|||||||
.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91
|
.\" from: @(#)ieee.3 6.4 (Berkeley) 5/6/91
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd November 6, 2005
|
.Dd December 16, 2007
|
||||||
.Dt ILOGB 3
|
.Dt ILOGB 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -36,7 +36,8 @@
|
|||||||
.Nm ilogbf ,
|
.Nm ilogbf ,
|
||||||
.Nm ilogbl ,
|
.Nm ilogbl ,
|
||||||
.Nm logb ,
|
.Nm logb ,
|
||||||
.Nm logbf
|
.Nm logbf ,
|
||||||
|
.Nm logbl
|
||||||
.Nd extract exponent
|
.Nd extract exponent
|
||||||
.Sh LIBRARY
|
.Sh LIBRARY
|
||||||
.Lb libm
|
.Lb libm
|
||||||
@ -52,6 +53,8 @@
|
|||||||
.Fn logb "double x"
|
.Fn logb "double x"
|
||||||
.Ft float
|
.Ft float
|
||||||
.Fn logbf "float x"
|
.Fn logbf "float x"
|
||||||
|
.Ft long double
|
||||||
|
.Fn logbl "long double x"
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Fn ilogb ,
|
.Fn ilogb ,
|
||||||
.Fn ilogbf
|
.Fn ilogbf
|
||||||
@ -71,9 +74,10 @@ and
|
|||||||
returns
|
returns
|
||||||
.Dv FP_ILOGB0 .
|
.Dv FP_ILOGB0 .
|
||||||
.Pp
|
.Pp
|
||||||
.Fn logb x
|
.Fn logb x ,
|
||||||
|
.Fn logbf x ,
|
||||||
and
|
and
|
||||||
.Fn logbf x
|
.Fn logbl x
|
||||||
return
|
return
|
||||||
.Fa x Ns 's exponent
|
.Fa x Ns 's exponent
|
||||||
in floating\-point format with the same precision as
|
in floating\-point format with the same precision as
|
||||||
@ -92,32 +96,29 @@ The
|
|||||||
.Fn ilogb ,
|
.Fn ilogb ,
|
||||||
.Fn ilogbf ,
|
.Fn ilogbf ,
|
||||||
.Fn ilogbl ,
|
.Fn ilogbl ,
|
||||||
.Fn logb
|
.Fn logb ,
|
||||||
|
.Fn logbf ,
|
||||||
and
|
and
|
||||||
.Fn logbf
|
.Fn logbl
|
||||||
routines conform to
|
routines conform to
|
||||||
.St -isoC-99 .
|
.St -isoC-99 .
|
||||||
.Fn logb
|
The latter three
|
||||||
and
|
|
||||||
.Fn logbf
|
|
||||||
implement the logb function recommended by
|
implement the logb function recommended by
|
||||||
.St -ieee754 .
|
.St -ieee754 .
|
||||||
.Sh HISTORY
|
.Sh HISTORY
|
||||||
The
|
.Bl -tag -width "Function " -compact
|
||||||
.Fn logb
|
.It Em Function
|
||||||
function appeared in
|
.Em "First Appeared In"
|
||||||
.Bx 4.3 .
|
.It Fn logb
|
||||||
The
|
.Bx 4.3
|
||||||
.Fn ilogb
|
.It Fn ilogb
|
||||||
function appeared in
|
.Fx 1.1.5
|
||||||
.Fx 1.1.5 .
|
.It Fn ilogbf
|
||||||
The
|
.Fx 2.0
|
||||||
.Fn ilogbf
|
.It Fn logbf
|
||||||
and
|
.Fx 2.0
|
||||||
.Fn logbf
|
.It Fn ilogbl
|
||||||
functions appeared in
|
.Fx 5.4
|
||||||
.Fx 2.0 .
|
.It Fn logbl
|
||||||
The
|
.Fx 8.0
|
||||||
.Fn ilogbl
|
.El
|
||||||
function appeared in
|
|
||||||
.Fx 5.4 .
|
|
||||||
|
@ -20,6 +20,8 @@ static char rcsid[] = "$FreeBSD$";
|
|||||||
* Use ilogb instead.
|
* Use ilogb instead.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <float.h>
|
||||||
|
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
#include "math_private.h"
|
#include "math_private.h"
|
||||||
|
|
||||||
@ -42,3 +44,7 @@ logb(double x)
|
|||||||
} else
|
} else
|
||||||
return (double) ((ix>>20)-1023);
|
return (double) ((ix>>20)-1023);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (LDBL_MANT_DIG == 53)
|
||||||
|
__weak_reference(logb, logbl);
|
||||||
|
#endif
|
||||||
|
55
lib/msun/src/s_logbl.c
Normal file
55
lib/msun/src/s_logbl.c
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* From: @(#)s_ilogb.c 5.1 93/09/24
|
||||||
|
* ====================================================
|
||||||
|
* 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.
|
||||||
|
* ====================================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef lint
|
||||||
|
static char rcsid[] = "$FreeBSD$";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <float.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "fpmath.h"
|
||||||
|
|
||||||
|
long double
|
||||||
|
logbl(long double x)
|
||||||
|
{
|
||||||
|
union IEEEl2bits u;
|
||||||
|
unsigned long m;
|
||||||
|
int b;
|
||||||
|
|
||||||
|
u.e = x;
|
||||||
|
if (u.bits.exp == 0) {
|
||||||
|
if ((u.bits.manl | u.bits.manh) == 0) { /* x == 0 */
|
||||||
|
u.bits.sign = 1;
|
||||||
|
return (1.0L / u.e);
|
||||||
|
}
|
||||||
|
/* denormalized */
|
||||||
|
if (u.bits.manh == 0) {
|
||||||
|
m = 1lu << (LDBL_MANL_SIZE - 1);
|
||||||
|
for (b = LDBL_MANH_SIZE; !(u.bits.manl & m); m >>= 1)
|
||||||
|
b++;
|
||||||
|
} else {
|
||||||
|
m = 1lu << (LDBL_MANH_SIZE - 1);
|
||||||
|
for (b = 0; !(u.bits.manh & m); m >>= 1)
|
||||||
|
b++;
|
||||||
|
}
|
||||||
|
#ifdef LDBL_IMPLICIT_NBIT
|
||||||
|
b++;
|
||||||
|
#endif
|
||||||
|
return ((long double)(LDBL_MIN_EXP - b - 1));
|
||||||
|
}
|
||||||
|
if (u.bits.exp < (LDBL_MAX_EXP << 1) - 1) /* normal */
|
||||||
|
return ((long double)(u.bits.exp - LDBL_MAX_EXP + 1));
|
||||||
|
else /* +/- inf or nan */
|
||||||
|
return (x * x);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user