diff --git a/liba/Makefile b/liba/Makefile index 074eff25e..bbe4e26f3 100644 --- a/liba/Makefile +++ b/liba/Makefile @@ -53,13 +53,16 @@ objs += $(addprefix liba/src/external/openbsd/, \ s_expm1f.o\ s_fabsf.o \ s_floorf.o \ + s_frexpf.o \ s_log1pf.o \ + s_modff.o \ s_roundf.o \ s_scalbnf.o \ s_signgam.o \ s_sinf.o \ s_tanf.o \ s_tanhf.o \ + s_truncf.o \ w_lgammaf.o \ ) diff --git a/liba/include/math.h b/liba/include/math.h index 6d20e74e6..7c1bd7d32 100644 --- a/liba/include/math.h +++ b/liba/include/math.h @@ -57,11 +57,14 @@ float expm1f(float x); float fabsf(float x); float floorf(float x); float fmodf(float x, float y); +float frexpf(float x, int *eptr); +float ldexpf(float x, int n); float lgammaf(float x); float lgammaf_r(float x, int *signgamp); float log1pf(float x); float log10f(float x); float logf(float x); +float modff(float value, float *iptr); float nanf(const char *s); float nearbyintf(float x); float powf(float x, float y); @@ -72,6 +75,7 @@ float sinhf(float x); float sqrtf(float x); float tanf(float x); float tanhf(float x); +float truncf(float x); double acos(double x); double acosh(double x); @@ -121,7 +125,9 @@ double tanh(double x); #define expm1f(x) __builtin_expm1f(x) #define fabsf(x) __builtin_fabsf(x) #define floorf(x) __builtin_floorf(x) +#define frexpf(x, y) __builtin_frexpf(x, y) #define fmodf(x, y) __builtin_fmodf(x, y) +#define ldexpf(x, n) __builtin_ldexpf(x, n) #define lgammaf(x) __builtin_lgammaf(x) #define lgammaf_r(x, signgamp) __builtin_lgammaf_r(x, signgamp) #define log1pf(x) __builtin_log1pf(x) @@ -137,6 +143,7 @@ double tanh(double x); #define sqrtf(x) __builtin_sqrtf(x) #define tanf(x) __builtin_tanf(x) #define tanhf(x) __builtin_tanhf(x) +#define truncf(x) __builtin_truncf(x) #define acos(x) __builtin_acos(x) #define acosh(x) __builtin_acosh(x) diff --git a/liba/src/external/openbsd/s_frexpf.c b/liba/src/external/openbsd/s_frexpf.c new file mode 100644 index 000000000..74cf5f3d9 --- /dev/null +++ b/liba/src/external/openbsd/s_frexpf.c @@ -0,0 +1,40 @@ +/* s_frexpf.c -- float version of s_frexp.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.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. + * ==================================================== + */ + +#include "math.h" +#include "math_private.h" + +static const float +two25 = 3.3554432000e+07; /* 0x4c000000 */ + +float +frexpf(float x, int *eptr) +{ + int32_t hx,ix; + GET_FLOAT_WORD(hx,x); + ix = 0x7fffffff&hx; + *eptr = 0; + if(ix>=0x7f800000||(ix==0)) return x; /* 0,inf,nan */ + if (ix<0x00800000) { /* subnormal */ + x *= two25; + GET_FLOAT_WORD(hx,x); + ix = hx&0x7fffffff; + *eptr = -25; + } + *eptr += (ix>>23)-126; + hx = (hx&0x807fffff)|0x3f000000; + SET_FLOAT_WORD(x,hx); + return x; +} diff --git a/liba/src/external/openbsd/s_modff.c b/liba/src/external/openbsd/s_modff.c new file mode 100644 index 000000000..829bfce7c --- /dev/null +++ b/liba/src/external/openbsd/s_modff.c @@ -0,0 +1,52 @@ +/* s_modff.c -- float version of s_modf.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.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. + * ==================================================== + */ + +#include "math.h" +#include "math_private.h" + +static const float one = 1.0; + +float +modff(float x, float *iptr) +{ + int32_t i0,jj0; + u_int32_t i; + GET_FLOAT_WORD(i0,x); + jj0 = ((i0>>23)&0xff)-0x7f; /* exponent of x */ + if(jj0<23) { /* integer part in x */ + if(jj0<0) { /* |x|<1 */ + SET_FLOAT_WORD(*iptr,i0&0x80000000); /* *iptr = +-0 */ + return x; + } else { + i = (0x007fffff)>>jj0; + if((i0&i)==0) { /* x is integral */ + u_int32_t ix; + *iptr = x; + GET_FLOAT_WORD(ix,x); + SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */ + return x; + } else { + SET_FLOAT_WORD(*iptr,i0&(~i)); + return x - *iptr; + } + } + } else { /* no fraction part */ + u_int32_t ix; + *iptr = x*one; + GET_FLOAT_WORD(ix,x); + SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */ + return x; + } +} diff --git a/liba/src/external/openbsd/s_truncf.c b/liba/src/external/openbsd/s_truncf.c new file mode 100644 index 000000000..40cdcd93b --- /dev/null +++ b/liba/src/external/openbsd/s_truncf.c @@ -0,0 +1,50 @@ +/* @(#)s_floor.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. + * ==================================================== + */ + +/* + * truncf(x) + * Return x rounded toward 0 to integral value + * Method: + * Bit twiddling. + * Exception: + * Inexact flag raised if x not equal to truncf(x). + */ + +#include "math.h" +#include "math_private.h" + +static const float huge = 1.0e30F; + +float +truncf(float x) +{ + int32_t i0,jj0; + u_int32_t i; + GET_FLOAT_WORD(i0,x); + jj0 = ((i0>>23)&0xff)-0x7f; + if(jj0<23) { + if(jj0<0) { /* raise inexact if x != 0 */ + if(huge+x>0.0F) /* |x|<1, so return 0*sign(x) */ + i0 &= 0x80000000; + } else { + i = (0x007fffff)>>jj0; + if((i0&i)==0) return x; /* x is integral */ + if(huge+x>0.0F) /* raise inexact flag */ + i0 &= (~i); + } + } else { + if(jj0==0x80) return x+x; /* inf or NaN */ + else return x; /* x is integral */ + } + SET_FLOAT_WORD(x,i0); + return x; +}