├── manifests └── bin ├── tests ├── .gitignore ├── README.txt ├── isfini.c ├── erf.c ├── issign.c ├── isinf.c ├── isnan.c ├── finite.c ├── isnorm.c ├── fneg.c ├── fpclass.c ├── nextaf.c ├── csign.c └── signb.c ├── .gitignore ├── s_signgam.c ├── include ├── asm │ └── ieee754 │ │ ├── m68k_ahcc.h │ │ └── m68k_pc.h ├── bits │ ├── fenvinline.h │ ├── fpu_control.h │ ├── inf.h │ ├── fenv.h │ ├── nan.h │ └── mathdef.h └── fpu_control.h ├── s_fminf.c ├── s_fmaxf.c ├── s_isnanf.c ├── s_fmaxl.c ├── s_fminl.c ├── s_copysignf.c ├── s_finitef.c ├── README.md ├── .travis ├── script.sh └── install.sh ├── s_significandf.c ├── s_copysignl.c ├── .master ├── s_significandl.c ├── .scripts ├── build.sh ├── install-hcp.sh ├── install-freemint.sh ├── setup_env.sh ├── install_ssh_id.sh └── deploy.sh ├── s_isnanl.c ├── Product-Info ├── s_ldexpf.c ├── s_isinff.c ├── s_ldexpl.c ├── s_matherr.c ├── s_isinfl.c ├── e_lgamma.c ├── e_lgammaf.c ├── e_lgammal.c ├── s_fpclassifyf.c ├── w_gammaf.c ├── w_lgammaf.c ├── s_isinf.c ├── configure.in ├── s_fabsf.c ├── w_gammal.c ├── w_lgammal.c ├── s_sincos.c ├── e_acosl.c ├── s_frexpf.c ├── s_fpclassifyl.c ├── s_truncf.c ├── s_lib_version.c ├── w_gamma.c ├── s_frexpl.c ├── s_nearbyintf.c ├── s_fpclassify.c ├── s_issigf.c ├── e_exp10f.c ├── s_finitel.c ├── w_lgamma.c ├── s_finite.c ├── s_fabsl.c ├── s_issigl.c ├── e_exp10l.c ├── s_isnan.c ├── w_gammaf_r.c ├── w_lgammaf_r.c ├── s_ldexp.c ├── s_fabs.c ├── w_gammal_r.c ├── s_copysign.c ├── s_truncl.c ├── w_lgammal_r.c ├── s_roundf.c ├── s_logbf.c ├── fpu_ctrl.c ├── s_trunc.c ├── s_nearbyint.c ├── w_gamma_r.c ├── w_lgamma_r.c ├── s_significand.c ├── .github └── workflows │ └── build.yml ├── fegetround.c ├── s_nearbyintl.c ├── s_ceilf.c ├── e_exp10.c ├── s_floorf.c ├── fegetexcept.c ├── s_fdimf.c ├── fetestexcept.c ├── s_fdiml.c ├── s_issig.c ├── fegetexceptflag.c ├── s_fmax.c ├── s_fmin.c ├── w_tgammaf.c ├── feenableexcept.c ├── fedisableexcept.c ├── s_fdim.c ├── s_tanf.c ├── fegetenv.c ├── s_logb.c ├── feclearexcept.c ├── e_fmodl.c ├── s_sincosf.c ├── s_logbl.c ├── feholdexcept.c ├── w_tgammal.c ├── truncxfdf2.c ├── fesetexceptflag.c ├── k_sinf.c ├── e_ilogbf.c ├── w_tgamma.c ├── s_cosf.c ├── s_sinf.c ├── feupdateenv.c ├── s_scalblnf.c ├── s_scalblnl.c ├── s_sincosl.c ├── e_expl.c ├── s_rintf.c ├── fpu_ctrl.h ├── k_cosf.c ├── s_frexp.c ├── s_tanhf.c ├── e_acoshf.c ├── s_asinhf.c ├── e_log2l.c ├── s_roundl.c ├── s_scalbln.c ├── e_sqrtl.c ├── s_scalbnf.c ├── s_modff.c ├── s_llroundf.c ├── s_scalbnl.c ├── s_lroundf.c ├── e_ilogb.c ├── e_exp2l.c ├── s_ceill.c ├── e_ilogbl.c ├── s_nextafterf.c ├── e_sqrtf.c ├── e_sinhf.c ├── s_cbrtf.c ├── s_floorl.c ├── e_remainderf.c └── fesetenv.c /manifests/bin: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/.gitignore: -------------------------------------------------------------------------------- 1 | runall.h 2 | runall.sh 3 | runv4e.sh 4 | runall.mup 5 | config.h 6 | .dirstamp 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 5475.hard-float 2 | 68000.soft-float 3 | 68020-60.68881 4 | config.cache 5 | config.log 6 | config.status 7 | Makefile 8 | *~ 9 | *.ttp 10 | *.log 11 | -------------------------------------------------------------------------------- /s_signgam.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | int signgam = 0; 6 | 7 | int *__signgam (void) 8 | { 9 | return &signgam; 10 | } 11 | -------------------------------------------------------------------------------- /include/asm/ieee754/m68k_ahcc.h: -------------------------------------------------------------------------------- 1 | #if defined(__AHCC__) && defined(__HAVE_68881__) 2 | 3 | #ifndef __NO_MATH_INLINES 4 | 5 | #endif /* __NO_MATH_INLINES */ 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /include/bits/fenvinline.h: -------------------------------------------------------------------------------- 1 | /* This file provides inline versions of floating-point environment 2 | handling functions. If there were any. */ 3 | 4 | #ifndef __NO_MATH_INLINES 5 | 6 | /* Here is where the code would go. */ 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /s_fminf.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | float __fminf(float x, float y) 6 | { 7 | return (islessequal (x, y) || isnan (y)) ? x : y; 8 | } 9 | 10 | __typeof(__fminf) fminf __attribute__((weak, alias("__fminf"))); 11 | -------------------------------------------------------------------------------- /s_fmaxf.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | float __fmaxf(float x, float y) 6 | { 7 | return (isgreaterequal (x, y) || isnan (y)) ? x : y; 8 | } 9 | 10 | __typeof(__fmaxf) fmaxf __attribute__((weak, alias("__fmaxf"))); 11 | -------------------------------------------------------------------------------- /include/asm/ieee754/m68k_pc.h: -------------------------------------------------------------------------------- 1 | # define math_opt_barrier(x) (x) 2 | # define math_force_eval(x) (void)(x) 3 | 4 | #if defined(__PUREC__) 5 | 6 | #if defined(__HAVE_68881__) 7 | 8 | #ifndef __NO_MATH_INLINES 9 | 10 | 11 | #endif /* __NO_MATH_INLINES */ 12 | 13 | #endif 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /s_isnanf.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | int __isnanf(float x) 6 | { 7 | int32_t ix; 8 | 9 | GET_FLOAT_WORD(ix, x); 10 | ix &= IC(0x7fffffff); 11 | return ix > IC(0x7f800000); 12 | } 13 | 14 | __typeof(__isnanf) isnanf __attribute__((weak, alias("__isnanf"))); 15 | -------------------------------------------------------------------------------- /s_fmaxl.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __NO_LONG_DOUBLE_MATH 6 | 7 | long double __fmaxl(long double x, long double y) 8 | { 9 | return (isgreaterequal (x, y) || isnan (y)) ? x : y; 10 | } 11 | 12 | __typeof(__fmaxl) fmaxl __attribute__((weak, alias("__fmaxl"))); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /s_fminl.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __NO_LONG_DOUBLE_MATH 6 | 7 | long double __fminl(long double x, long double y) 8 | { 9 | return (islessequal (x, y) || isnan (y)) ? x : y; 10 | } 11 | 12 | __typeof(__fminl) fminl __attribute__((weak, alias("__fminl"))); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /s_copysignf.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | float __copysignf(float x, float y) 6 | { 7 | uint32_t ix, iy; 8 | 9 | GET_FLOAT_WORD(ix, x); 10 | GET_FLOAT_WORD(iy, y); 11 | SET_FLOAT_WORD(x, (ix & UC(0x7fffffff)) | (iy & UC(0x80000000))); 12 | return x; 13 | } 14 | 15 | __typeof(__copysignf) copysignf __attribute__((weak, alias("__copysignf"))); 16 | -------------------------------------------------------------------------------- /s_finitef.c: -------------------------------------------------------------------------------- 1 | /* 2 | * finitef(x) returns 1 is x is finite, else 0; 3 | * no branching! 4 | */ 5 | 6 | #ifndef __FDLIBM_H__ 7 | #include "fdlibm.h" 8 | #endif 9 | 10 | int __finitef(float x) 11 | { 12 | uint32_t ix; 13 | 14 | GET_FLOAT_WORD(ix, x); 15 | return (ix & UC(0x7fffffff)) < UC(0x7f800000); 16 | } 17 | 18 | __typeof(__finitef) finitef __attribute__((weak, alias("__finitef"))); 19 | -------------------------------------------------------------------------------- /include/bits/fpu_control.h: -------------------------------------------------------------------------------- 1 | #ifndef _FPU_CONTROL_H 2 | # error "Never use directly; include instead." 3 | #endif 4 | 5 | #ifdef __mc68000__ 6 | #include 7 | #endif 8 | 9 | #if defined(__i386__) || defined(__x86_64__) 10 | #include 11 | #endif 12 | 13 | #ifndef _FPU_GETCW 14 | #error " not supported" 15 | #endif 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://github.com/freemint/fdlibm/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/freemint/fdlibm/actions) 2 | 3 | * Latest snapshot: [Download (mint)](https://tho-otto.de/snapshots/fdlibm/fdlibm-mint-latest.tar.bz2) 4 | * Latest snapshot: [Download (mintelf)](https://tho-otto.de/snapshots/fdlibm/fdlibm-mintelf-latest.tar.bz2) 5 | * [Archive](https://tho-otto.de/snapshots/fdlibm/) 6 | -------------------------------------------------------------------------------- /.travis/script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | # -e: Exit immediately if a command exits with a non-zero status. 3 | # -u: Treat unset variables as an error when substituting. 4 | # -x: Display expanded script commands 5 | 6 | unset CC 7 | ./configure --host=m68k-atari-mint 8 | make 9 | make prefix="${INSTALL_DIR}" install 10 | 11 | find "${INSTALL_DIR}" -type f \( -name '*.a' -o -name '*.o' \) -exec m68k-atari-mint-strip -S -X -w -N '.L[0-9]*' {} \; 12 | -------------------------------------------------------------------------------- /s_significandf.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | float __significandf(float x) 6 | { 7 | uint32_t hx, ix; 8 | 9 | GET_FLOAT_WORD(hx, x); 10 | ix = hx & UC(0x7f800000); 11 | if (ix != 0 && ix != UC(0x7f800000)) 12 | { 13 | SET_FLOAT_WORD(x, (hx & UC(0x807fffff)) | UC(0x3f800000)); 14 | } 15 | return x; 16 | } 17 | 18 | __typeof(__significandf) significandf __attribute__((weak, alias("__significandf"))); 19 | -------------------------------------------------------------------------------- /s_copysignl.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __NO_LONG_DOUBLE_MATH 6 | 7 | long double __copysignl(long double x, long double y) 8 | { 9 | uint32_t es1, es2; 10 | GET_LDOUBLE_EXP(es1, x); 11 | GET_LDOUBLE_EXP(es2, y); 12 | SET_LDOUBLE_EXP(x, (es1 & 0x7fff) | (es2 & 0x8000)); 13 | return x; 14 | } 15 | 16 | __typeof(__copysignl) copysignl __attribute__((weak, alias("__copysignl"))); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /.master: -------------------------------------------------------------------------------- 1 | lib fdlibm 2 | for C math library for machines that support IEEE 754 floating-point 3 | by Kwok C Ng 4 | # Version: 5.1 5 | # Maintained-hy: fdlibm-comments@sunpro.eng.sun.com 6 | # Maintained-at: sunsite.unc.edu 7 | # Platforms: Require ANSI C compiler with IEEE 754 style arithmetic 8 | # Copying-Policy: Freely Redistributable 9 | # Keywords: libm,exp,log,sin,cos,floating-point,IEEE754 10 | master netlib.bell-labs.com 11 | 12 | -------------------------------------------------------------------------------- /s_significandl.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __NO_LONG_DOUBLE_MATH 6 | 7 | long double __significandl(long double x) 8 | { 9 | uint32_t exp, ix; 10 | 11 | GET_LDOUBLE_EXP(exp, x); 12 | ix = exp & 0x7fff; 13 | if (ix != 0 && ix != 0x7fff) 14 | SET_LDOUBLE_EXP(x, (exp & 0x8000) | 0x3fff); 15 | return x; 16 | } 17 | 18 | __typeof(__significandl) significandl __attribute__((weak, alias("__significandl"))); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /.scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | # -e: Exit immediately if a command exits with a non-zero status. 3 | # -u: Treat unset variables as an error when substituting. 4 | # -x: Display expanded script commands 5 | 6 | unset CC 7 | if ./configure --prefix=/usr --host=${CROSS_TOOL}; then :; else cat config.log; exit 1; fi 8 | make 9 | make DESTDIR="${INSTALL_DIR}" install 10 | 11 | find "${INSTALL_DIR}" -type f \( -name '*.a' -o -name '*.o' \) -exec ${CROSS_TOOL}-strip -S -X -w -N '.L[0-9]*' {} \; 12 | -------------------------------------------------------------------------------- /s_isnanl.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __NO_LONG_DOUBLE_MATH 6 | 7 | int __isnanl(long double x) 8 | { 9 | int32_t se, hx, lx; 10 | 11 | GET_LDOUBLE_WORDS(se, hx, lx, x); 12 | se = (se & 0x7fff) << 1; 13 | lx |= hx & IC(0x7fffffff); 14 | se |= (uint32_t) (lx | (-lx)) >> 31; 15 | se = 0xfffe - se; 16 | return (int) (((uint32_t) (se)) >> 31); 17 | } 18 | 19 | __typeof(__isnanl) isnanl __attribute__((weak, alias("__isnanl"))); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /Product-Info: -------------------------------------------------------------------------------- 1 | .name 2 | fdlibm 3 | .type 4 | library 5 | .short 6 | Redistributable IEEE 754 C math library 7 | .description 8 | FDLIBM (Freely Distributable LIBM) is a C math library 9 | for machines that support IEEE 754 floating-point arithmetic. 10 | In this release, only double precision is supported. 11 | .version 12 | 5.2 13 | .author 14 | SunSoft 15 | .distribution 16 | Freely Distributable 17 | .described-by 18 | Fred Fish (fnf@ninemoons.com) 19 | .submittal 20 | ftp://netlib.bell-labs.com/netlib/fdlibm 21 | -------------------------------------------------------------------------------- /.scripts/install-hcp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | # -e: Exit immediately if a command exits with a non-zero status. 3 | # -u: Treat unset variables as an error when substituting. 4 | # -x: Display expanded script commands 5 | 6 | # HCP is defined as "~/tmp/hcp/bin/hcp" 7 | HCP=~/tmp/hcp/bin/hcp 8 | echo "HCP=$HCP" >> $GITHUB_ENV 9 | 10 | HCP_VERSION="1.0.3" 11 | 12 | mkdir -p ~/tmp 13 | cd ~/tmp 14 | wget -q -O - "http://tho-otto.de/download/hcp-${HCP_VERSION}-linux.tar.bz2" | tar xjf - 15 | mv "hcp-${HCP_VERSION}" hcp 16 | cd - 17 | -------------------------------------------------------------------------------- /s_ldexpf.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __have_fpu_ldexp 6 | 7 | float __ieee754_ldexpf(float value, int exp) 8 | { 9 | if (!isfinite(value) || value == 0.0F) 10 | return value; 11 | return __ieee754_scalbnf(value, exp); 12 | } 13 | 14 | #endif 15 | 16 | float __ldexpf(float x, int n) 17 | { 18 | x = __ieee754_ldexpf(x, n); 19 | if (!isfinite(x) || x == 0.0F) 20 | __set_errno(ERANGE); 21 | return x; 22 | } 23 | 24 | __typeof(__ldexpf) ldexpf __attribute__((weak, alias("__ldexpf"))); 25 | -------------------------------------------------------------------------------- /s_isinff.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by J.T. Conklin . 3 | * Public domain. 4 | */ 5 | 6 | /* 7 | * isinff(x) returns 1 if x is inf, -1 if x is -inf, else 0; 8 | * no branching! 9 | */ 10 | 11 | #ifndef __FDLIBM_H__ 12 | #include "fdlibm.h" 13 | #endif 14 | 15 | int __isinff(float x) 16 | { 17 | int32_t ix, t; 18 | 19 | GET_FLOAT_WORD(ix, x); 20 | t = ix & IC(0x7fffffff); 21 | t ^= IC(0x7f800000); 22 | t |= -t; 23 | return (int)(~(t >> 31) & (ix >> 30)); 24 | } 25 | 26 | __typeof(__isinff) isinff __attribute__((weak, alias("__isinff"))); 27 | -------------------------------------------------------------------------------- /s_ldexpl.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __NO_LONG_DOUBLE_MATH 6 | 7 | #ifndef __have_fpu_ldexp 8 | 9 | long double __ieee754_ldexpl(long double value, int exp) 10 | { 11 | if (!isfinite(value) || value == 0.0) 12 | return value; 13 | return __ieee754_scalbnl(value, exp); 14 | } 15 | 16 | #endif 17 | 18 | long double __ldexpl(long double x, int n) 19 | { 20 | x = __ieee754_ldexpl(x, n); 21 | if (!isfinite(x) || x == 0.0) 22 | __set_errno(ERANGE); 23 | return x; 24 | } 25 | 26 | __typeof(__ldexpl) ldexpl __attribute__((weak, alias("__ldexpl"))); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /s_matherr.c: -------------------------------------------------------------------------------- 1 | 2 | /* @(#)s_matherr.c 1.3 95/01/18 */ 3 | /* 4 | * ==================================================== 5 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 6 | * 7 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 8 | * Permission to use, copy, modify, and distribute this 9 | * software is freely granted, provided that this notice 10 | * is preserved. 11 | * ==================================================== 12 | */ 13 | 14 | #include "fdlibm.h" 15 | 16 | int matherr(struct exception *x) 17 | { 18 | int n=0; 19 | if(x->arg1!=x->arg1) return 0; 20 | return n; 21 | } 22 | -------------------------------------------------------------------------------- /.travis/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | # -e: Exit immediately if a command exits with a non-zero status. 3 | # -u: Treat unset variables as an error when substituting. 4 | # -x: Display expanded script commands 5 | 6 | if [ "${TRAVIS_PULL_REQUEST}" = "false" -a "${TRAVIS_REPO_SLUG}" = "freemint/fdlibm" ] 7 | then 8 | BINTRAY_REPO="travis" SYSROOT_DIR="/" ./.travis/install_bintray.sh m68k-atari-mint-binutils-gdb m68k-atari-mint-gcc mintbin 9 | ./.travis/install_bintray.sh mintlib 10 | else 11 | sudo add-apt-repository -y ppa:vriviere/ppa 12 | sudo apt-get update 13 | sudo apt-get install binutils-m68k-atari-mint gcc-m68k-atari-mint mintbin-m68k-atari-mint mintlib-m68k-atari-mint 14 | fi 15 | -------------------------------------------------------------------------------- /s_isinfl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by J.T. Conklin . 3 | * Change for long double by Jakub Jelinek 4 | * Public domain. 5 | */ 6 | 7 | /* 8 | * isinfl(x) returns 1 if x is inf, -1 if x is -inf, else 0; 9 | * no branching! 10 | */ 11 | 12 | #ifndef __FDLIBM_H__ 13 | #include "fdlibm.h" 14 | #endif 15 | 16 | #ifndef __NO_LONG_DOUBLE_MATH 17 | 18 | int __isinfl(long double x) 19 | { 20 | int32_t se, hx, lx; 21 | 22 | GET_LDOUBLE_WORDS(se, hx, lx, x); 23 | lx |= (hx & IC(0x7fffffff)) | ((se & 0x7fff) ^ 0x7fff); 24 | lx |= -lx; 25 | se &= 0x8000; 26 | return (int)(~(lx >> 31) & (1 - (se >> 14))); 27 | } 28 | 29 | __typeof(__isinfl) isinfl __attribute__((weak, alias("__isinfl"))); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /e_lgamma.c: -------------------------------------------------------------------------------- 1 | /* @(#)e_lgamma.c 1.3 95/01/18 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | * 12 | */ 13 | 14 | /* __ieee754_lgamma(x) 15 | * Return the logarithm of the Gamma function of x. 16 | * 17 | * Method: call __ieee754_lgamma_r 18 | */ 19 | 20 | #include "fdlibm.h" 21 | 22 | double __ieee754_lgamma(double x) 23 | { 24 | return __ieee754_lgamma_r(x, &signgam); 25 | } 26 | -------------------------------------------------------------------------------- /e_lgammaf.c: -------------------------------------------------------------------------------- 1 | /* @(#)e_lgamma.c 1.3 95/01/18 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | * 12 | */ 13 | 14 | /* __ieee754_lgammaf(x) 15 | * Return the logarithm of the Gamma function of x. 16 | * 17 | * Method: call __ieee754_lgammaf_r 18 | */ 19 | 20 | #include "fdlibm.h" 21 | 22 | float __ieee754_lgammaf(float x) 23 | { 24 | return __ieee754_lgammaf_r(x, &signgam); 25 | } 26 | -------------------------------------------------------------------------------- /e_lgammal.c: -------------------------------------------------------------------------------- 1 | /* @(#)e_lgamma.c 1.3 95/01/18 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | * 12 | */ 13 | 14 | /* __ieee754_lgammal(x) 15 | * Return the logarithm of the Gamma function of x. 16 | * 17 | * Method: call __ieee754_lgamma_r 18 | */ 19 | 20 | #include "fdlibm.h" 21 | 22 | long double __ieee754_lgamma(long double x) 23 | { 24 | return __ieee754_lgammal_r(x, &signgam); 25 | } 26 | -------------------------------------------------------------------------------- /s_fpclassifyf.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002, 2007 by Red Hat, Incorporated. All rights reserved. 2 | * 3 | * Permission to use, copy, modify, and distribute this software 4 | * is freely granted, provided that this notice is preserved. 5 | */ 6 | 7 | #ifndef __FDLIBM_H__ 8 | #include "fdlibm.h" 9 | #endif 10 | 11 | int __fpclassifyf(float x) 12 | { 13 | int retval = FP_NORMAL; 14 | uint32_t wx; 15 | 16 | GET_FLOAT_WORD(wx, x); 17 | wx &= UC(0x7fffffff); 18 | if (wx == 0) 19 | retval = FP_ZERO; 20 | else if (wx < UC(0x800000)) 21 | retval = FP_SUBNORMAL; 22 | else if (wx >= UC(0x7f800000)) 23 | retval = wx > UC(0x7f800000) ? FP_NAN : FP_INFINITE; 24 | 25 | return retval; 26 | } 27 | 28 | __typeof(__fpclassifyf) fpclassifyf __attribute__((weak, alias("__fpclassifyf"))); 29 | -------------------------------------------------------------------------------- /w_gammaf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================== 3 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 | * 5 | * Developed at SunPro, a Sun Microsystems, Inc. business. 6 | * Permission to use, copy, modify, and distribute this 7 | * software is freely granted, provided that this notice 8 | * is preserved. 9 | * ==================================================== 10 | * 11 | */ 12 | 13 | /* float gammaf(double x) 14 | * Return the logarithm of the Gamma function of x. 15 | * 16 | * Method: call gammaf_r 17 | */ 18 | 19 | #ifndef __FDLIBM_H__ 20 | #include "fdlibm.h" 21 | #endif 22 | 23 | float __gammaf(float x) 24 | { 25 | return gammaf_r(x, &signgam); 26 | } 27 | 28 | __typeof(__gammaf) gammaf __attribute__((weak, alias("__gammaf"))); 29 | -------------------------------------------------------------------------------- /w_lgammaf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================== 3 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 | * 5 | * Developed at SunPro, a Sun Microsystems, Inc. business. 6 | * Permission to use, copy, modify, and distribute this 7 | * software is freely granted, provided that this notice 8 | * is preserved. 9 | * ==================================================== 10 | * 11 | */ 12 | 13 | /* float lgammaf(double x) 14 | * Return the logarithm of the Gamma function of x. 15 | * 16 | * Method: call lgammaf_r 17 | */ 18 | 19 | #ifndef __FDLIBM_H__ 20 | #include "fdlibm.h" 21 | #endif 22 | 23 | float __lgammaf(float x) 24 | { 25 | return lgammaf_r(x, &signgam); 26 | } 27 | 28 | __typeof(__lgammaf) lgammaf __attribute__((weak, alias("__lgammaf"))); 29 | -------------------------------------------------------------------------------- /s_isinf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by J.T. Conklin . 3 | * Changed to return -1 for -Inf by Ulrich Drepper . 4 | * Public domain. 5 | */ 6 | 7 | /* 8 | * isinf(x) returns 1 is x is inf, -1 if x is -inf, else 0; 9 | * no branching! 10 | */ 11 | 12 | #ifndef __FDLIBM_H__ 13 | #include "fdlibm.h" 14 | #endif 15 | 16 | int __isinf(double x) 17 | { 18 | int32_t hx, lx; 19 | 20 | GET_DOUBLE_WORDS(hx, lx, x); 21 | lx |= (hx & IC(0x7fffffff)) ^ IC(0x7ff00000); 22 | lx |= -lx; 23 | return (int)(~(lx >> 31) & (hx >> 30)); 24 | } 25 | 26 | __typeof(__isinf) isinf __attribute__((weak, alias("__isinf"))); 27 | #ifdef __NO_LONG_DOUBLE_MATH 28 | __typeof(__isinfl) __isinfl __attribute__((alias("__isinf"))); 29 | __typeof(__isinfl) isinfl __attribute__((weak, alias("__isinf"))); 30 | #endif 31 | -------------------------------------------------------------------------------- /.scripts/install-freemint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eux 2 | # -e: Exit immediately if a command exits with a non-zero status. 3 | # -u: Treat unset variables as an error when substituting. 4 | # -x: Display expanded script commands 5 | 6 | DOWNLOAD_DIR=http://tho-otto.de/snapshots 7 | SYSROOT_DIR=${SYSROOT_DIR:-"/usr/${CROSS_TOOL}/sys-root"} 8 | 9 | sudo mkdir -p "${SYSROOT_DIR}" && cd "${SYSROOT_DIR}" 10 | 11 | toolsuffix=${CROSS_TOOL##*-} 12 | 13 | for package in $* 14 | do 15 | # for gcc and binutils, use stable current, not experimental latest build 16 | case $package in 17 | gcc | binutils) 18 | filename=${package}-${toolsuffix}-current.tar.bz2 19 | ;; 20 | *) 21 | filename=${package}-${toolsuffix}-latest.tar.bz2 22 | ;; 23 | esac 24 | wget -q -O - "$DOWNLOAD_DIR/${package}/${filename}" | sudo tar xjf - 25 | done 26 | -------------------------------------------------------------------------------- /configure.in: -------------------------------------------------------------------------------- 1 | dnl Process this file with autoconf to produce a configure script. 2 | AC_INIT(fdlibm, , [freemint-discuss@lists.sourceforge.net], , [https://github.com/freemint/fdlibm]) 3 | AC_PREREQ(2.52) 4 | AC_CONFIG_SRCDIR([include/fdlibm.h]) 5 | AC_CONFIG_AUX_DIR([config-aux]) 6 | 7 | dnl Canonical system information. 8 | AC_CANONICAL_HOST 9 | 10 | dnl Checks for programs. 11 | AC_PROG_CC 12 | AC_PROG_RANLIB 13 | AC_CHECK_TOOL(AR, ar) 14 | if test "$AR" = ""; then AC_MSG_ERROR([ar missing]); fi 15 | 16 | dnl Checks for libraries. 17 | 18 | dnl Checks for header files. 19 | AC_CHECK_HEADERS(unistd.h) 20 | AC_CHECK_LIB(m, cos) 21 | 22 | dnl Checks for typedefs, structures, and compiler characteristics. 23 | AC_C_CONST 24 | 25 | dnl Checks for library functions. 26 | 27 | AC_SUBST(ac_aux_dir) 28 | AC_OUTPUT(Makefile) 29 | -------------------------------------------------------------------------------- /s_fabsf.c: -------------------------------------------------------------------------------- 1 | /* s_fabsf.c -- float version of s_fabs.c. 2 | */ 3 | 4 | /* 5 | * ==================================================== 6 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 7 | * 8 | * Developed at SunPro, a Sun Microsystems, Inc. business. 9 | * Permission to use, copy, modify, and distribute this 10 | * software is freely granted, provided that this notice 11 | * is preserved. 12 | * ==================================================== 13 | */ 14 | 15 | /* 16 | * fabsf(x) returns the absolute value of x. 17 | */ 18 | 19 | #ifndef __FDLIBM_H__ 20 | #include "fdlibm.h" 21 | #endif 22 | 23 | float __fabsf(float x) 24 | { 25 | uint32_t ix; 26 | 27 | GET_FLOAT_WORD(ix, x); 28 | SET_FLOAT_WORD(x, ix & UC(0x7fffffff)); 29 | return x; 30 | } 31 | 32 | __typeof(__fabsf) fabsf __attribute__((weak, alias("__fabsf"))); 33 | -------------------------------------------------------------------------------- /w_gammal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================== 3 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 | * 5 | * Developed at SunPro, a Sun Microsystems, Inc. business. 6 | * Permission to use, copy, modify, and distribute this 7 | * software is freely granted, provided that this notice 8 | * is preserved. 9 | * ==================================================== 10 | * 11 | */ 12 | 13 | /* long double gammal(long double x) 14 | * Return the logarithm of the Gamma function of x. 15 | * 16 | * Method: call gammal_r 17 | */ 18 | 19 | #ifndef __FDLIBM_H__ 20 | #include "fdlibm.h" 21 | #endif 22 | 23 | #ifndef __NO_LONG_DOUBLE_MATH 24 | 25 | long double __gammal(long double x) 26 | { 27 | return gammal_r(x, &signgam); 28 | } 29 | 30 | __typeof(__gammal) gammal __attribute__((weak, alias("__gammal"))); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /w_lgammal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================== 3 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 | * 5 | * Developed at SunPro, a Sun Microsystems, Inc. business. 6 | * Permission to use, copy, modify, and distribute this 7 | * software is freely granted, provided that this notice 8 | * is preserved. 9 | * ==================================================== 10 | * 11 | */ 12 | 13 | /* long double lgammal(long double x) 14 | * Return the logarithm of the Gamma function of x. 15 | * 16 | * Method: call lgammal_r 17 | */ 18 | 19 | #ifndef __FDLIBM_H__ 20 | #include "fdlibm.h" 21 | #endif 22 | 23 | #ifndef __NO_LONG_DOUBLE_MATH 24 | 25 | long double __lgammal(long double x) 26 | { 27 | return lgammal_r(x, &signgam); 28 | } 29 | 30 | __typeof(__lgammal) lgammal __attribute__((weak, alias("__lgammal"))); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /s_sincos.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __have_fpu_sincos 6 | 7 | void __ieee754_sincos(double x, double *sinx, double *cosx) 8 | { 9 | *sinx = __ieee754_sin(x); 10 | *cosx = __ieee754_cos(x); 11 | } 12 | 13 | #endif 14 | 15 | void __sincos(double x, double *sinx, double *cosx) 16 | { 17 | int32_t ix; 18 | 19 | /* High word of x. */ 20 | GET_HIGH_WORD(ix, x); 21 | 22 | /* |x| ~< pi/4 */ 23 | ix &= IC(0x7fffffff); 24 | if (ix >= IC(0x7ff00000)) 25 | { 26 | /* sin(Inf or NaN) is NaN */ 27 | *sinx = *cosx = x - x; 28 | } else 29 | { 30 | __ieee754_sincos(x, sinx, cosx); 31 | } 32 | } 33 | 34 | __typeof(__sincos) sincos __attribute__((weak, alias("__sincos"))); 35 | #ifdef __NO_LONG_DOUBLE_MATH 36 | __typeof(__sincosl) __sincosl __attribute__((alias("__sincos"))); 37 | __typeof(__sincosl) sincosl __attribute__((weak, alias("__sincos"))); 38 | #endif 39 | -------------------------------------------------------------------------------- /e_acosl.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __NO_LONG_DOUBLE_MATH 6 | 7 | #ifndef __have_fpu_acos 8 | 9 | long double __ieee754_acosl(long double x) 10 | { 11 | long double y; 12 | 13 | if (x == 0.0) 14 | return M_PI_2l; 15 | if (x == 1.0) 16 | return 0.0; 17 | if (x == -1.0) 18 | return M_PIl; 19 | y = __ieee754_atanl(__ieee754_sqrtl(1.0L - (x * x)) / x); 20 | if (x > 0.0) 21 | return y; 22 | return y + M_PIl; 23 | } 24 | 25 | #endif 26 | 27 | /* wrapper acosl */ 28 | long double __acosl(long double x) 29 | { 30 | if (isgreater(__ieee754_fabsl(x), 1.0L) && _LIB_VERSION != _IEEE_) 31 | { 32 | /* acos(|x|>1) */ 33 | feraiseexcept(FE_INVALID); 34 | return __kernel_standard_l(x, x, __builtin_nanl(""), KMATHERRL_ACOS); 35 | } 36 | 37 | return __ieee754_acosl(x); 38 | } 39 | 40 | __typeof(__acosl) acosl __attribute__((weak, alias("__acosl"))); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /s_frexpf.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __have_fpu_frexp 6 | 7 | float __ieee754_frexpf(float x, int *eptr) 8 | { 9 | int32_t hx, ix; 10 | static const float two25 = 3.3554432000e+07; /* 0x4c000000 */ 11 | 12 | GET_FLOAT_WORD(hx, x); 13 | ix = UC(0x7fffffff) & hx; 14 | *eptr = 0; 15 | if (!FLT_UWORD_IS_FINITE(ix) || FLT_UWORD_IS_ZERO(ix)) 16 | return x; /* 0,inf,nan */ 17 | if (FLT_UWORD_IS_SUBNORMAL(ix)) 18 | { /* subnormal */ 19 | x *= two25; 20 | GET_FLOAT_WORD(hx, x); 21 | ix = hx & UC(0x7fffffff); 22 | *eptr = -25; 23 | } 24 | *eptr += (int)(ix >> 23) - 126; 25 | hx = (hx & UC(0x807fffff)) | UC(0x3f000000); 26 | SET_FLOAT_WORD(x, hx); 27 | return x; 28 | } 29 | 30 | #endif 31 | 32 | float __frexpf(float x, int *exp) 33 | { 34 | return __ieee754_frexpf(x, exp); 35 | } 36 | 37 | __typeof(__frexpf) frexpf __attribute__((weak, alias("__frexpf"))); 38 | -------------------------------------------------------------------------------- /s_fpclassifyl.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002, 2007 by Red Hat, Incorporated. All rights reserved. 2 | * 3 | * Permission to use, copy, modify, and distribute this software 4 | * is freely granted, provided that this notice is preserved. 5 | */ 6 | 7 | #ifndef __FDLIBM_H__ 8 | #include "fdlibm.h" 9 | #endif 10 | 11 | #ifndef __NO_LONG_DOUBLE_MATH 12 | 13 | int __fpclassifyl(long double x) 14 | { 15 | int retval = FP_NORMAL; 16 | uint32_t ex, hx, lx, m; 17 | 18 | GET_LDOUBLE_WORDS(ex, hx, lx, x); 19 | m = (hx & UC(0x7fffffff)) | lx; 20 | ex &= IEEE854_LONG_DOUBLE_MAXEXP; 21 | if ((ex | m) == 0) 22 | retval = FP_ZERO; 23 | else if (ex == 0 && (hx & UC(0x80000000)) == 0) 24 | retval = FP_SUBNORMAL; 25 | else if (ex == IEEE854_LONG_DOUBLE_MAXEXP) 26 | retval = m != 0 ? FP_NAN : FP_INFINITE; 27 | 28 | return retval; 29 | } 30 | 31 | __typeof(__fpclassifyl) fpclassifyl __attribute__((weak, alias("__fpclassifyl"))); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /s_truncf.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __have_fpu_trunc 6 | 7 | float __ieee754_truncf(float x) 8 | { 9 | int32_t i0, j0; 10 | int32_t sx; 11 | 12 | GET_FLOAT_WORD(i0, x); 13 | sx = i0 & UC(0x80000000); 14 | j0 = ((i0 >> IEEE754_FLOAT_SHIFT) & IEEE754_FLOAT_MAXEXP) - IEEE754_FLOAT_BIAS; 15 | if (j0 < IEEE754_FLOAT_SHIFT) 16 | { 17 | if (j0 < 0) 18 | { 19 | /* The magnitude of the number is < 1 so the result is +-0. */ 20 | SET_FLOAT_WORD(x, sx); 21 | } else 22 | { 23 | SET_FLOAT_WORD(x, sx | (i0 & ~(UC(0x007fffff) >> j0))); 24 | } 25 | } else 26 | { 27 | if (j0 == (IEEE754_FLOAT_MAXEXP - IEEE754_FLOAT_BIAS)) 28 | /* x is inf or NaN. */ 29 | return x + x; 30 | } 31 | 32 | return x; 33 | } 34 | 35 | #endif 36 | 37 | float __truncf(float x) 38 | { 39 | return __ieee754_truncf(x); 40 | } 41 | 42 | __typeof(__truncf) truncf __attribute__((weak, alias("__truncf"))); 43 | -------------------------------------------------------------------------------- /s_lib_version.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_lib_version.c 1.3 95/01/18 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | /* 14 | * MACRO for standards 15 | */ 16 | 17 | #include "fdlibm.h" 18 | 19 | #undef _LIB_VERSION 20 | 21 | /* 22 | * define and initialize _LIB_VERSION 23 | */ 24 | #if defined(_POSIX_MODE) 25 | _LIB_VERSION_TYPE _LIB_VERSION = _POSIX_; 26 | #elif defined(_XOPEN_MODE) 27 | _LIB_VERSION_TYPE _LIB_VERSION = _XOPEN_; 28 | #elif defined(_SVID3_MODE) 29 | _LIB_VERSION_TYPE _LIB_VERSION = _SVID_; 30 | #else /* default _IEEE_MODE */ 31 | _LIB_VERSION_TYPE _LIB_VERSION = _IEEE_; 32 | #endif 33 | -------------------------------------------------------------------------------- /w_gamma.c: -------------------------------------------------------------------------------- 1 | /* @(#)w_gamma.c 1.3 95/01/18 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | * 12 | */ 13 | 14 | /* double gamma(double x) 15 | * Return the logarithm of the Gamma function of x. 16 | * 17 | * Method: call gamma_r 18 | */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | 24 | double __gamma(double x) 25 | { 26 | return gamma_r(x, &signgam); 27 | } 28 | 29 | __typeof(__gamma) gamma __attribute__((weak, alias("__gamma"))); 30 | #ifdef __NO_LONG_DOUBLE_MATH 31 | __typeof(__gammal) __gammal __attribute__((alias("__gamma"))); 32 | __typeof(__gammal) gammal __attribute__((weak, alias("__gamma"))); 33 | #endif 34 | -------------------------------------------------------------------------------- /s_frexpl.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __NO_LONG_DOUBLE_MATH 6 | 7 | #ifndef __have_fpu_frexp 8 | 9 | long double __ieee754_frexpl(long double x, int *eptr) 10 | { 11 | static const long double two65 = 3.68934881474191032320e+19L; /* 0x4040, 0x80000000, 0x00000000 */ 12 | 13 | uint32_t se, hx, ix, lx; 14 | 15 | GET_LDOUBLE_WORDS(se, hx, lx, x); 16 | ix = 0x7fff & se; 17 | *eptr = 0; 18 | if (ix == 0x7fff || ((ix | hx | lx) == 0)) 19 | return x; /* 0,inf,nan */ 20 | if (ix == 0x0000) 21 | { /* subnormal */ 22 | x *= two65; 23 | GET_LDOUBLE_EXP(se, x); 24 | ix = se & 0x7fff; 25 | *eptr = -65; 26 | } 27 | *eptr += (int)(ix - 16382); 28 | se = (se & 0x8000) | 0x3ffe; 29 | SET_LDOUBLE_EXP(x, se); 30 | return x; 31 | } 32 | 33 | #endif 34 | 35 | long double __frexpl(long double x, int *exp) 36 | { 37 | return __ieee754_frexpl(x, exp); 38 | } 39 | 40 | __typeof(__frexpl) frexpl __attribute__((weak, alias("__frexpl"))); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /s_nearbyintf.c: -------------------------------------------------------------------------------- 1 | /* s_nearbyintf.c -- float version of s_nearbyint.c. 2 | * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. 3 | */ 4 | /* Adapted for use as nearbyint by Ulrich Drepper . */ 5 | 6 | /* 7 | * ==================================================== 8 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 9 | * 10 | * Developed at SunPro, a Sun Microsystems, Inc. business. 11 | * Permission to use, copy, modify, and distribute this 12 | * software is freely granted, provided that this notice 13 | * is preserved. 14 | * ==================================================== 15 | */ 16 | 17 | 18 | #ifndef __FDLIBM_H__ 19 | #include "fdlibm.h" 20 | #endif 21 | 22 | float __nearbyintf(float x) 23 | { 24 | fenv_t env; 25 | float value; 26 | 27 | feholdexcept(&env); 28 | value = __ieee754_rintf(x); 29 | fesetenv(&env); 30 | return value; 31 | } 32 | 33 | __typeof(__nearbyintf) nearbyintf __attribute__((weak, alias("__nearbyintf"))); 34 | -------------------------------------------------------------------------------- /tests/README.txt: -------------------------------------------------------------------------------- 1 | This is a first version of a testsuite for fdlibm for 680x0. 2 | 3 | Part of the data for the tests were orginally taken from an 4 | older release of GLIBC, but many additional test cases for 5 | corner-cases have been added. 6 | 7 | The tests where originally designed to test emulator behaviour 8 | of FPU instructions, and had already been verified by running them 9 | on real hardware. However, since the FPU internally only uses long 10 | doubles, and fdlibm currently only handles (64-bit) doubles, the 11 | tests were adjusted. 12 | 13 | Some failures have already been identified, and are currently skipped 14 | to concentrate on any remaining issues and to prevent regressions. 15 | 16 | Note that the constants involved in the tests are still defined as 17 | long doubles, and are converted during the tests. This is not perfect, 18 | and might change in a later release. For the same reason, the Coldfire 19 | versions might not work yet at all, because the Coldfire has no long double 20 | format. 21 | -------------------------------------------------------------------------------- /s_fpclassify.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2002, 2007 by Red Hat, Incorporated. All rights reserved. 2 | * 3 | * Permission to use, copy, modify, and distribute this software 4 | * is freely granted, provided that this notice is preserved. 5 | */ 6 | 7 | #include "fdlibm.h" 8 | 9 | #undef fpclassify 10 | 11 | int __fpclassify (double x) 12 | { 13 | int retval = FP_NORMAL; 14 | uint32_t msw, lsw; 15 | 16 | GET_DOUBLE_WORDS(msw, lsw, x); 17 | 18 | lsw |= msw & UC(0xfffff); 19 | msw &= UC(0x7ff00000); 20 | if ((msw | lsw) == 0) 21 | retval = FP_ZERO; 22 | else if (msw == 0) 23 | retval = FP_SUBNORMAL; 24 | else if (msw == UC(0x7ff00000)) 25 | retval = lsw != 0 ? FP_NAN : FP_INFINITE; 26 | 27 | return retval; 28 | } 29 | 30 | __typeof(__fpclassify) fpclassify __attribute__((weak, alias("__fpclassify"))); 31 | #ifdef __NO_LONG_DOUBLE_MATH 32 | int __fpclassifyl(long double x) __attribute__((alias("__fpclassify"))); 33 | __typeof(__fpclassifyl) fpclassifyl __attribute__((weak, alias("__fpclassifyl"))); 34 | #endif 35 | -------------------------------------------------------------------------------- /s_issigf.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | int __issignalingf(float x) 6 | { 7 | uint32_t xi; 8 | 9 | GET_FLOAT_WORD(xi, x); 10 | #ifdef HIGH_ORDER_BIT_IS_SET_FOR_SNAN 11 | /* We only have to care about the high-order bit of x's significand, because 12 | having it set (sNaN) already makes the significand different from that 13 | used to designate infinity. */ 14 | return (xi & UC(0x7fc00000)) == UC(0x7fc00000); 15 | #else 16 | /* To keep the following comparison simple, toggle the quiet/signaling bit, 17 | so that it is set for sNaNs. This is inverse to IEEE 754-2008 (as well as 18 | common practice for IEEE 754-1985). */ 19 | xi ^= UC(0x00400000); 20 | /* We have to compare for greater (instead of greater or equal), because x's 21 | significand being all-zero designates infinity not NaN. */ 22 | return (xi & UC(0x7fffffff)) > UC(0x7fc00000); 23 | #endif 24 | } 25 | 26 | __typeof(__issignalingf) issignalingf __attribute__((weak, alias("__issignalingf"))); 27 | -------------------------------------------------------------------------------- /e_exp10f.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __have_fpu_exp10 6 | 7 | float __ieee754_exp10f(float arg) 8 | { 9 | /* The argument to exp needs to be calculated in enough precision 10 | that the fractional part has as much precision as float, in 11 | addition to the bits in the integer part; using double ensures 12 | this. */ 13 | return (float)__ieee754_exp(M_LN10 * (double)arg); 14 | } 15 | 16 | #endif 17 | 18 | 19 | float __exp10f(float x) 20 | { 21 | float z = __ieee754_exp10f(x); 22 | 23 | if (!isfinite(z) && isfinite(x) && _LIB_VERSION != _IEEE_) 24 | /* exp10 overflow (46) if x > 0, underflow (47) if x < 0. */ 25 | return __kernel_standard_f(x, x, z, signbit(x) ? KMATHERRF_EXP10_UNDERFLOW : KMATHERRF_EXP10_OVERFLOW); 26 | 27 | return z; 28 | } 29 | 30 | __typeof(__exp10f) exp10f __attribute__((weak, alias("__exp10f"))); 31 | __typeof(__exp10f) __pow10f __attribute__((alias("__exp10f"))); 32 | __typeof(__pow10f) pow10f __attribute__((weak, alias("__pow10f"))); 33 | -------------------------------------------------------------------------------- /s_finitel.c: -------------------------------------------------------------------------------- 1 | /* s_finitel.c -- long double version of s_finite.c. 2 | * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz. 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 | * finitel(x) returns 1 is x is finite, else 0; 18 | * no branching! 19 | */ 20 | 21 | #ifndef __FDLIBM_H__ 22 | #include "fdlibm.h" 23 | #endif 24 | 25 | #ifndef __NO_LONG_DOUBLE_MATH 26 | 27 | int __finitel(long double x) 28 | { 29 | uint32_t exp; 30 | 31 | GET_LDOUBLE_EXP(exp, x); 32 | return (int) (((exp & 0x7fff) - 0x7fff) >> 31); 33 | } 34 | 35 | __typeof(__finitel) finitel __attribute__((weak, alias("__finitel"))); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /w_lgamma.c: -------------------------------------------------------------------------------- 1 | /* @(#)w_lgamma.c 1.3 95/01/18 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | * 12 | */ 13 | 14 | /* double lgamma(double x) 15 | * Return the logarithm of the Gamma function of x. 16 | * 17 | * Method: call lgamma_r 18 | */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | 24 | double __lgamma(double x) 25 | { 26 | return lgamma_r(x, &signgam); 27 | } 28 | 29 | __typeof(__lgamma) lgamma __attribute__((weak, alias("__lgamma"))); 30 | #ifdef __NO_LONG_DOUBLE_MATH 31 | __typeof(__lgammal) __lgammal __attribute__((alias("__lgamma"))); 32 | __typeof(__lgammal) lgammal __attribute__((weak, alias("__lgamma"))); 33 | #endif 34 | -------------------------------------------------------------------------------- /s_finite.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_finite.c 1.3 95/01/18 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | /* 14 | * finite(x) returns 1 is x is finite, else 0; 15 | * no branching! 16 | */ 17 | 18 | #ifndef __FDLIBM_H__ 19 | #include "fdlibm.h" 20 | #endif 21 | 22 | int __finite(double x) 23 | { 24 | uint32_t hx; 25 | 26 | GET_HIGH_WORD(hx, x); 27 | return (int) (((hx & UC(0x7fffffff)) - UC(0x7ff00000)) >> 31); 28 | } 29 | 30 | __typeof(__finite) finite __attribute__((weak, alias("__finite"))); 31 | #ifdef __NO_LONG_DOUBLE_MATH 32 | __typeof(finitel) __finitel __attribute__((alias("__finite"))); 33 | __typeof(__finitel) finitel __attribute__((weak, alias("__finite"))); 34 | #endif 35 | -------------------------------------------------------------------------------- /s_fabsl.c: -------------------------------------------------------------------------------- 1 | /* s_fabsl.c -- long double version of s_fabs.c. 2 | */ 3 | 4 | /* 5 | * ==================================================== 6 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 7 | * 8 | * Developed at SunPro, a Sun Microsystems, Inc. business. 9 | * Permission to use, copy, modify, and distribute this 10 | * software is freely granted, provided that this notice 11 | * is preserved. 12 | * ==================================================== 13 | */ 14 | 15 | /* 16 | * fabsl(x) returns the absolute value of x. 17 | */ 18 | 19 | #ifndef __FDLIBM_H__ 20 | #include "fdlibm.h" 21 | #endif 22 | 23 | #ifndef __NO_LONG_DOUBLE_MATH 24 | long double __fabsl(long double x) 25 | { 26 | #ifdef __mc68000__ 27 | ieee_long_double_shape_type *sh_u = (ieee_long_double_shape_type *)&x; 28 | sh_u->parts.sign_exponent &= 0x7fff; 29 | #else 30 | uint32_t exp; 31 | 32 | GET_LDOUBLE_EXP(exp, x); 33 | SET_LDOUBLE_EXP(x, exp & 0x7fff); 34 | #endif 35 | return x; 36 | } 37 | 38 | __typeof(__fabsl) fabsl __attribute__((weak, alias("__fabsl"))); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /s_issigl.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __NO_LONG_DOUBLE_MATH 6 | 7 | int __issignalingl(long double x) 8 | { 9 | uint32_t exi, hxi, lxi; 10 | 11 | GET_LDOUBLE_WORDS(exi, hxi, lxi, x); 12 | #ifdef HIGH_ORDER_BIT_IS_SET_FOR_SNAN 13 | # error not implemented 14 | #else 15 | /* To keep the following comparison simple, toggle the quiet/signaling bit, 16 | so that it is set for sNaNs. This is inverse to IEEE 754-2008 (as well as 17 | common practice for IEEE 754-1985). */ 18 | hxi ^= UC(0x40000000); 19 | /* If lxi != 0, then set any suitable bit of the significand in hxi. */ 20 | hxi |= (lxi | -lxi) >> 31; 21 | /* We do not recognize a pseudo NaN as sNaN; they're invalid on 80387 and 22 | later. */ 23 | /* We have to compare for greater (instead of greater or equal), because x's 24 | significand being all-zero designates infinity not NaN. */ 25 | return ((exi & 0x7fff) == 0x7fff) && (hxi > UC(0xc0000000)); 26 | #endif 27 | } 28 | 29 | __typeof(__issignalingl) issignalingl __attribute__((weak, alias("__issignalingl"))); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /e_exp10l.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __NO_LONG_DOUBLE_MATH 6 | 7 | #ifndef __have_fpu_exp10 8 | 9 | long double __ieee754_exp10l(long double arg) 10 | { 11 | if (isfinite(arg) && arg < LDBL_MIN_10_EXP - LDBL_DIG - 10) 12 | { 13 | feraiseexcept(FE_UNDERFLOW); 14 | return 0; 15 | } 16 | /* This is a very stupid and inprecise implementation. It'll get 17 | replaced sometime (soon?). */ 18 | return __ieee754_expl(M_LN10l * arg); 19 | } 20 | 21 | #endif 22 | 23 | long double __exp10l(long double x) 24 | { 25 | long double z = __ieee754_exp10l(x); 26 | 27 | if (!isfinite(z) && isfinite(x) && _LIB_VERSION != _IEEE_) 28 | /* exp10 overflow (46) if x > 0, underflow (47) if x < 0. */ 29 | return __kernel_standard_l(x, x, z, signbit(x) ? KMATHERRL_EXP10_UNDERFLOW : KMATHERRL_EXP10_OVERFLOW); 30 | 31 | return z; 32 | } 33 | 34 | __typeof(__exp10l) exp10l __attribute__((weak, alias("__exp10l"))); 35 | __typeof(__exp10l) __pow10l __attribute__((alias("__exp10l"))); 36 | __typeof(__pow10l) pow10l __attribute__((weak, alias("__pow10l"))); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /s_isnan.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_isnan.c 1.3 95/01/18 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | /* 14 | * isnan(x) returns 1 is x is nan, else 0; 15 | * no branching! 16 | */ 17 | 18 | #ifndef __FDLIBM_H__ 19 | #include "fdlibm.h" 20 | #endif 21 | 22 | int __isnan(double x) 23 | { 24 | int32_t hx, lx; 25 | 26 | GET_DOUBLE_WORDS(hx, lx, x); 27 | hx &= IC(0x7fffffff); 28 | hx |= (uint32_t) (lx | (-lx)) >> 31; 29 | hx = IC(0x7ff00000) - hx; 30 | return (int) (((uint32_t) hx) >> 31); 31 | } 32 | 33 | __typeof(__isnan) isnan __attribute__((weak, alias("__isnan"))); 34 | #ifdef __NO_LONG_DOUBLE_MATH 35 | __typeof(__isnanl) __isnanl __attribute__((alias("__isnan"))); 36 | __typeof(__isnanl) isnanl __attribute__((weak, alias("__isnan"))); 37 | #endif 38 | -------------------------------------------------------------------------------- /w_gammaf_r.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================== 3 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 | * 5 | * Developed at SunPro, a Sun Microsystems, Inc. business. 6 | * Permission to use, copy, modify, and distribute this 7 | * software is freely granted, provided that this notice 8 | * is preserved. 9 | * ==================================================== 10 | * 11 | */ 12 | 13 | /* float gammaf_r(float x, int *signgamp) 14 | * Return the logarithm of the Gamma function of x. 15 | * 16 | * Method: call __ieee754_gammaf_r 17 | */ 18 | 19 | #ifndef __FDLIBM_H__ 20 | #include "fdlibm.h" 21 | #endif 22 | 23 | float __gammaf_r(float x, int *signgamp) 24 | { 25 | float y = __ieee754_lgammaf_r(x, signgamp); 26 | 27 | if (!isfinite(y) && isfinite(x) && _LIB_VERSION != _IEEE_) 28 | return __kernel_standard_f(x, x, y, __ieee754_floorf(x) == x && x <= 0.0F ? KMATHERRF_LGAMMA_MINUS /* lgamma pole */ 29 | : KMATHERRF_LGAMMA_OVERFLOW); /* lgamma overflow */ 30 | 31 | return y; 32 | } 33 | 34 | __typeof(__gammaf_r) gammaf_r __attribute__((weak, alias("__gammaf_r"))); 35 | -------------------------------------------------------------------------------- /w_lgammaf_r.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================== 3 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 | * 5 | * Developed at SunPro, a Sun Microsystems, Inc. business. 6 | * Permission to use, copy, modify, and distribute this 7 | * software is freely granted, provided that this notice 8 | * is preserved. 9 | * ==================================================== 10 | * 11 | */ 12 | 13 | /* float lgammaf_r(float x, int *signgamp) 14 | * Return the logarithm of the Gamma function of x. 15 | * 16 | * Method: call __ieee754_lgammaf_r 17 | */ 18 | 19 | #ifndef __FDLIBM_H__ 20 | #include "fdlibm.h" 21 | #endif 22 | 23 | float __lgammaf_r(float x, int *signgamp) 24 | { 25 | float y = __ieee754_lgammaf_r(x, signgamp); 26 | 27 | if (!isfinite(y) && isfinite(x) && _LIB_VERSION != _IEEE_) 28 | return __kernel_standard_f(x, x, y, __ieee754_floorf(x) == x && x <= 0.0F ? KMATHERRF_LGAMMA_MINUS /* lgamma pole */ 29 | : KMATHERRF_LGAMMA_OVERFLOW); /* lgamma overflow */ 30 | 31 | return y; 32 | } 33 | 34 | __typeof(__lgammaf_r) lgammaf_r __attribute__((weak, alias("__lgammaf_r"))); 35 | -------------------------------------------------------------------------------- /s_ldexp.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_ldexp.c 1.3 95/01/18 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | #ifndef __FDLIBM_H__ 14 | #include "fdlibm.h" 15 | #endif 16 | 17 | #ifndef __have_fpu_ldexp 18 | 19 | double __ieee754_ldexp(double value, int exp) 20 | { 21 | if (!isfinite(value) || value == 0.0) 22 | return value; 23 | return __ieee754_scalbn(value, exp); 24 | } 25 | 26 | #endif 27 | 28 | double __ldexp(double x, int n) 29 | { 30 | x = __ieee754_ldexp(x, n); 31 | if (!isfinite(x) || x == 0.0) 32 | __set_errno(ERANGE); 33 | return x; 34 | } 35 | 36 | __typeof(__ldexp) ldexp __attribute__((weak, alias("__ldexp"))); 37 | #ifdef __NO_LONG_DOUBLE_MATH 38 | __typeof(__ldexpl) __ldexpl __attribute__((alias("__ldexp"))); 39 | __typeof(__ldexpl) ldexpl __attribute__((weak, alias("__ldexp"))); 40 | #endif 41 | -------------------------------------------------------------------------------- /include/fpu_control.h: -------------------------------------------------------------------------------- 1 | /* 68k FPU control word definitions. 2 | Copyright (C) 1996-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library. If not, see 17 | . */ 18 | 19 | #ifndef _FPU_CONTROL_H 20 | #define _FPU_CONTROL_H 21 | 22 | #ifndef _FEATURES_H 23 | #include 24 | #endif 25 | 26 | #ifndef _BITS_TYPES_H 27 | #include 28 | #endif 29 | 30 | #include 31 | 32 | #endif /* _FPU_CONTROL_H */ 33 | -------------------------------------------------------------------------------- /s_fabs.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_fabs.c 1.3 95/01/18 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | /* 14 | * fabs(x) returns the absolute value of x. 15 | */ 16 | 17 | #ifndef __FDLIBM_H__ 18 | #include "fdlibm.h" 19 | #endif 20 | 21 | double __fabs(double x) 22 | { 23 | #ifdef __mc68000__ 24 | ieee_double_shape_type *sh_u = (ieee_double_shape_type *)&x; 25 | sh_u->parts.msw &= UC(0x7fffffff); 26 | return x; 27 | #else 28 | uint32_t high; 29 | 30 | GET_HIGH_WORD(high, x); 31 | SET_HIGH_WORD(x, high & UC(0x7fffffff)); 32 | return x; 33 | #endif 34 | } 35 | 36 | __typeof(__fabs) fabs __attribute__((weak, alias("__fabs"))); 37 | #ifdef __NO_LONG_DOUBLE_MATH 38 | long double __fabsl(long double x) __attribute__((alias("__fabs"))); 39 | __typeof(__fabsl) fabsl __attribute__((weak, alias("__fabs"))); 40 | #endif 41 | -------------------------------------------------------------------------------- /include/bits/inf.h: -------------------------------------------------------------------------------- 1 | /* `INFINITY' constant for IEEE 754 machines. 2 | Copyright (C) 2004-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, see 17 | . */ 18 | 19 | #ifndef _MATH_H 20 | # error "Never use directly; include instead." 21 | #endif 22 | 23 | /* IEEE positive infinity. */ 24 | 25 | #if __GNUC_PREREQ(3,3) 26 | # define INFINITY (__builtin_inff()) 27 | #else 28 | # define INFINITY HUGE_VALF 29 | #endif 30 | -------------------------------------------------------------------------------- /w_gammal_r.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================== 3 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 | * 5 | * Developed at SunPro, a Sun Microsystems, Inc. business. 6 | * Permission to use, copy, modify, and distribute this 7 | * software is freely granted, provided that this notice 8 | * is preserved. 9 | * ==================================================== 10 | * 11 | */ 12 | 13 | /* double gamma(double x) 14 | * Return the logarithm of the Gamma function of x. 15 | * 16 | * Method: call __ieee754_gammal_r 17 | */ 18 | 19 | #ifndef __FDLIBM_H__ 20 | #include "fdlibm.h" 21 | #endif 22 | 23 | #ifndef __NO_LONG_DOUBLE_MATH 24 | 25 | long double __gammal_r(long double x, int *signgamp) 26 | { 27 | long double y = __ieee754_lgammal_r(x, signgamp); 28 | 29 | if (!isfinite(y) && isfinite(x) && _LIB_VERSION != _IEEE_) 30 | return __kernel_standard_l(x, x, y, __ieee754_floorl(x) == x && x <= 0.0 ? KMATHERRL_LGAMMA_MINUS /* lgamma pole */ 31 | : KMATHERRL_LGAMMA_OVERFLOW); /* lgamma overflow */ 32 | 33 | return y; 34 | } 35 | 36 | __typeof(__gammal_r) gammal_r __attribute__((weak, alias("__gammal_r"))); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /s_copysign.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_copysign.c 1.3 95/01/18 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | /* 14 | * copysign(double x, double y) 15 | * copysign(x,y) returns a value with the magnitude of x and 16 | * with the sign bit of y. 17 | */ 18 | 19 | #ifndef __FDLIBM_H__ 20 | #include "fdlibm.h" 21 | #endif 22 | 23 | double __copysign(double x, double y) 24 | { 25 | uint32_t hx, hy; 26 | 27 | GET_HIGH_WORD(hx, x); 28 | GET_HIGH_WORD(hy, y); 29 | SET_HIGH_WORD(x, (hx & UC(0x7fffffff)) | (hy & UC(0x80000000))); 30 | return x; 31 | } 32 | 33 | __typeof(__copysign) copysign __attribute__((weak, alias("__copysign"))); 34 | #ifdef __NO_LONG_DOUBLE_MATH 35 | __typeof(__copysignl) __copysignl __attribute__((alias("__copysign"))); 36 | __typeof(__copysignl) copysignl __attribute__((weak, alias("__copysign"))); 37 | #endif 38 | -------------------------------------------------------------------------------- /s_truncl.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __NO_LONG_DOUBLE_MATH 6 | 7 | #ifndef __have_fpu_trunc 8 | 9 | long double __ieee754_truncl(long double x) 10 | { 11 | int32_t i0, j0; 12 | uint32_t se, i1; 13 | int32_t sx; 14 | 15 | GET_LDOUBLE_WORDS(se, i0, i1, x); 16 | sx = se & 0x8000; 17 | j0 = (se & IEEE854_LONG_DOUBLE_MAXEXP) - IEEE854_LONG_DOUBLE_BIAS; 18 | if (j0 < 31) 19 | { 20 | if (j0 < 0) 21 | /* The magnitude of the number is < 1 so the result is +-0. */ 22 | SET_LDOUBLE_WORDS(x, sx, 0, 0); 23 | else 24 | SET_LDOUBLE_WORDS(x, se, i0 & ~(UC(0x7fffffff) >> j0), 0); 25 | } else if (j0 > 63) 26 | { 27 | if (j0 == (IEEE854_LONG_DOUBLE_MAXEXP - IEEE854_LONG_DOUBLE_BIAS)) 28 | /* x is inf or NaN. */ 29 | return x + x; 30 | } else 31 | { 32 | /* avoid undefined behaviour for shift-count == 32 */ 33 | if (j0 != 63) 34 | SET_LDOUBLE_WORDS(x, se, i0, i1 & ~(UC(0xffffffff) >> (j0 - 31))); 35 | } 36 | 37 | return x; 38 | } 39 | 40 | #endif 41 | 42 | long double __truncl(long double x) 43 | { 44 | return __ieee754_truncl(x); 45 | } 46 | 47 | __typeof(__truncl) truncl __attribute__((weak, alias("__truncl"))); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /w_lgammal_r.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================== 3 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 | * 5 | * Developed at SunPro, a Sun Microsystems, Inc. business. 6 | * Permission to use, copy, modify, and distribute this 7 | * software is freely granted, provided that this notice 8 | * is preserved. 9 | * ==================================================== 10 | * 11 | */ 12 | 13 | /* double lgamma(double x) 14 | * Return the logarithm of the Gamma function of x. 15 | * 16 | * Method: call __ieee754_lgammal_r 17 | */ 18 | 19 | #ifndef __FDLIBM_H__ 20 | #include "fdlibm.h" 21 | #endif 22 | 23 | #ifndef __NO_LONG_DOUBLE_MATH 24 | 25 | long double __lgammal_r(long double x, int *signgamp) 26 | { 27 | long double y = __ieee754_lgammal_r(x, signgamp); 28 | 29 | if (!isfinite(y) && isfinite(x) && _LIB_VERSION != _IEEE_) 30 | return __kernel_standard_l(x, x, y, __ieee754_floorl(x) == x && x <= 0.0 ? KMATHERRL_LGAMMA_MINUS /* lgamma pole */ 31 | : KMATHERRL_LGAMMA_OVERFLOW); /* lgamma overflow */ 32 | 33 | return y; 34 | } 35 | 36 | __typeof(__lgammal_r) lgammal_r __attribute__((weak, alias("__lgammal_r"))); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /s_roundf.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __have_fpu_round 6 | 7 | float __ieee754_roundf(float x) 8 | { 9 | int32_t i0, j0; 10 | 11 | static const float hugeval = 1.0e30; 12 | 13 | GET_FLOAT_WORD(i0, x); 14 | j0 = ((i0 >> IEEE754_FLOAT_SHIFT) & IEEE754_FLOAT_MAXEXP) - IEEE754_FLOAT_BIAS; 15 | if (j0 < IEEE754_FLOAT_SHIFT) 16 | { 17 | if (j0 < 0) 18 | { 19 | math_force_eval(hugeval + x); 20 | 21 | i0 &= IC(0x80000000); 22 | if (j0 == -1) 23 | i0 |= IC(0x3f800000); 24 | } else 25 | { 26 | uint32_t i = UC(0x007fffff) >> j0; 27 | 28 | if ((i0 & i) == 0) 29 | /* X is integral. */ 30 | return x; 31 | math_force_eval(hugeval + x); 32 | 33 | /* Raise inexact if x != 0. */ 34 | i0 += UC(0x00400000) >> j0; 35 | i0 &= ~i; 36 | } 37 | } else 38 | { 39 | if (j0 == (IEEE754_FLOAT_MAXEXP - IEEE754_FLOAT_BIAS)) 40 | /* Inf or NaN. */ 41 | return x + x; 42 | else 43 | return x; 44 | } 45 | 46 | SET_FLOAT_WORD(x, i0); 47 | return x; 48 | } 49 | 50 | #endif 51 | 52 | float __roundf(float x) 53 | { 54 | return __ieee754_roundf(x); 55 | } 56 | 57 | __typeof(__roundf) roundf __attribute__((weak, alias("__roundf"))); 58 | -------------------------------------------------------------------------------- /s_logbf.c: -------------------------------------------------------------------------------- 1 | /* s_logbf.c -- float version of s_logb.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 | #ifndef __FDLIBM_H__ 17 | #include "fdlibm.h" 18 | #endif 19 | 20 | float __logbf(float x) 21 | { 22 | int32_t ix, rix; 23 | 24 | GET_FLOAT_WORD(ix, x); 25 | ix &= IC(0x7fffffff); /* high |x| */ 26 | if (ix == 0) 27 | return (float) -1.0 / __ieee754_fabsf(x); 28 | if (ix >= IC(0x7f800000)) 29 | return x * x; 30 | if ((rix = ix >> IEEE754_FLOAT_SHIFT) == 0) 31 | { 32 | /* POSIX specifies that denormal number is treated as 33 | though it were normalized. */ 34 | rix -= count_leading_zeros(ix) - 9; 35 | } 36 | return (float) (rix - IEEE754_FLOAT_BIAS); 37 | } 38 | 39 | __typeof(__logbf) logbf __attribute__((weak, alias("__logbf"))); 40 | -------------------------------------------------------------------------------- /fpu_ctrl.c: -------------------------------------------------------------------------------- 1 | /* Install given floating-point environment. 2 | Copyright (C) 1997-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Andreas Schwab 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library. If not, see 18 | . */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | #include "fpu_ctrl.h" 24 | 25 | 26 | /* This module defines `__fpu_control' with the default value. */ 27 | 28 | fpu_control_t __fpu_control = _FPU_DEFAULT; 29 | fexcept_t __fpu_status = 0; 30 | -------------------------------------------------------------------------------- /s_trunc.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __have_fpu_trunc 6 | 7 | double __ieee754_trunc(double x) 8 | { 9 | int32_t i0, j0; 10 | uint32_t i1; 11 | int32_t sx; 12 | 13 | GET_DOUBLE_WORDS(i0, i1, x); 14 | sx = i0 & IC(0x80000000); 15 | j0 = ((i0 >> IEEE754_DOUBLE_SHIFT) & IEEE754_DOUBLE_MAXEXP) - IEEE754_DOUBLE_BIAS; 16 | if (j0 < IEEE754_DOUBLE_SHIFT) 17 | { 18 | if (j0 < 0) 19 | /* The magnitude of the number is < 1 so the result is +-0. */ 20 | INSERT_WORDS(x, sx, 0); 21 | else 22 | INSERT_WORDS(x, sx | (i0 & ~(UC(0x000fffff) >> j0)), 0); 23 | } else if (j0 > 51) 24 | { 25 | if (j0 == (IEEE754_DOUBLE_MAXEXP - IEEE754_DOUBLE_BIAS)) 26 | /* x is inf or NaN. */ 27 | return x + x; 28 | } else 29 | { 30 | INSERT_WORDS(x, i0, i1 & ~(UC(0xffffffff) >> (j0 - IEEE754_DOUBLE_SHIFT))); 31 | } 32 | 33 | return x; 34 | } 35 | 36 | #endif 37 | 38 | double __trunc(double x) 39 | { 40 | return __ieee754_trunc(x); 41 | } 42 | 43 | __typeof(__trunc) trunc __attribute__((weak, alias("__trunc"))); 44 | #ifdef __NO_LONG_DOUBLE_MATH 45 | long double __truncl(long double x) __attribute__((alias("__trunc"))); 46 | __typeof(__truncl) truncl __attribute__((weak, alias("__trunc"))); 47 | #endif 48 | -------------------------------------------------------------------------------- /s_nearbyint.c: -------------------------------------------------------------------------------- 1 | /* Adapted for use as nearbyint by Ulrich Drepper . */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | #ifndef __FDLIBM_H__ 14 | #include "fdlibm.h" 15 | #endif 16 | 17 | /* 18 | * nearbyint(x) 19 | * Return x rounded to integral value according to the prevailing 20 | * rounding mode. 21 | * Method: 22 | * Using floating addition. 23 | * Exception: 24 | * none 25 | */ 26 | 27 | double __nearbyint(double x) 28 | { 29 | fenv_t env; 30 | double value; 31 | 32 | feholdexcept(&env); 33 | value = __ieee754_rint(x); 34 | fesetenv(&env); 35 | return value; 36 | } 37 | 38 | __typeof(__nearbyint) nearbyint __attribute__((weak, alias("__nearbyint"))); 39 | #ifdef __NO_LONG_DOUBLE_MATH 40 | __typeof(nearbyintl) __nearbyintl __attribute__((alias("__nearbyint"))); 41 | __typeof(__nearbyintl) nearbyintl __attribute__((weak, alias("__nearbyint"))); 42 | #endif 43 | -------------------------------------------------------------------------------- /w_gamma_r.c: -------------------------------------------------------------------------------- 1 | /* @(#)w_gamma_r.c 1.3 95/01/18 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | /* 14 | * wrapper double gamma_r(double x, int *signgamp) 15 | */ 16 | 17 | #include "fdlibm.h" 18 | 19 | 20 | double __gamma_r(double x, int *signgamp) /* wrapper lgamma_r */ 21 | { 22 | double y = __ieee754_lgamma_r(x, signgamp); 23 | 24 | if (_LIB_VERSION != _IEEE_ && !isfinite(y) && isfinite(x)) 25 | return __kernel_standard(x, x, y, __ieee754_floor(x) == x && x <= 0.0 ? KMATHERR_LGAMMA_MINUS /* lgamma pole */ 26 | : KMATHERR_LGAMMA_OVERFLOW); /* lgamma overflow */ 27 | 28 | return y; 29 | } 30 | 31 | __typeof(__gamma_r) gamma_r __attribute__((weak, alias("__gamma_r"))); 32 | #ifdef __NO_LONG_DOUBLE_MATH 33 | __typeof(__gammal_r) __gammal_r __attribute__((alias("__gamma_r"))); 34 | __typeof(__gammal_r) gammal_r __attribute__((weak, alias("__gamma_r"))); 35 | #endif 36 | -------------------------------------------------------------------------------- /w_lgamma_r.c: -------------------------------------------------------------------------------- 1 | /* @(#)w_lgamma_r.c 1.3 95/01/18 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | /* 14 | * wrapper double lgamma_r(double x, int *signgamp) 15 | */ 16 | 17 | #ifndef __FDLIBM_H__ 18 | #include "fdlibm.h" 19 | #endif 20 | 21 | double __lgamma_r(double x, int *signgamp) 22 | { 23 | double y = __ieee754_lgamma_r(x, signgamp); 24 | 25 | if (_LIB_VERSION != _IEEE_ && !isfinite(y) && isfinite(x)) 26 | return __kernel_standard(x, x, y, __ieee754_floor(x) == x && x <= 0.0 ? KMATHERR_LGAMMA_MINUS /* lgamma pole */ 27 | : KMATHERR_LGAMMA_OVERFLOW); /* lgamma overflow */ 28 | 29 | return y; 30 | } 31 | 32 | __typeof(__lgamma_r) lgamma_r __attribute__((weak, alias("__lgamma_r"))); 33 | #ifdef __NO_LONG_DOUBLE_MATH 34 | __typeof(__lgammal_r) __lgammal_r __attribute__((alias("__lgamma_r"))); 35 | __typeof(__lgammal_r) lgammal_r __attribute__((weak, alias("__lgamma_r"))); 36 | #endif 37 | -------------------------------------------------------------------------------- /include/bits/fenv.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1997-2013 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library. If not, see 16 | . */ 17 | 18 | #ifndef _FENV_H 19 | # error "Never use directly; include instead." 20 | #endif 21 | 22 | #ifndef _BITS_TYPES_H 23 | #include 24 | #endif 25 | 26 | #ifdef __mc68000__ 27 | #include 28 | #endif 29 | 30 | #if defined(__i386__) || defined(__x86_64__) 31 | #include 32 | #endif 33 | 34 | #ifndef FE_DFL_ENV 35 | #error " not supported" 36 | #endif 37 | -------------------------------------------------------------------------------- /s_significand.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_significand.c 1.3 95/01/18 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | /* 14 | * significand(x) computes just 15 | * scalb(x, (double) -ilogb(x)), 16 | * for exercising the fraction-part(F) IEEE 754-1985 test vector. 17 | */ 18 | 19 | #ifndef __FDLIBM_H__ 20 | #include "fdlibm.h" 21 | #endif 22 | 23 | double __significand(double x) 24 | { 25 | uint32_t hx, ix; 26 | 27 | GET_HIGH_WORD(hx, x); 28 | ix = hx & UC(0x7ff00000); 29 | if (ix != 0 && ix != UC(0x7ff00000)) 30 | { 31 | SET_HIGH_WORD(x, (hx & UC(0x800fffff)) | UC(0x3ff00000)); 32 | } 33 | return x; 34 | } 35 | 36 | __typeof(__significand) significand __attribute__((weak, alias("__significand"))); 37 | #ifdef __NO_LONG_DOUBLE_MATH 38 | __typeof(__significandl) __significandl __attribute__((alias("__significand"))); 39 | __typeof(__significandl) significandl __attribute__((weak, alias("__significand"))); 40 | #endif 41 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Linux build 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-22.04 12 | strategy: 13 | fail-fast: false 14 | matrix: 15 | cross_tool: [ "m68k-atari-mint", "m68k-atari-mintelf" ] 16 | steps: 17 | - uses: actions/checkout@v4 18 | - name: Install SSH keys 19 | if: ${{ github.event_name == 'push' }} 20 | env: 21 | SSH_ID: ${{ secrets.SSH_ID }} 22 | run: ./.scripts/install_ssh_id.sh 23 | - name: Setup environment 24 | env: 25 | PROJECT_VERSION: "5.3" 26 | CROSS_TOOL: ${{ matrix.cross_tool }} 27 | run: ./.scripts/setup_env.sh 28 | - name: Install packages 29 | run: | 30 | SYSROOT_DIR="/" ./.scripts/install-freemint.sh binutils gcc mintbin 31 | ./.scripts/install-freemint.sh mintlib 32 | - name: build 33 | run: ./.scripts/build.sh 34 | - name: deploy 35 | if: ${{ github.event_name == 'push' }} 36 | env: 37 | COMMITER_NAME: ${{ github.event.commits[0].author.name }} 38 | COMMITER_EMAIL: ${{ github.event.commits[0].author.email }} 39 | run: ./.scripts/deploy.sh 40 | -------------------------------------------------------------------------------- /fegetround.c: -------------------------------------------------------------------------------- 1 | /* Return current rounding direction. 2 | Copyright (C) 1997-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Andreas Schwab 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library. If not, see 18 | . */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | #include "fpu_ctrl.h" 24 | 25 | int __fegetround(void) 26 | { 27 | fpu_control_t cw; 28 | 29 | _FPU_GETCW(cw); 30 | 31 | return (int) (cw & FE_ROUNDING_MASK); 32 | } 33 | 34 | __typeof(__fegetround) fegetround __attribute__((weak, alias("__fegetround"))); 35 | -------------------------------------------------------------------------------- /s_nearbyintl.c: -------------------------------------------------------------------------------- 1 | /* s_nearbyintl.c -- long double version of s_nearbyint.c. 2 | * Conversion to long double by Ulrich Drepper, 3 | * Cygnus Support, drepper@cygnus.com. 4 | */ 5 | /* Adapted for use as nearbyint by Ulrich Drepper . */ 6 | 7 | /* 8 | * ==================================================== 9 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 10 | * 11 | * Developed at SunPro, a Sun Microsystems, Inc. business. 12 | * Permission to use, copy, modify, and distribute this 13 | * software is freely granted, provided that this notice 14 | * is preserved. 15 | * ==================================================== 16 | */ 17 | 18 | /* 19 | * nearbyintl(x) 20 | * Return x rounded to integral value according to the prevailing 21 | * rounding mode. 22 | * Method: 23 | * Using floating addition. 24 | * Exception: 25 | * none 26 | */ 27 | 28 | #ifndef __FDLIBM_H__ 29 | #include "fdlibm.h" 30 | #endif 31 | 32 | #ifndef __NO_LONG_DOUBLE_MATH 33 | 34 | long double __nearbyintl(long double x) 35 | { 36 | fenv_t env; 37 | long double value; 38 | 39 | feholdexcept(&env); 40 | value = __ieee754_rintl(x); 41 | fesetenv(&env); 42 | return value; 43 | } 44 | 45 | __typeof(__nearbyintl) nearbyintl __attribute__((weak, alias("__nearbyintl"))); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /s_ceilf.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __have_fpu_ceil 6 | 7 | float __ieee754_ceilf(float x) 8 | { 9 | int32_t i0, j0; 10 | uint32_t i; 11 | 12 | static const float hugeval = 1.0e30; 13 | 14 | GET_FLOAT_WORD(i0, x); 15 | j0 = ((i0 >> IEEE754_FLOAT_SHIFT) & IEEE754_FLOAT_MAXEXP) - IEEE754_FLOAT_BIAS; 16 | if (j0 < IEEE754_FLOAT_SHIFT) 17 | { 18 | if (j0 < 0) 19 | { /* raise inexact if x != 0 */ 20 | math_force_eval(hugeval + x); /* return 0*sign(x) if |x|<1 */ 21 | if (i0 < 0) 22 | { 23 | i0 = IC(0x80000000); 24 | } else if (i0 != 0) 25 | { 26 | i0 = IC(0x3f800000); 27 | } 28 | } else 29 | { 30 | i = UC(0x007fffff) >> j0; 31 | if ((i0 & i) == 0) 32 | return x; /* x is integral */ 33 | math_force_eval(hugeval + x); /* raise inexact flag */ 34 | if (i0 > 0) 35 | i0 += UC(0x00800000) >> j0; 36 | i0 &= (~i); 37 | } 38 | } else 39 | { 40 | if (j0 == (IEEE754_FLOAT_MAXEXP - IEEE754_FLOAT_BIAS)) 41 | return x + x; /* inf or NaN */ 42 | else 43 | return x; /* x is integral */ 44 | } 45 | SET_FLOAT_WORD(x, i0); 46 | return x; 47 | } 48 | 49 | #endif 50 | 51 | float __ceilf(float x) 52 | { 53 | return __ieee754_ceilf(x); 54 | } 55 | 56 | __typeof(__ceilf) ceilf __attribute__((weak, alias("__ceilf"))); 57 | -------------------------------------------------------------------------------- /e_exp10.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __have_fpu_exp10 6 | 7 | double __ieee754_exp10(double arg) 8 | { 9 | if (isfinite(arg) && arg < DBL_MIN_10_EXP - DBL_DIG - 10) 10 | { 11 | feraiseexcept(FE_UNDERFLOW); 12 | return 0; 13 | } 14 | /* This is a very stupid and inprecise implementation. It'll get 15 | replaced sometime (soon?). */ 16 | return __ieee754_exp(M_LN10 * arg); 17 | } 18 | 19 | #endif 20 | 21 | 22 | double __exp10(double x) 23 | { 24 | double z = __ieee754_exp10(x); 25 | 26 | if (!isfinite(z) && isfinite(x) && _LIB_VERSION != _IEEE_) 27 | /* exp10 overflow (46) if x > 0, underflow (47) if x < 0. */ 28 | return __kernel_standard(x, x, z, signbit(x) ? KMATHERR_EXP10_UNDERFLOW : KMATHERR_EXP10_OVERFLOW); 29 | 30 | return z; 31 | } 32 | 33 | 34 | 35 | __typeof(__exp10) exp10 __attribute__((weak, alias("__exp10"))); 36 | __typeof(__exp10) __pow10 __attribute__((alias("__exp10"))); 37 | __typeof(__pow10) pow10 __attribute__((weak, alias("__pow10"))); 38 | #ifdef __NO_LONG_DOUBLE_MATH 39 | __typeof(__exp10l) __exp10l __attribute__((alias("__exp10"))); 40 | __typeof(__exp10l) exp10l __attribute__((weak, alias("__exp10l"))); 41 | __typeof(__pow10l) __pow10l __attribute__((alias("__pow10"))); 42 | __typeof(__pow10l) pow10l __attribute__((weak, alias("__pow10l"))); 43 | #endif 44 | -------------------------------------------------------------------------------- /s_floorf.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __have_fpu_floor 6 | 7 | float __ieee754_floorf(float x) 8 | { 9 | int32_t i0, j0; 10 | uint32_t i; 11 | 12 | static const float hugeval = 1.0e30; 13 | 14 | GET_FLOAT_WORD(i0, x); 15 | j0 = ((i0 >> IEEE754_FLOAT_SHIFT) & IEEE754_FLOAT_MAXEXP) - IEEE754_FLOAT_BIAS; 16 | if (j0 < IEEE754_FLOAT_SHIFT) 17 | { 18 | if (j0 < 0) 19 | { /* raise inexact if x != 0 */ 20 | math_force_eval(hugeval + x); /* return 0*sign(x) if |x|<1 */ 21 | if (i0 >= 0) 22 | { 23 | i0 = 0; 24 | } else if ((i0 & UC(0x7fffffff)) != 0) 25 | { 26 | i0 = UC(0xbf800000); 27 | } 28 | } else 29 | { 30 | i = UC(0x007fffff) >> j0; 31 | if ((i0 & i) == 0) 32 | return x; /* x is integral */ 33 | math_force_eval(hugeval + x); /* raise inexact flag */ 34 | if (i0 < 0) 35 | i0 += UC(0x00800000) >> j0; 36 | i0 &= (~i); 37 | } 38 | } else 39 | { 40 | if (j0 == (IEEE754_FLOAT_MAXEXP - IEEE754_FLOAT_BIAS)) 41 | return x + x; /* inf or NaN */ 42 | else 43 | return x; /* x is integral */ 44 | } 45 | SET_FLOAT_WORD(x, i0); 46 | return x; 47 | } 48 | 49 | #endif 50 | 51 | float __floorf(float x) 52 | { 53 | return __ieee754_floorf(x); 54 | } 55 | 56 | __typeof(__floorf) floorf __attribute__((weak, alias("__floorf"))); 57 | -------------------------------------------------------------------------------- /fegetexcept.c: -------------------------------------------------------------------------------- 1 | /* Get enabled floating-point exceptions. 2 | Copyright (C) 2000-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Andreas Schwab , 2000. 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library. If not, see 18 | . */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | #include "fpu_ctrl.h" 24 | 25 | int __fegetexcept(void) 26 | { 27 | fpu_control_t exc; 28 | 29 | /* Get the current control register contents. */ 30 | _FPU_GETCW(exc); 31 | 32 | return (int)((exc >> 6) & FE_ALL_EXCEPT); 33 | } 34 | 35 | __typeof(__fegetexcept) fegetexcept __attribute__((weak, alias("__fegetexcept"))); 36 | -------------------------------------------------------------------------------- /s_fdimf.c: -------------------------------------------------------------------------------- 1 | /* Return positive difference between arguments. 2 | Copyright (C) 1997-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Ulrich Drepper , 1997. 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library; if not, see 18 | . */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | 24 | float __fdimf(float x, float y) 25 | { 26 | float r; 27 | 28 | if (islessequal(x, y)) 29 | return 0.0f; 30 | 31 | r = x - y; 32 | 33 | if (isinf(r) && !isinf(x) && !isinf(y)) 34 | __set_errno(ERANGE); 35 | 36 | return r; 37 | } 38 | 39 | __typeof(__fdimf) fdimf __attribute__((weak, alias("__fdimf"))); 40 | -------------------------------------------------------------------------------- /fetestexcept.c: -------------------------------------------------------------------------------- 1 | /* Test exception in current environment. 2 | Copyright (C) 1997-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Andreas Schwab 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library. If not, see 18 | . */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | #include "fpu_ctrl.h" 24 | 25 | int __fetestexcept(int excepts) 26 | { 27 | fexcept_t fpsr; 28 | 29 | /* Get current exceptions. */ 30 | _FPU_GETSR(fpsr); 31 | 32 | return (int)(fpsr & excepts & FE_ALL_EXCEPT); 33 | } 34 | 35 | __typeof(__fetestexcept) fetestexcept __attribute__((weak, alias("__fetestexcept"))); 36 | -------------------------------------------------------------------------------- /s_fdiml.c: -------------------------------------------------------------------------------- 1 | /* Return positive difference between arguments. 2 | Copyright (C) 1997-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Ulrich Drepper , 1997. 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library; if not, see 18 | . */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | 24 | #ifndef __NO_LONG_DOUBLE_MATH 25 | long double __fdiml(long double x, long double y) 26 | { 27 | long double r; 28 | 29 | if (islessequal(x, y)) 30 | return 0.0L; 31 | 32 | r = x - y; 33 | 34 | if (isinf(r) && !isinf(x) && !isinf(y)) 35 | __set_errno(ERANGE); 36 | 37 | return r; 38 | } 39 | 40 | __typeof(__fdiml) fdiml __attribute__((weak, alias("__fdiml"))); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /s_issig.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #undef issignaling 6 | 7 | int __issignaling(double x) 8 | { 9 | #ifdef HIGH_ORDER_BIT_IS_SET_FOR_SNAN 10 | uint32_t hxi; 11 | 12 | GET_HIGH_WORD(hxi, x); 13 | /* We only have to care about the high-order bit of x's significand, because 14 | having it set (sNaN) already makes the significand different from that 15 | used to designate infinity. */ 16 | return (hxi & UC(0x7ff80000)) == UC(0x7ff80000); 17 | #else 18 | uint32_t hxi, lxi; 19 | 20 | GET_DOUBLE_WORDS(hxi, lxi, x); 21 | /* To keep the following comparison simple, toggle the quiet/signaling bit, 22 | so that it is set for sNaNs. This is inverse to IEEE 754-2008 (as well as 23 | common practice for IEEE 754-1985). */ 24 | hxi ^= UC(0x00080000); 25 | /* If lxi != 0, then set any suitable bit of the significand in hxi. */ 26 | hxi |= (lxi | -lxi) >> 31; 27 | /* We have to compare for greater (instead of greater or equal), because x's 28 | significand being all-zero designates infinity not NaN. */ 29 | return (hxi & UC(0x7fffffff)) > UC(0x7ff80000); 30 | #endif 31 | } 32 | 33 | __typeof(__issignaling) issignaling __attribute__((weak, alias("__issignaling"))); 34 | #ifdef __NO_LONG_DOUBLE_MATH 35 | int __issignalingl(long double x) __attribute__((alias("__issignaling"))); 36 | __typeof(__issignalingl) issignalingl __attribute__((weak, alias("__issignaling"))); 37 | #endif 38 | -------------------------------------------------------------------------------- /.scripts/setup_env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Use as: ". setup_env.sh" 3 | 4 | PROJECT_REPO=$(echo "${GITHUB_REPOSITORY}" | cut -d '/' -f 1) 5 | echo "PROJECT_REPO=${PROJECT_REPO}" >> $GITHUB_ENV 6 | PROJECT_NAME=$(echo "${GITHUB_REPOSITORY}" | cut -d '/' -f 2) 7 | echo "PROJECT_NAME=${PROJECT_NAME}" >> $GITHUB_ENV 8 | # PROJECT_VERSION is defined in the action script 9 | echo "PROJECT_VERSION=${PROJECT_VERSION}" >> $GITHUB_ENV 10 | INSTALL_DIR="/tmp/${PROJECT_NAME}" 11 | echo "INSTALL_DIR=${INSTALL_DIR}" >> $GITHUB_ENV 12 | DEPLOY_DIR="/tmp/${PROJECT_NAME}-deploy" 13 | echo "DEPLOY_DIR=${DEPLOY_DIR}" >> $GITHUB_ENV 14 | DEPLOY_ARCHIVE="tar.bz2" 15 | echo "DEPLOY_ARCHIVE=${DEPLOY_ARCHIVE}" >> $GITHUB_ENV 16 | 17 | SHORT_ID=$(echo ${GITHUB_SHA} | cut -c 1-3) 18 | echo "SHORT_ID=$SHORT_ID" >> $GITHUB_ENV 19 | LONG_ID=$(echo ${GITHUB_SHA} | cut -c 1-8) 20 | echo "LONG_ID=$LONG_ID" >> $GITHUB_ENV 21 | BRANCH=$(echo "${GITHUB_REF}" | cut -d '/' -f 3) 22 | 23 | if test "$CPU_TARGET" != ""; then 24 | echo "CPU_TARGET=$CPU_TARGET" >> $GITHUB_ENV 25 | fi 26 | CROSS_TOOL=${CROSS_TOOL:-m68k-atari-mint} 27 | echo "CROSS_TOOL=$CROSS_TOOL" >> $GITHUB_ENV 28 | 29 | # GITHUB_HEAD_REF is only set for pull requests 30 | if [ "${GITHUB_HEAD_REF}" = "" ] 31 | then 32 | COMMIT_MESSAGE="[${PROJECT_NAME}] [${BRANCH}] Commit: https://github.com/${PROJECT_REPO}/${PROJECT_NAME}/commit/${GITHUB_SHA}" 33 | fi 34 | 35 | echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_ENV 36 | -------------------------------------------------------------------------------- /fegetexceptflag.c: -------------------------------------------------------------------------------- 1 | /* Store current representation for exceptions. 2 | Copyright (C) 1997-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Andreas Schwab 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library. If not, see 18 | . */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | #include "fpu_ctrl.h" 24 | 25 | int __fegetexceptflag(fexcept_t *flagp, int excepts) 26 | { 27 | fexcept_t fpsr; 28 | 29 | /* Get the current exceptions. */ 30 | _FPU_GETSR(fpsr); 31 | 32 | *flagp = fpsr & excepts & FE_ALL_EXCEPT; 33 | 34 | /* Success. */ 35 | return 0; 36 | } 37 | 38 | __typeof(__fegetexceptflag) fegetexceptflag __attribute__((weak, alias("__fegetexceptflag"))); 39 | -------------------------------------------------------------------------------- /s_fmax.c: -------------------------------------------------------------------------------- 1 | /* Return maximum numeric value of X and Y. 2 | Copyright (C) 1997 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Ulrich Drepper , 1997. 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library; if not, write to the Free 18 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 19 | 02111-1307 USA. */ 20 | 21 | #ifndef __FDLIBM_H__ 22 | #include "fdlibm.h" 23 | #endif 24 | 25 | double __fmax(double x, double y) 26 | { 27 | return (isgreaterequal (x, y) || isnan (y)) ? x : y; 28 | } 29 | 30 | __typeof(__fmax) fmax __attribute__((weak, alias("__fmax"))); 31 | #ifdef __NO_LONG_DOUBLE_MATH 32 | __typeof(fmaxl) __fmaxl __attribute__((alias("__fmax"))); 33 | __typeof(__fmaxl) fmaxl __attribute__((weak, alias("__fmax"))); 34 | #endif 35 | -------------------------------------------------------------------------------- /s_fmin.c: -------------------------------------------------------------------------------- 1 | /* Return minimum numeric value of X and Y. 2 | Copyright (C) 1997 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Ulrich Drepper , 1997. 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library; if not, write to the Free 18 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 19 | 02111-1307 USA. */ 20 | 21 | #ifndef __FDLIBM_H__ 22 | #include "fdlibm.h" 23 | #endif 24 | 25 | double __fmin(double x, double y) 26 | { 27 | return (islessequal (x, y) || isnan (y)) ? x : y; 28 | } 29 | 30 | __typeof(__fmin) fmin __attribute__((weak, alias("__fmin"))); 31 | #ifdef __NO_LONG_DOUBLE_MATH 32 | __typeof(fminl) __fminl __attribute__((alias("__fmin"))); 33 | __typeof(__fminl) fminl __attribute__((weak, alias("__fmin"))); 34 | #endif 35 | -------------------------------------------------------------------------------- /w_tgammaf.c: -------------------------------------------------------------------------------- 1 | /* w_gammaf.c -- float version of w_gamma.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 | #ifndef __FDLIBM_H__ 17 | #include "fdlibm.h" 18 | #endif 19 | 20 | float __tgammaf(float x) 21 | { 22 | int local_signgam; 23 | float y = __ieee754_tgammaf_r(x, &local_signgam); 24 | 25 | if (!isfinite(y) && (isfinite(x) || isinf(x) < 0) && _LIB_VERSION != _IEEE_) 26 | { 27 | if (x == 0.0F) 28 | return __kernel_standard_f(x, x, y, KMATHERRF_TGAMMA_ZERO); /* tgammaf pole */ 29 | else if (__ieee754_floorf(x) == x && x < 0.0f) 30 | return __kernel_standard_f(x, x, y, KMATHERRF_TGAMMA_MINUS); /* tgammaf domain */ 31 | else if (y == 0) 32 | return __kernel_standard_f(x, x, y, KMATHERRF_TGAMMA_UNDERFLOW); /* tgamma underflow */ 33 | else 34 | return __kernel_standard_f(x, x, y, KMATHERRF_TGAMMA_OVERFLOW); /* tgammaf overflow */ 35 | } 36 | return local_signgam < 0 ? -y : y; 37 | } 38 | 39 | __typeof(__tgammaf) tgammaf __attribute__((weak, alias("__tgammaf"))); 40 | -------------------------------------------------------------------------------- /feenableexcept.c: -------------------------------------------------------------------------------- 1 | /* Enable floating-point exceptions. 2 | Copyright (C) 2000-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Andreas Schwab , 2000. 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library. If not, see 18 | . */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | #include "fpu_ctrl.h" 24 | 25 | int __feenableexcept(int excepts) 26 | { 27 | fpu_control_t new_exc, old_exc; 28 | 29 | /* Get the current control register contents. */ 30 | _FPU_GETCW(new_exc); 31 | 32 | old_exc = (new_exc >> 6) & FE_ALL_EXCEPT; 33 | 34 | excepts &= FE_ALL_EXCEPT; 35 | 36 | new_exc |= excepts << 6; 37 | _FPU_SETCW(new_exc); 38 | 39 | return (int)old_exc; 40 | } 41 | 42 | __typeof(__feenableexcept) feenableexcept __attribute__((weak, alias("__feenableexcept"))); 43 | -------------------------------------------------------------------------------- /fedisableexcept.c: -------------------------------------------------------------------------------- 1 | /* Disable floating-point exceptions. 2 | Copyright (C) 2000-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Andreas Schwab , 2000. 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library. If not, see 18 | . */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | #include "fpu_ctrl.h" 24 | 25 | int __fedisableexcept(int excepts) 26 | { 27 | fpu_control_t old_exc, new_exc; 28 | 29 | /* Get the current control register contents. */ 30 | _FPU_GETCW(new_exc); 31 | 32 | old_exc = (new_exc >> 6) & FE_ALL_EXCEPT; 33 | 34 | excepts &= FE_ALL_EXCEPT; 35 | 36 | new_exc &= ~(excepts << 6); 37 | _FPU_SETCW(new_exc); 38 | 39 | return (int)old_exc; 40 | } 41 | 42 | __typeof(__fedisableexcept) fedisableexcept __attribute__((weak, alias("__fedisableexcept"))); 43 | -------------------------------------------------------------------------------- /s_fdim.c: -------------------------------------------------------------------------------- 1 | /* Return positive difference between arguments. 2 | Copyright (C) 1997-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Ulrich Drepper , 1997. 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library; if not, see 18 | . */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | 24 | double __fdim(double x, double y) 25 | { 26 | double r; 27 | 28 | if (islessequal(x, y)) 29 | return 0.0; 30 | 31 | r = x - y; 32 | 33 | if (isinf(r) && !isinf(x) && !isinf(y)) 34 | __set_errno(ERANGE); 35 | 36 | return r; 37 | } 38 | 39 | __typeof(__fdim) fdim __attribute__((weak, alias("__fdim"))); 40 | #ifdef __NO_LONG_DOUBLE_MATH 41 | __typeof(fdiml) __fdiml __attribute__((alias("__fdim"))); 42 | __typeof(__fdiml) fdiml __attribute__((weak, alias("__fdim"))); 43 | #endif 44 | -------------------------------------------------------------------------------- /s_tanf.c: -------------------------------------------------------------------------------- 1 | /* s_tanf.c -- float version of s_tan.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 | #ifndef __FDLIBM_H__ 17 | #include "fdlibm.h" 18 | #endif 19 | 20 | #ifndef __have_fpu_tan 21 | 22 | float __ieee754_tanf(float x) 23 | { 24 | float y[2], z = 0.0; 25 | int32_t n, ix; 26 | 27 | GET_FLOAT_WORD(ix, x); 28 | 29 | /* |x| ~< pi/4 */ 30 | ix &= IC(0x7fffffff); 31 | if (ix <= IC(0x3f490fda)) 32 | return __kernel_tanf(x, z, 1); 33 | 34 | /* tan(Inf or NaN) is NaN */ 35 | else if (!FLT_UWORD_IS_FINITE(ix)) 36 | return x - x; /* NaN */ 37 | 38 | /* argument reduction needed */ 39 | else 40 | { 41 | n = __ieee754_rem_pio2f(x, y); 42 | return __kernel_tanf(y[0], y[1], (int)(1 - ((n & 1) << 1))); /* 1 -- n even -1 -- n odd */ 43 | } 44 | } 45 | 46 | #endif 47 | 48 | float __tanf(float x) 49 | { 50 | float ret; 51 | 52 | ret = __ieee754_tan(x); 53 | if (isnan(ret) && isinf(x)) 54 | ret = __kernel_standard_f(x, x, ret, KMATHERRF_TAN_INF); 55 | return ret; 56 | } 57 | 58 | __typeof(__tanf) tanf __attribute__((weak, alias("__tanf"))); 59 | -------------------------------------------------------------------------------- /fegetenv.c: -------------------------------------------------------------------------------- 1 | /* Store current floating-point environment. 2 | Copyright (C) 1997-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Andreas Schwab 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library. If not, see 18 | . */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | #include "fpu_ctrl.h" 24 | 25 | int __fegetenv(fenv_t *envp) 26 | { 27 | #if defined(__GNUC__) && defined(__HAVE_68881__) && !defined(__mcoldfire__) 28 | __asm__("fmovem%.l %/fpcr/%/fpsr/%/fpiar,%0":"=m"(*envp)); 29 | #else 30 | _FPU_GETCW(envp->__control_register); 31 | _FPU_GETSR(envp->__status_register); 32 | _FPU_GETIAR(envp->__instruction_address); 33 | #endif 34 | 35 | /* Success. */ 36 | return 0; 37 | } 38 | 39 | __typeof(__fegetenv) fegetenv __attribute__((weak, alias("__fegetenv"))); 40 | -------------------------------------------------------------------------------- /s_logb.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_logb.c 1.3 95/01/18 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | /* 14 | * double logb(x) 15 | * IEEE 754 logb. Included to pass IEEE test suite. Not recommend. 16 | * Use ilogb instead. 17 | */ 18 | 19 | #ifndef __FDLIBM_H__ 20 | #include "fdlibm.h" 21 | #endif 22 | 23 | 24 | double __logb(double x) 25 | { 26 | int32_t lx, ix, rix; 27 | 28 | GET_DOUBLE_WORDS(ix, lx, x); 29 | ix &= IC(0x7fffffff); /* high |x| */ 30 | if ((ix | lx) == 0) 31 | return -1.0 / __ieee754_fabs(x); 32 | if (ix >= IC(0x7ff00000)) 33 | return x * x; 34 | if ((rix = ix >> IEEE754_DOUBLE_SHIFT) == 0) 35 | { 36 | /* POSIX specifies that denormal number is treated as 37 | though it were normalized. */ 38 | int32_t ma; 39 | 40 | if (ix == 0) 41 | ma = count_leading_zeros(lx) + 32; 42 | else 43 | ma = count_leading_zeros(ix); 44 | rix -= ma - 12; 45 | } 46 | return (double) (rix - IEEE754_DOUBLE_BIAS); 47 | } 48 | 49 | __typeof(__logb) logb __attribute__((weak, alias("__logb"))); 50 | #ifdef __NO_LONG_DOUBLE_MATH 51 | __typeof(__logbl) __logbl __attribute__((alias("__logb"))); 52 | __typeof(__logbl) logbl __attribute__((weak, alias("__logb"))); 53 | #endif 54 | -------------------------------------------------------------------------------- /feclearexcept.c: -------------------------------------------------------------------------------- 1 | /* Clear given exceptions in current floating-point environment. 2 | Copyright (C) 1997-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Ulrich Drepper , 1997. 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library; if not, see 18 | . */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | #include "fpu_ctrl.h" 24 | 25 | int __feclearexcept(int excepts) 26 | { 27 | fexcept_t fpsr; 28 | 29 | /* Mask out unsupported bits/exceptions. */ 30 | excepts &= FE_ALL_EXCEPT; 31 | 32 | /* Fetch the fpu status register. */ 33 | _FPU_GETSR(fpsr); 34 | 35 | /* Clear the relevant bits. */ 36 | fpsr &= ~excepts; 37 | 38 | /* Put the new data in effect. */ 39 | _FPU_SETSR(fpsr); 40 | 41 | /* Success. */ 42 | return 0; 43 | } 44 | 45 | __typeof(__feclearexcept) feclearexcept __attribute__((weak, alias("__feclearexcept"))); 46 | -------------------------------------------------------------------------------- /e_fmodl.c: -------------------------------------------------------------------------------- 1 | /* e_fmodl.c -- long double version of e_fmod.c. 2 | * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz. 3 | */ 4 | /* 5 | * ==================================================== 6 | * Copyright (C) 1993, 2011 by Sun Microsystems, Inc. All rights reserved. 7 | * 8 | * Developed at SunPro, a Sun Microsystems, Inc. business. 9 | * Permission to use, copy, modify, and distribute this 10 | * software is freely granted, provided that this notice 11 | * is preserved. 12 | * ==================================================== 13 | */ 14 | 15 | /* 16 | * __ieee754_fmodl(x,y) 17 | * Return x mod y in exact arithmetic 18 | * Method: shift and subtract 19 | */ 20 | 21 | #ifndef __FDLIBM_H__ 22 | #include "fdlibm.h" 23 | #endif 24 | 25 | #ifndef __NO_LONG_DOUBLE_MATH 26 | 27 | #ifndef __have_fpu_fmod 28 | 29 | long double __ieee754_fmodl(long double x, long double y) 30 | { 31 | long double intpart; 32 | 33 | if (isinf(y)) 34 | { 35 | if (isinf(x)) 36 | return x < 0 ? -0.0L : 0.0L; 37 | return x; 38 | } 39 | if (__ieee754_fabsl(x) <= __ieee754_fabsl(y)) 40 | return x; 41 | (void) __ieee754_modfl(x / y, &intpart); 42 | return x - y * intpart; 43 | } 44 | 45 | #endif 46 | 47 | long double __fmodl(long double x, long double y) 48 | { 49 | if ((isinf(x) || y == 0.0) && _LIB_VERSION != _IEEE_ && !isunordered(x, y)) 50 | /* fmod(+-Inf,y) or fmod(x,0) */ 51 | return __kernel_standard_l(x, y, y, KMATHERRL_FMOD); 52 | return __ieee754_fmodl(x, y); 53 | } 54 | 55 | __typeof(__fmodl) fmodl __attribute__((weak, alias("__fmodl"))); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /s_sincosf.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __have_fpu_sincos 6 | 7 | void __ieee754_sincosf(float x, float *sinx, float *cosx) 8 | { 9 | *sinx = sinf(x); 10 | *cosx = cosf(x); 11 | } 12 | 13 | #endif 14 | 15 | void __sincosf(float x, float *sinx, float *cosx) 16 | { 17 | int32_t ix; 18 | 19 | /* High word of x. */ 20 | GET_FLOAT_WORD(ix, x); 21 | 22 | /* |x| ~< pi/4 */ 23 | ix &= IC(0x7fffffff); 24 | if (ix <= IC(0x3f490fd8)) 25 | { 26 | #ifdef __have_fpu_sincos 27 | __ieee754_sincosf(x, sinx, cosx); 28 | #else 29 | *sinx = __kernel_sinf(x, 0.0, 0); 30 | *cosx = __kernel_cosf(x, 0.0); 31 | #endif 32 | } else if (ix >= IC(0x7f800000)) 33 | { 34 | /* sin(Inf or NaN) is NaN */ 35 | *sinx = *cosx = x - x; 36 | } else 37 | { 38 | #ifdef __have_fpu_sincos 39 | __ieee754_sincosf(x, sinx, cosx); 40 | #else 41 | /* Argument reduction needed. */ 42 | float y[2]; 43 | int32_t n; 44 | 45 | n = __ieee754_rem_pio2f(x, y); 46 | switch ((int)(n & 3)) 47 | { 48 | case 0: 49 | *sinx = __kernel_sinf(y[0], y[1], 1); 50 | *cosx = __kernel_cosf(y[0], y[1]); 51 | break; 52 | case 1: 53 | *sinx = __kernel_cosf(y[0], y[1]); 54 | *cosx = -__kernel_sinf(y[0], y[1], 1); 55 | break; 56 | case 2: 57 | *sinx = -__kernel_sinf(y[0], y[1], 1); 58 | *cosx = -__kernel_cosf(y[0], y[1]); 59 | break; 60 | default: 61 | *sinx = -__kernel_cosf(y[0], y[1]); 62 | *cosx = __kernel_sinf(y[0], y[1], 1); 63 | break; 64 | } 65 | #endif 66 | } 67 | } 68 | 69 | __typeof(__sincosf) sincosf __attribute__((weak, alias("__sincosf"))); 70 | -------------------------------------------------------------------------------- /s_logbl.c: -------------------------------------------------------------------------------- 1 | /* s_logbl.c -- long double version of s_logb.c. 2 | * Conversion to long double by Ulrich Drepper, 3 | * Cygnus Support, drepper@cygnus.com. 4 | */ 5 | 6 | /* 7 | * ==================================================== 8 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 9 | * 10 | * Developed at SunPro, a Sun Microsystems, Inc. business. 11 | * Permission to use, copy, modify, and distribute this 12 | * software is freely granted, provided that this notice 13 | * is preserved. 14 | * ==================================================== 15 | */ 16 | 17 | /* 18 | * long double logbl(x) 19 | * IEEE 754 logb. Included to pass IEEE test suite. Not recommend. 20 | * Use ilogb instead. 21 | */ 22 | 23 | #ifndef __FDLIBM_H__ 24 | #include "fdlibm.h" 25 | #endif 26 | 27 | #ifndef __NO_LONG_DOUBLE_MATH 28 | 29 | long double __logbl(long double x) 30 | { 31 | int32_t es, lx, ix; 32 | 33 | GET_LDOUBLE_WORDS(es, ix, lx, x); 34 | es &= IEEE854_LONG_DOUBLE_MAXEXP; /* exponent */ 35 | if ((es | ix | lx) == 0) 36 | return -1.0 / __ieee754_fabsl(x); 37 | if (es == IEEE854_LONG_DOUBLE_MAXEXP) 38 | return x * x; 39 | if (es == 0) /* IEEE 754 logb */ 40 | { 41 | /* POSIX specifies that denormal number is treated as 42 | though it were normalized. */ 43 | int32_t ma; 44 | 45 | if (ix == 0) 46 | ma = count_leading_zeros(lx) + 32; 47 | else 48 | ma = count_leading_zeros(ix); 49 | es -= ma - 1; 50 | } 51 | return (long double) (es - IEEE854_LONG_DOUBLE_BIAS); 52 | } 53 | 54 | __typeof(__logbl) logbl __attribute__((weak, alias("__logbl"))); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /.scripts/install_ssh_id.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | # -e: Exit immediately if a command exits with a non-zero status. 3 | # -u: Treat unset variables as an error when substituting. 4 | 5 | # This installs an SSH private/public key pair on the build system, 6 | # so ssh can connect to remote servers without password. 7 | # Important: for passwordless connection to succeed, our public key must be 8 | # manually authorized on the remote server. 9 | 10 | # Our private key is the critical security component, it must remain secret. 11 | # We store it in the SSH_ID environment variable in Travis CI project settings. 12 | # As environment variables can only contain text, our key files are transformed 13 | # like this: tar, xz, base64. Then then can be decoded here. This is safe as 14 | # Travis CI never shows the contents of secure variables. 15 | 16 | # To generate the contents of the SSH_ID variable: 17 | # Be sure to be in an empty, temporary directory. 18 | # 19 | # mkdir .ssh 20 | # ssh-keygen -t rsa -b 4096 -C travis-ci.org/$USER/$PROJECT -N '' -f .ssh/id_rsa 21 | # tar Jcvf id.tar.xz .ssh 22 | # base64 -w 0 id.tar.xz 23 | # 24 | # Select the resulting encoded text (several lines) to copy it to the clipboard. 25 | # Then go to the Travis CI project settings: 26 | # https://travis-ci.org/$USER/$PROJECT/settings 27 | # Create a new environment variable named SSH_ID, and paste the value. 28 | # The script below will recreate the key files from that variable contents. 29 | 30 | if [ -z ${SSH_ID+x} ] 31 | then 32 | echo "error: SSH_ID is undefined" >&2 33 | exit 1 34 | fi 35 | 36 | echo $SSH_ID | base64 -d | tar -C ~ -Jx 37 | 38 | ls -l ~/.ssh 39 | -------------------------------------------------------------------------------- /feholdexcept.c: -------------------------------------------------------------------------------- 1 | /* Store current floating-point environment and clear exceptions. 2 | Copyright (C) 1997-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Andreas Schwab 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library. If not, see 18 | . */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | #include "fpu_ctrl.h" 24 | 25 | int __feholdexcept(fenv_t *envp) 26 | { 27 | fpu_control_t fpcr; 28 | fexcept_t fpsr; 29 | 30 | /* Store the environment. */ 31 | fegetenv(envp); 32 | 33 | /* Now clear all exceptions. */ 34 | fpsr = envp->__status_register & ~FE_ALL_EXCEPT; 35 | _FPU_SETSR(fpsr); 36 | /* And set all exceptions to non-stop. */ 37 | fpcr = envp->__control_register & ~(FE_ALL_EXCEPT << 6); 38 | _FPU_SETCW(fpcr); 39 | 40 | return 0; 41 | } 42 | 43 | __typeof(__feholdexcept) feholdexcept __attribute__((weak, alias("__feholdexcept"))); 44 | -------------------------------------------------------------------------------- /w_tgammal.c: -------------------------------------------------------------------------------- 1 | /* w_gammal.c -- long double version of w_gamma.c. 2 | * Conversion to long double by Ulrich Drepper, 3 | * Cygnus Support, drepper@cygnus.com. 4 | */ 5 | 6 | /* 7 | * ==================================================== 8 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 9 | * 10 | * Developed at SunPro, a Sun Microsystems, Inc. business. 11 | * Permission to use, copy, modify, and distribute this 12 | * software is freely granted, provided that this notice 13 | * is preserved. 14 | * ==================================================== 15 | */ 16 | 17 | /* long double gammal(double x) 18 | * Return the Gamma function of x. 19 | */ 20 | 21 | #ifndef __FDLIBM_H__ 22 | #include "fdlibm.h" 23 | #endif 24 | 25 | #ifndef __NO_LONG_DOUBLE_MATH 26 | 27 | long double __tgammal(long double x) 28 | { 29 | int local_signgam; 30 | long double y = __ieee754_tgammal_r(x, &local_signgam); 31 | 32 | if (!isfinite(y) && (isfinite(x) || isinf(x) < 0) && _LIB_VERSION != _IEEE_) 33 | { 34 | if (x == 0.0) 35 | return __kernel_standard_l(x, x, y, KMATHERRL_TGAMMA_ZERO); /* tgamma pole */ 36 | else if (__ieee754_floorl(x) == x && x < 0.0L) 37 | return __kernel_standard_l(x, x, y, KMATHERRL_TGAMMA_MINUS); /* tgamma domain */ 38 | else if (y == 0) 39 | return __kernel_standard_l(x, x, y, KMATHERRL_TGAMMA_UNDERFLOW); /* tgamma underflow */ 40 | else 41 | return __kernel_standard_l(x, x, y, KMATHERRL_TGAMMA_OVERFLOW); /* tgamma overflow */ 42 | } 43 | return local_signgam < 0 ? -y : y; 44 | } 45 | 46 | __typeof(__tgammal) tgammal __attribute__((weak, alias("__tgammal"))); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /truncxfdf2.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | /* 6 | * we cannot replace that single function, because it is 7 | * not compiled separately in libgcc.a and leads 8 | * to duplicate definition errors :( 9 | */ 10 | #if 0 11 | 12 | #ifndef __NO_LONG_DOUBLE_MATH 13 | 14 | #define EXPDBITS 11 15 | #define MANTXMASK IC(0x7fffffff) 16 | 17 | double __truncxfdf2(long double ld); 18 | 19 | /* convert long double to double */ 20 | double __truncxfdf2(long double ld) 21 | { 22 | int32_t exp; 23 | ieee_double_shape_type dl; 24 | ieee_long_double_shape_type ldl; 25 | 26 | ldl.value = ld; 27 | 28 | exp = ldl.parts.sign_exponent & IEEE854_LONG_DOUBLE_MAXEXP; 29 | dl.parts.msw = (int32_t)(ldl.parts.sign_exponent & 0x8000) << 16; 30 | if (exp == 0 && 31 | (ldl.parts.msw & MANTXMASK) == 0 && 32 | ldl.parts.lsw == 0) 33 | { 34 | dl.parts.lsw = 0; 35 | } else 36 | { 37 | if (exp == IEEE854_LONG_DOUBLE_MAXEXP) 38 | { 39 | exp = IEEE754_DOUBLE_MAXEXP; 40 | } else 41 | { 42 | exp = exp - IEEE854_LONG_DOUBLE_BIAS + IEEE754_DOUBLE_BIAS; 43 | /* ??? quick and dirty: keep `exp' sane */ 44 | if (exp >= IEEE754_DOUBLE_MAXEXP) 45 | exp = IEEE754_DOUBLE_MAXEXP - 1; 46 | } 47 | dl.parts.msw |= exp << (32 - (EXPDBITS + 1)); 48 | /* +1-1: add one for sign bit, but take one off for explicit-integer-bit */ 49 | dl.parts.msw |= (ldl.parts.msw & MANTXMASK) >> (EXPDBITS + 1 - 1); 50 | dl.parts.lsw = (ldl.parts.msw & MANTXMASK) << (32 - (EXPDBITS + 1 - 1)); 51 | dl.parts.lsw |= ldl.parts.lsw >> (EXPDBITS + 1 - 1); 52 | } 53 | 54 | return dl.value; 55 | } 56 | 57 | #endif 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /fesetexceptflag.c: -------------------------------------------------------------------------------- 1 | /* Set floating-point environment exception handling. 2 | Copyright (C) 1997-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Andreas Schwab 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library. If not, see 18 | . */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | #include "fpu_ctrl.h" 24 | 25 | int __fesetexceptflag(const fexcept_t *flagp, int excepts) 26 | { 27 | fexcept_t fpsr; 28 | 29 | /* Get the current status register. */ 30 | _FPU_GETSR(fpsr); 31 | 32 | /* Install the new exception bits in the Accrued Exception Byte. */ 33 | fpsr &= ~(excepts & FE_ALL_EXCEPT); 34 | fpsr |= *flagp & excepts & FE_ALL_EXCEPT; 35 | 36 | /* Store the new status register. */ 37 | _FPU_SETSR(fpsr); 38 | 39 | /* Success. */ 40 | return 0; 41 | } 42 | 43 | __typeof(__fesetexceptflag) fesetexceptflag __attribute__((weak, alias("__fesetexceptflag"))); 44 | -------------------------------------------------------------------------------- /k_sinf.c: -------------------------------------------------------------------------------- 1 | /* k_sinf.c -- float version of k_sin.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 | #ifndef __FDLIBM_H__ 17 | #include "fdlibm.h" 18 | #endif 19 | 20 | 21 | float __kernel_sinf(float x, float y, int iy) 22 | { 23 | float z, r, v; 24 | int32_t ix; 25 | 26 | static const float half = 5.0000000000e-01; /* 0x3f000000 */ 27 | static const float S1 = -1.6666667163e-01; /* 0xbe2aaaab */ 28 | static const float S2 = 8.3333337680e-03; /* 0x3c088889 */ 29 | static const float S3 = -1.9841270114e-04; /* 0xb9500d01 */ 30 | static const float S4 = 2.7557314297e-06; /* 0x3638ef1b */ 31 | static const float S5 = -2.5050759689e-08; /* 0xb2d72f34 */ 32 | static const float S6 = 1.5896910177e-10; /* 0x2f2ec9d3 */ 33 | 34 | GET_FLOAT_WORD(ix, x); 35 | ix &= IC(0x7fffffff); /* high word of x */ 36 | if (ix < IC(0x32000000)) /* |x| < 2**-27 */ 37 | { 38 | if ((int32_t) x == 0) 39 | return x; 40 | } /* generate inexact */ 41 | z = x * x; 42 | v = z * x; 43 | r = S2 + z * (S3 + z * (S4 + z * (S5 + z * S6))); 44 | if (iy == 0) 45 | return x + v * (S1 + z * r); 46 | else 47 | return x - ((z * (half * y - v * r) - y) - v * S1); 48 | } 49 | -------------------------------------------------------------------------------- /e_ilogbf.c: -------------------------------------------------------------------------------- 1 | /* s_ilogbf.c -- float version of s_ilogb.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 | #ifndef __FDLIBM_H__ 17 | #include "fdlibm.h" 18 | #endif 19 | 20 | #ifndef __have_fpu_ilogb 21 | 22 | int __ieee754_ilogbf(float x) 23 | { 24 | int32_t hx, ix; 25 | 26 | GET_FLOAT_WORD(hx, x); 27 | hx &= IC(0x7fffffff); 28 | if (hx < IC(0x00800000)) 29 | { 30 | if (hx == 0) 31 | return FP_ILOGB0; /* ilogb(0) = FP_ILOGB0 */ 32 | /* subnormal x */ 33 | for (ix = -126, hx <<= 8; hx > 0; hx <<= 1) 34 | ix -= 1; 35 | return (int)ix; 36 | } 37 | if (hx < IC(0x7f800000)) 38 | return (int)((hx >> IEEE754_FLOAT_SHIFT) - IEEE754_FLOAT_BIAS); 39 | #if FP_ILOGBNAN != INT_MAX 40 | /* ISO C99 requires ilogbf(+-Inf) == INT_MAX. */ 41 | if (hx == IC(0x7f800000)) 42 | return INT_MAX; 43 | #endif 44 | return FP_ILOGBNAN; 45 | } 46 | 47 | #endif 48 | 49 | /* wrapper ilogbf */ 50 | int __ilogbf(float x) 51 | { 52 | int r = __ieee754_ilogbf(x); 53 | 54 | if (r == FP_ILOGB0 || r == FP_ILOGBNAN || r == INT_MAX) 55 | { 56 | __kernel_standard_f(x, x, x, KMATHERRF_ILOGB); 57 | } 58 | return r; 59 | } 60 | 61 | __typeof(__ilogbf) ilogbf __attribute__((weak, alias("__ilogbf"))); 62 | -------------------------------------------------------------------------------- /w_tgamma.c: -------------------------------------------------------------------------------- 1 | /* @(#)w_gamma.c 5.1 93/09/24 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | /* double gamma(double x) 14 | * Return the logarithm of the Gamma function of x or the Gamma function of x, 15 | * depending on the library mode. 16 | */ 17 | 18 | #ifndef __FDLIBM_H__ 19 | #include "fdlibm.h" 20 | #endif 21 | 22 | double __tgamma(double x) 23 | { 24 | int local_signgam; 25 | double y = __ieee754_tgamma_r(x, &local_signgam); 26 | 27 | if (!isfinite(y) && (isfinite(x) || isinf(x) < 0) && _LIB_VERSION != _IEEE_) 28 | { 29 | if (x == 0.0) 30 | return __kernel_standard(x, x, y, KMATHERR_TGAMMA_ZERO); /* tgamma pole */ 31 | else if (__ieee754_floor(x) == x && x < 0.0) 32 | return __kernel_standard(x, x, y, KMATHERR_TGAMMA_MINUS); /* tgamma domain */ 33 | else if (y == 0) 34 | return __kernel_standard(x, x, y, KMATHERR_TGAMMA_UNDERFLOW); /* tgamma underflow */ 35 | else 36 | return __kernel_standard(x, x, y, KMATHERR_TGAMMA_OVERFLOW); /* tgamma overflow */ 37 | } 38 | return local_signgam < 0 ? -y : y; 39 | } 40 | 41 | __typeof(__tgamma) tgamma __attribute__((weak, alias("__tgamma"))); 42 | #ifdef __NO_LONG_DOUBLE_MATH 43 | __typeof(__tgammal) __tgammal __attribute__((alias("__tgamma"))); 44 | __typeof(__tgammal) tgammal __attribute__((weak, alias("__tgamma"))); 45 | #endif 46 | -------------------------------------------------------------------------------- /s_cosf.c: -------------------------------------------------------------------------------- 1 | /* sf_cos.c -- float version of s_cos.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 | #ifndef __FDLIBM_H__ 17 | #include "fdlibm.h" 18 | #endif 19 | 20 | #ifndef __have_fpu_cos 21 | 22 | float __ieee754_cosf(float x) 23 | { 24 | float y[2], z = 0.0; 25 | int32_t n, ix; 26 | 27 | GET_FLOAT_WORD(ix, x); 28 | 29 | /* |x| ~< pi/4 */ 30 | ix &= IC(0x7fffffff); 31 | if (ix <= IC(0x3f490fd8)) 32 | return __kernel_cosf(x, z); 33 | 34 | /* cos(Inf or NaN) is NaN */ 35 | else if (!FLT_UWORD_IS_FINITE(ix)) 36 | return x - x; 37 | 38 | /* argument reduction needed */ 39 | else 40 | { 41 | n = __ieee754_rem_pio2f(x, y); 42 | switch ((int)(n & 3)) 43 | { 44 | case 0: 45 | return __kernel_cosf(y[0], y[1]); 46 | case 1: 47 | return -__kernel_sinf(y[0], y[1], 1); 48 | case 2: 49 | return -__kernel_cosf(y[0], y[1]); 50 | default: 51 | return __kernel_sinf(y[0], y[1], 1); 52 | } 53 | } 54 | } 55 | 56 | #endif 57 | 58 | float __cosf(float x) 59 | { 60 | float ret; 61 | 62 | ret = __ieee754_cosf(x); 63 | if (isnan(ret) && !isnan(x)) 64 | ret = __kernel_standard_f(x, x, ret, KMATHERRF_COS_INF); 65 | return ret; 66 | } 67 | 68 | __typeof(__cosf) cosf __attribute__((weak, alias("__cosf"))); 69 | -------------------------------------------------------------------------------- /s_sinf.c: -------------------------------------------------------------------------------- 1 | /* sf_sin.c -- float version of s_sin.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 | #ifndef __FDLIBM_H__ 17 | #include "fdlibm.h" 18 | #endif 19 | 20 | #ifndef __have_fpu_sin 21 | 22 | float __ieee754_sinf(float x) 23 | { 24 | float y[2], z = 0.0; 25 | int32_t n, ix; 26 | 27 | GET_FLOAT_WORD(ix, x); 28 | 29 | /* |x| ~< pi/4 */ 30 | ix &= IC(0x7fffffff); 31 | if (ix <= IC(0x3f490fd8)) 32 | return __kernel_sinf(x, z, 0); 33 | 34 | /* sin(Inf or NaN) is NaN */ 35 | else if (!FLT_UWORD_IS_FINITE(ix)) 36 | return x - x; 37 | 38 | /* argument reduction needed */ 39 | else 40 | { 41 | n = __ieee754_rem_pio2f(x, y); 42 | switch ((int)(n & 3)) 43 | { 44 | case 0: 45 | return __kernel_sinf(y[0], y[1], 1); 46 | case 1: 47 | return __kernel_cosf(y[0], y[1]); 48 | case 2: 49 | return -__kernel_sinf(y[0], y[1], 1); 50 | default: 51 | return -__kernel_cosf(y[0], y[1]); 52 | } 53 | } 54 | } 55 | 56 | #endif 57 | 58 | float __sinf(float x) 59 | { 60 | float ret; 61 | 62 | ret = __ieee754_sinf(x); 63 | if (isnan(ret) && !isnan(x)) 64 | ret = __kernel_standard_f(x, x, ret, KMATHERRF_SIN_INF); 65 | return ret; 66 | } 67 | 68 | __typeof(__sinf) sinf __attribute__((weak, alias("__sinf"))); 69 | -------------------------------------------------------------------------------- /feupdateenv.c: -------------------------------------------------------------------------------- 1 | /* Install given floating-point environment and raise exceptions. 2 | Copyright (C) 1997-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Andreas Schwab 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library. If not, see 18 | . */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | #include "fpu_ctrl.h" 24 | 25 | int __feupdateenv(const fenv_t *envp) 26 | { 27 | fexcept_t fpsr; 28 | 29 | /* Save current exceptions. */ 30 | _FPU_GETSR(fpsr); 31 | fpsr &= FE_ALL_EXCEPT; 32 | 33 | /* Install new environment. */ 34 | fesetenv(envp); 35 | 36 | /* Raise the saved exception. Incidently for us the implementation 37 | defined format of the values in objects of type fexcept_t is the 38 | same as the ones specified using the FE_* constants. */ 39 | feraiseexcept((int) fpsr); 40 | 41 | /* Success. */ 42 | return 0; 43 | } 44 | 45 | __typeof(__feupdateenv) feupdateenv __attribute__((weak, alias("__feupdateenv"))); 46 | -------------------------------------------------------------------------------- /s_scalblnf.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #if INT_MAX != LONG_MAX 6 | 7 | #ifndef __have_fpu_scalbln 8 | 9 | float __ieee754_scalblnf(float x, long n) 10 | { 11 | int32_t k, ix; 12 | 13 | static const float two25 = 3.355443200e+07; /* 0x4c000000 */ 14 | static const float twom25 = 2.9802322388e-08; /* 0x33000000 */ 15 | static const float hugeval = 1.0e+30; 16 | static const float tiny = 1.0e-30; 17 | 18 | GET_FLOAT_WORD(ix, x); 19 | k = (ix & UC(0x7f800000)) >> IEEE754_FLOAT_SHIFT; /* extract exponent */ 20 | if (k == 0) 21 | { /* 0 or subnormal x */ 22 | if ((ix & UC(0x7fffffff)) == 0) 23 | return x; /* +-0 */ 24 | x *= two25; 25 | GET_FLOAT_WORD(ix, x); 26 | k = ((ix & UC(0x7f800000)) >> IEEE754_FLOAT_SHIFT) - 25; 27 | } 28 | if (k == IEEE754_FLOAT_MAXEXP) 29 | return x + x; /* NaN or Inf */ 30 | if (n < IC(-50000)) 31 | return tiny * copysignf(tiny, x); /*underflow */ 32 | if (n > IC(50000) || k + n > 0xfe) 33 | return hugeval * copysignf(hugeval, x); /* overflow */ 34 | /* Now k and n are bounded we know that k = k+n does not 35 | overflow. */ 36 | k = k + n; 37 | if (k > 0) /* normal result */ 38 | { 39 | SET_FLOAT_WORD(x, (ix & UC(0x807fffff)) | (k << IEEE754_FLOAT_SHIFT)); 40 | return x; 41 | } 42 | if (k <= -25) 43 | return tiny * copysignf(tiny, x); /*underflow */ 44 | k += 25; /* subnormal result */ 45 | SET_FLOAT_WORD(x, (ix & UC(0x807fffff)) | (k << IEEE754_FLOAT_SHIFT)); 46 | return x * twom25; 47 | } 48 | 49 | #endif 50 | 51 | float __scalblnf(float x, long n) 52 | { 53 | return __ieee754_scalblnf(x, n); 54 | } 55 | 56 | __typeof(__scalblnf) scalblnf __attribute__((weak, alias("__scalblnf"))); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /s_scalblnl.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #if INT_MAX != LONG_MAX 6 | 7 | #ifndef __NO_LONG_DOUBLE_MATH 8 | 9 | #ifndef __have_fpu_scalbln 10 | 11 | long double __ieee754_scalblnl(long double x, long n) 12 | { 13 | int32_t k, es, hx, lx; 14 | 15 | static const long double two64 = 1.8446744073709551616e19L; 16 | static const long double twom64 = 5.421010862427522170037e-20L; 17 | static const long double hugeval = 1.0e+4900L; 18 | static const long double tiny = 1.0e-4900L; 19 | 20 | GET_LDOUBLE_WORDS(es, hx, lx, x); 21 | k = es & IEEE854_LONG_DOUBLE_MAXEXP; /* extract exponent */ 22 | if (k == 0) 23 | { /* 0 or subnormal x */ 24 | if ((lx | (hx & UC(0x7fffffff))) == 0) 25 | return x; /* +-0 */ 26 | x *= two64; 27 | GET_LDOUBLE_EXP(hx, x); 28 | k = (hx & IEEE854_LONG_DOUBLE_MAXEXP) - 64; 29 | } 30 | if (k == IEEE854_LONG_DOUBLE_MAXEXP) 31 | return x + x; /* NaN or Inf */ 32 | if (n < IC(-50000)) 33 | return tiny * __copysignl(tiny, x); 34 | if (n > IC(50000) || k + n > 0x7ffe) 35 | return hugeval * __copysignl(hugeval, x); /* overflow */ 36 | /* Now k and n are bounded we know that k = k+n does not 37 | overflow. */ 38 | k = k + n; 39 | if (k > 0) /* normal result */ 40 | { 41 | SET_LDOUBLE_EXP(x, (es & 0x8000) | k); 42 | return x; 43 | } 44 | if (k <= -64) 45 | return tiny * __copysignl(tiny, x); /* underflow */ 46 | k += 64; /* subnormal result */ 47 | SET_LDOUBLE_EXP(x, (es & 0x8000) | k); 48 | return x * twom64; 49 | } 50 | 51 | #endif 52 | 53 | long double __scalblnl(long double x, long n) 54 | { 55 | return __ieee754_scalblnl(x, n); 56 | } 57 | 58 | __typeof(__scalblnl) scalblnl __attribute__((weak, alias("__scalblnl"))); 59 | 60 | #endif 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /tests/isfini.c: -------------------------------------------------------------------------------- 1 | #include "testconfig.h" 2 | #if defined(HAVE_ISFINITE) || defined(HAVE___ISFINITE) 3 | #ifdef HAVE___ISFINITE 4 | int __MATH_PRECNAME(__isfinite)(REAL x); 5 | #define TEST_FUNC_F_I __MATH_PRECNAME(__isfinite) 6 | #else 7 | #define TEST_FUNC_F_I __MATH_PRECNAME(isfinite) 8 | #endif 9 | #include "testdriver.h" 10 | 11 | /* make sure we don't test the builtin */ 12 | #undef isfinite 13 | #undef __isfinite 14 | 15 | static test_f_i_data const isfinite_data[] = { 16 | { __LINE__, ZERO_P, 1, NO_INEXACT_EXCEPTION }, 17 | { __LINE__, ZERO_M, 1, NO_INEXACT_EXCEPTION }, 18 | { __LINE__, SUBNORM_P, 1, NO_INEXACT_EXCEPTION }, 19 | { __LINE__, SUBNORM_M, 1, NO_INEXACT_EXCEPTION }, 20 | { __LINE__, INF_P, 0, NO_INEXACT_EXCEPTION }, 21 | { __LINE__, INF_M, 0, NO_INEXACT_EXCEPTION }, 22 | { __LINE__, QNAN_P, 0, NO_INEXACT_EXCEPTION }, 23 | { __LINE__, QNAN_M, 0, NO_INEXACT_EXCEPTION }, 24 | { __LINE__, SNAN_P, 0, NO_INEXACT_EXCEPTION }, 25 | { __LINE__, SNAN_M, 0, NO_INEXACT_EXCEPTION }, 26 | { __LINE__, MAX_P, 1, NO_INEXACT_EXCEPTION }, 27 | { __LINE__, MAX_M, 1, NO_INEXACT_EXCEPTION }, 28 | { __LINE__, MIN_P, 1, NO_INEXACT_EXCEPTION }, 29 | { __LINE__, MIN_M, 1, NO_INEXACT_EXCEPTION }, 30 | 31 | { __LINE__, HEXCONSTE(10, 0x4002, 0xa0000000L, 0x00000000L), 1, NO_INEXACT_EXCEPTION }, 32 | { __LINE__, HEXCONSTE(-10, 0xc002, 0xa0000000L, 0x00000000L), 1, NO_INEXACT_EXCEPTION }, 33 | }; 34 | 35 | int main(int argc, char **argv) 36 | { 37 | int status; 38 | 39 | status = 0; 40 | 41 | test_init(argc, argv); 42 | 43 | status |= test_table_f_i(isfinite_data, ARRAY_SIZE(isfinite_data), __FILE__); 44 | (void)check_fp; 45 | 46 | return status ? EXIT_FAILURE : EXIT_SUCCESS; 47 | } 48 | 49 | #else 50 | 51 | int main(void) 52 | { 53 | return 77; 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /s_sincosl.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __NO_LONG_DOUBLE_MATH 6 | 7 | #ifndef __have_fpu_sincos 8 | 9 | void __ieee754_sincosl(long double x, long double *sinx, long double *cosx) 10 | { 11 | *sinx = __ieee754_sinl(x); 12 | *cosx = __ieee754_cosl(x); 13 | } 14 | 15 | #endif 16 | 17 | void __sincosl(long double x, long double *sinx, long double *cosx) 18 | { 19 | int32_t se; 20 | uint32_t i0, i1; 21 | 22 | /* High word of x. */ 23 | GET_LDOUBLE_WORDS(se, i0, i1, x); 24 | (void) i1; 25 | 26 | /* |x| ~< pi/4 */ 27 | se &= 0x7fff; 28 | if (se < 0x3ffe || (se == 0x3ffe && i0 <= UC(0xc90fdaa2))) 29 | { 30 | #ifdef __have_fpu_sincos 31 | __ieee754_sincosl(x, sinx, cosx); 32 | #else 33 | *sinx = __kernel_sinl(x, 0.0, 0); 34 | *cosx = __kernel_cosl(x, 0.0); 35 | #endif 36 | } else if (se == 0x7fff) 37 | { 38 | /* sin(Inf or NaN) is NaN */ 39 | *sinx = *cosx = x - x; 40 | } else 41 | { 42 | #ifdef __have_fpu_sincos 43 | __ieee754_sincosl(x, sinx, cosx); 44 | #else 45 | /* Argument reduction needed. */ 46 | long double y[2]; 47 | int32_t n; 48 | 49 | n = __ieee754_rem_pio2l(x, y); 50 | switch ((int)(n & 3)) 51 | { 52 | case 0: 53 | *sinx = __kernel_sinl(y[0], y[1], 1); 54 | *cosx = __kernel_cosl(y[0], y[1]); 55 | break; 56 | case 1: 57 | *sinx = __kernel_cosl(y[0], y[1]); 58 | *cosx = -__kernel_sinl(y[0], y[1], 1); 59 | break; 60 | case 2: 61 | *sinx = -__kernel_sinl(y[0], y[1], 1); 62 | *cosx = -__kernel_cosl(y[0], y[1]); 63 | break; 64 | default: 65 | *sinx = -__kernel_cosl(y[0], y[1]); 66 | *cosx = __kernel_sinl(y[0], y[1], 1); 67 | break; 68 | } 69 | #endif 70 | } 71 | } 72 | 73 | __typeof(__sincosl) sincosl __attribute__((weak, alias("__sincosl"))); 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /tests/erf.c: -------------------------------------------------------------------------------- 1 | #include "testconfig.h" 2 | #define TEST_FUNC_F_F __MATH_PRECNAME(erf) 3 | #include "testdriver.h" 4 | 5 | 6 | 7 | static test_f_f_data const erf_data[] = { 8 | { __LINE__, ZERO_P, ZERO_P, 0 }, 9 | { __LINE__, ZERO_M, ZERO_M, FLAG_FAIL_ARANYM2 }, 10 | { __LINE__, INF_P, HEXCONSTE(1, 0x3fff, 0x80000000L, 0x00000000L), 0 }, 11 | { __LINE__, INF_M, HEXCONSTE(-1, 0xbfff, 0x80000000L, 0x00000000L), 0 }, 12 | { __LINE__, QNAN_P, QNAN_P, 0 }, 13 | { __LINE__, QNAN_M, QNAN_P, 0 }, 14 | { __LINE__, SNAN_P, QNAN_P, 0 }, 15 | { __LINE__, SNAN_M, QNAN_P, 0 }, 16 | 17 | { __LINE__, HEXCONSTE(0.125L, 0x3ffc, 0x80000000L, 0x00000000L), HEXCONSTE(0.140316204801333817393029446521623398L, 0x3ffc, 0x8faf0d1aL, 0xe1dc4ba1L), 0 }, 18 | { __LINE__, HEXCONSTE(0.75L, 0x3ffe, 0xc0000000L, 0x00000000L), HEXCONSTE(0.711155633653515131598937834591410777L, 0x3ffe, 0xb60e4bacL, 0xe872fb63L), FLAG_INEXACT }, 19 | { __LINE__, HEXCONSTE(1.25L, 0x3fff, 0xa0000000L, 0x00000000L), HEXCONSTE(0.922900128256458230136523481197281140L, 0x3ffe, 0xec432eccL, 0x55f00406L), FLAG_FAIL_ARANYM }, /* too inexact when using double */ 20 | { __LINE__, HEXCONSTE(2.0L, 0x4000, 0x80000000L, 0x00000000L), HEXCONSTE(0.995322265018952734162069256367252929L, 0x3ffe, 0xfecd70a1L, 0x3caf1997L), 0 }, 21 | { __LINE__, HEXCONSTE(4.125L, 0x4001, 0x84000000L, 0x00000000L), HEXCONSTE(0.999999994576599200434933994687765914L, 0x3ffe, 0xffffffe8L, 0xb4e862e1L), 0 }, 22 | { __LINE__, HEXCONSTE(27.0L, 0x4003, 0xd8000000L, 0x00000000L), HEXCONSTE(1.0L, 0x3fff, 0x80000000L, 0x00000000L), 0 }, 23 | }; 24 | 25 | int main(int argc, char **argv) 26 | { 27 | int status; 28 | 29 | status = 0; 30 | 31 | test_init(argc, argv); 32 | 33 | status |= test_table_f_f(erf_data, ARRAY_SIZE(erf_data), __FILE__); 34 | 35 | return status ? EXIT_FAILURE : EXIT_SUCCESS; 36 | } 37 | -------------------------------------------------------------------------------- /tests/issign.c: -------------------------------------------------------------------------------- 1 | #include "testconfig.h" 2 | #if defined(HAVE_ISSIGNALING) || defined(HAVE___ISSIGNALING) 3 | #ifdef HAVE___ISSIGNALING 4 | int __MATH_PRECNAME(__issignaling)(REAL x); 5 | #define TEST_FUNC_F_I __MATH_PRECNAME(__issignaling) 6 | #else 7 | #define TEST_FUNC_F_I __MATH_PRECNAME(issignaling) 8 | #endif 9 | #include "testdriver.h" 10 | 11 | /* make sure we don't test the builtin */ 12 | #undef issignaling 13 | #undef __issignaling 14 | 15 | static test_f_i_data const issignaling_data[] = { 16 | { __LINE__, ZERO_P, 0, NO_INEXACT_EXCEPTION }, 17 | { __LINE__, ZERO_M, 0, NO_INEXACT_EXCEPTION }, 18 | { __LINE__, SUBNORM_P, 0, NO_INEXACT_EXCEPTION }, 19 | { __LINE__, SUBNORM_M, 0, NO_INEXACT_EXCEPTION }, 20 | { __LINE__, INF_P, 0, NO_INEXACT_EXCEPTION }, 21 | { __LINE__, INF_M, 0, NO_INEXACT_EXCEPTION }, 22 | { __LINE__, QNAN_P, 0, NO_INEXACT_EXCEPTION }, 23 | { __LINE__, QNAN_M, 0, NO_INEXACT_EXCEPTION }, 24 | { __LINE__, SNAN_P, 1, NO_INEXACT_EXCEPTION }, 25 | { __LINE__, SNAN_M, 1, NO_INEXACT_EXCEPTION }, 26 | { __LINE__, MAX_P, 0, NO_INEXACT_EXCEPTION }, 27 | { __LINE__, MAX_M, 0, NO_INEXACT_EXCEPTION }, 28 | { __LINE__, MIN_P, 0, NO_INEXACT_EXCEPTION }, 29 | { __LINE__, MIN_M, 0, NO_INEXACT_EXCEPTION }, 30 | 31 | { __LINE__, HEXCONSTE(10, 0x4002, 0xa0000000L, 0x00000000L), 0, NO_INEXACT_EXCEPTION }, 32 | { __LINE__, HEXCONSTE(-10, 0xc002, 0xa0000000L, 0x00000000L), 0, NO_INEXACT_EXCEPTION }, 33 | }; 34 | 35 | int main(int argc, char **argv) 36 | { 37 | int status; 38 | 39 | status = 0; 40 | 41 | test_init(argc, argv); 42 | 43 | status |= test_table_f_i(issignaling_data, ARRAY_SIZE(issignaling_data), __FILE__); 44 | (void)check_fp; 45 | 46 | return status ? EXIT_FAILURE : EXIT_SUCCESS; 47 | } 48 | 49 | #else 50 | 51 | int main(void) 52 | { 53 | return 77; 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /e_expl.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __NO_LONG_DOUBLE_MATH 6 | 7 | #ifndef __have_fpu_exp 8 | 9 | long double __ieee754_expl(long double x) /* default IEEE double exp */ 10 | { 11 | int sign; 12 | int32_t ex; 13 | uint32_t hx, lx; 14 | int intx; 15 | long double fractx; 16 | 17 | /* Smallest integer x for which e^x overflows. */ 18 | static const double o_threshold = 1.1356523406294143949491931077970764891253E4L; 19 | /* Largest integer x for which e^x underflows. */ 20 | static const long double u_threshold = -11355.137111933024058885L; 21 | static const long double log2e = 1.44269504088896340735992468100189213743L; 22 | 23 | GET_LDOUBLE_WORDS(ex, hx, lx, x); 24 | sign = (int)ex & 0x8000; /* sign bit of x */ 25 | ex &= 0x7fff; 26 | hx &= IC(0x7fffffff); 27 | /* filter out non-finite argument */ 28 | if (ex >= 0x7fff) 29 | { 30 | if ((hx | lx) != 0) 31 | return x; /* NaN */ 32 | return sign ? 0.0 : x; /* exp(+-inf)={inf,0} */ 33 | } 34 | if (x > o_threshold) /* overflow */ 35 | { 36 | feraiseexcept(FE_OVERFLOW); 37 | return HUGE_VALL; 38 | } 39 | if (x < u_threshold) /* underflow */ 40 | { 41 | feraiseexcept(FE_UNDERFLOW); 42 | return 0; 43 | } 44 | x *= log2e; 45 | intx = (int) x; 46 | fractx = x - intx; 47 | return __ieee754_scalbnl(__ieee754_expm1l(M_LN2l * fractx) + 1.0L, intx); 48 | } 49 | 50 | #endif 51 | 52 | /* wrapper exp */ 53 | long double __expl(long double x) 54 | { 55 | long double z = __ieee754_expl(x); 56 | 57 | if ((!isfinite(z) || z == 0.0L) && isfinite(x) && _LIB_VERSION != _IEEE_) 58 | return __kernel_standard_l(x, x, z, signbit(x) ? KMATHERRL_EXP_UNDERFLOW : KMATHERRL_EXP_OVERFLOW); 59 | 60 | return z; 61 | } 62 | 63 | __typeof(__expl) expl __attribute__((weak, alias("__expl"))); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /tests/isinf.c: -------------------------------------------------------------------------------- 1 | #include "testconfig.h" 2 | #if defined(HAVE_ISINF) || defined(HAVE___ISINF) 3 | /* FIXME: that would use the function from mintlib */ 4 | #if defined(HAVE___ISINF) && 0 5 | int __MATH_PRECNAME(__isinf)(REAL x); 6 | #define TEST_FUNC_F_I __MATH_PRECNAME(__isinf) 7 | #else 8 | #define TEST_FUNC_F_I __MATH_PRECNAME(isinf) 9 | #endif 10 | #include "testdriver.h" 11 | 12 | /* make sure we don't test the builtin */ 13 | #undef isinf 14 | #undef __isinf 15 | 16 | static test_f_i_data const isinf_data[] = { 17 | { __LINE__, ZERO_P, 0, NO_INEXACT_EXCEPTION }, 18 | { __LINE__, ZERO_M, 0, NO_INEXACT_EXCEPTION }, 19 | { __LINE__, SUBNORM_P, 0, NO_INEXACT_EXCEPTION }, 20 | { __LINE__, SUBNORM_M, 0, NO_INEXACT_EXCEPTION }, 21 | { __LINE__, INF_P, 1, NO_INEXACT_EXCEPTION }, 22 | { __LINE__, INF_M, -1, NO_INEXACT_EXCEPTION }, 23 | { __LINE__, QNAN_P, 0, NO_INEXACT_EXCEPTION }, 24 | { __LINE__, QNAN_M, 0, NO_INEXACT_EXCEPTION }, 25 | { __LINE__, SNAN_P, 0, NO_INEXACT_EXCEPTION }, 26 | { __LINE__, SNAN_M, 0, NO_INEXACT_EXCEPTION }, 27 | { __LINE__, MAX_P, 0, NO_INEXACT_EXCEPTION }, 28 | { __LINE__, MAX_M, 0, NO_INEXACT_EXCEPTION }, 29 | { __LINE__, MIN_P, 0, NO_INEXACT_EXCEPTION }, 30 | { __LINE__, MIN_M, 0, NO_INEXACT_EXCEPTION }, 31 | 32 | { __LINE__, HEXCONSTE(10, 0x4002, 0xa0000000L, 0x00000000L), 0, NO_INEXACT_EXCEPTION }, 33 | { __LINE__, HEXCONSTE(-10, 0xc002, 0xa0000000L, 0x00000000L), 0, NO_INEXACT_EXCEPTION }, 34 | }; 35 | 36 | int main(int argc, char **argv) 37 | { 38 | int status; 39 | 40 | status = 0; 41 | 42 | test_init(argc, argv); 43 | 44 | status |= test_table_f_i(isinf_data, ARRAY_SIZE(isinf_data), __FILE__); 45 | (void)check_fp; 46 | 47 | return status ? EXIT_FAILURE : EXIT_SUCCESS; 48 | } 49 | 50 | #else 51 | 52 | int main(void) 53 | { 54 | return 77; 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /tests/isnan.c: -------------------------------------------------------------------------------- 1 | #include "testconfig.h" 2 | #if defined(HAVE_ISNAN) || defined(HAVE___ISNAN) 3 | /* FIXME: that would use the function from mintlib */ 4 | #if defined(HAVE___ISNAN) && 0 5 | int __MATH_PRECNAME(__isnan)(REAL x); 6 | #define TEST_FUNC_F_I __MATH_PRECNAME(__isnan) 7 | #else 8 | #define TEST_FUNC_F_I __MATH_PRECNAME(isnan) 9 | #endif 10 | #include "testdriver.h" 11 | 12 | /* make sure we don't test the builtin */ 13 | #undef isnan 14 | #undef __isnan 15 | 16 | static test_f_i_data const isnan_data[] = { 17 | { __LINE__, ZERO_P, 0, NO_INEXACT_EXCEPTION }, 18 | { __LINE__, ZERO_M, 0, NO_INEXACT_EXCEPTION }, 19 | { __LINE__, SUBNORM_P, 0, NO_INEXACT_EXCEPTION }, 20 | { __LINE__, SUBNORM_M, 0, NO_INEXACT_EXCEPTION }, 21 | { __LINE__, INF_P, 0, NO_INEXACT_EXCEPTION }, 22 | { __LINE__, INF_M, 0, NO_INEXACT_EXCEPTION }, 23 | { __LINE__, QNAN_P, 1, NO_INEXACT_EXCEPTION }, 24 | { __LINE__, QNAN_M, 1, NO_INEXACT_EXCEPTION }, 25 | { __LINE__, SNAN_P, 1, NO_INEXACT_EXCEPTION }, 26 | { __LINE__, SNAN_M, 1, NO_INEXACT_EXCEPTION }, 27 | { __LINE__, MAX_P, 0, NO_INEXACT_EXCEPTION }, 28 | { __LINE__, MAX_M, 0, NO_INEXACT_EXCEPTION }, 29 | { __LINE__, MIN_P, 0, NO_INEXACT_EXCEPTION }, 30 | { __LINE__, MIN_M, 0, NO_INEXACT_EXCEPTION }, 31 | 32 | { __LINE__, HEXCONSTE(10, 0x4002, 0xa0000000L, 0x00000000L), 0, NO_INEXACT_EXCEPTION }, 33 | { __LINE__, HEXCONSTE(-10, 0xc002, 0xa0000000L, 0x00000000L), 0, NO_INEXACT_EXCEPTION }, 34 | }; 35 | 36 | int main(int argc, char **argv) 37 | { 38 | int status; 39 | 40 | status = 0; 41 | 42 | test_init(argc, argv); 43 | 44 | status |= test_table_f_i(isnan_data, ARRAY_SIZE(isnan_data), __FILE__); 45 | (void)check_fp; 46 | 47 | return status ? EXIT_FAILURE : EXIT_SUCCESS; 48 | } 49 | 50 | #else 51 | 52 | int main(void) 53 | { 54 | return 77; 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /tests/finite.c: -------------------------------------------------------------------------------- 1 | #include "testconfig.h" 2 | #if defined(HAVE_FINITE) || defined(HAVE___FINITE) 3 | /* FIXME: that would use the function from mintlib */ 4 | #if defined(HAVE___FINITE) && 0 5 | int __MATH_PRECNAME(__finite)(REAL x); 6 | #define TEST_FUNC_F_I __MATH_PRECNAME(__finite) 7 | #else 8 | #define TEST_FUNC_F_I __MATH_PRECNAME(finite) 9 | #endif 10 | #include "testdriver.h" 11 | 12 | /* make sure we don't test the builtin */ 13 | #undef finite 14 | #undef __finite 15 | 16 | static test_f_i_data const finite_data[] = { 17 | { __LINE__, ZERO_P, 1, NO_INEXACT_EXCEPTION }, 18 | { __LINE__, ZERO_M, 1, NO_INEXACT_EXCEPTION }, 19 | { __LINE__, SUBNORM_P, 1, NO_INEXACT_EXCEPTION }, 20 | { __LINE__, SUBNORM_M, 1, NO_INEXACT_EXCEPTION }, 21 | { __LINE__, INF_P, 0, NO_INEXACT_EXCEPTION }, 22 | { __LINE__, INF_M, 0, NO_INEXACT_EXCEPTION }, 23 | { __LINE__, QNAN_P, 0, NO_INEXACT_EXCEPTION }, 24 | { __LINE__, QNAN_M, 0, NO_INEXACT_EXCEPTION }, 25 | { __LINE__, SNAN_P, 0, NO_INEXACT_EXCEPTION }, 26 | { __LINE__, SNAN_M, 0, NO_INEXACT_EXCEPTION }, 27 | { __LINE__, MAX_P, 1, NO_INEXACT_EXCEPTION }, 28 | { __LINE__, MAX_M, 1, NO_INEXACT_EXCEPTION }, 29 | { __LINE__, MIN_P, 1, NO_INEXACT_EXCEPTION }, 30 | { __LINE__, MIN_M, 1, NO_INEXACT_EXCEPTION }, 31 | 32 | { __LINE__, HEXCONSTE(10, 0x4002, 0xa0000000L, 0x00000000L), 1, NO_INEXACT_EXCEPTION }, 33 | { __LINE__, HEXCONSTE(-10, 0xc002, 0xa0000000L, 0x00000000L), 1, NO_INEXACT_EXCEPTION }, 34 | }; 35 | 36 | int main(int argc, char **argv) 37 | { 38 | int status; 39 | 40 | status = 0; 41 | 42 | test_init(argc, argv); 43 | 44 | status |= test_table_f_i(finite_data, ARRAY_SIZE(finite_data), __FILE__); 45 | (void)check_fp; 46 | 47 | return status ? EXIT_FAILURE : EXIT_SUCCESS; 48 | } 49 | 50 | #else 51 | 52 | int main(void) 53 | { 54 | return 77; 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /tests/isnorm.c: -------------------------------------------------------------------------------- 1 | #include "testconfig.h" 2 | #if defined(HAVE_ISNORMAL) || defined(HAVE___ISNORMAL) 3 | #ifdef HAVE___ISNORMAL 4 | int __MATH_PRECNAME(__isnormal)(REAL x); 5 | #define TEST_FUNC_F_I __MATH_PRECNAME(__isnormal) 6 | #else 7 | #define TEST_FUNC_F_I __MATH_PRECNAME(isnormal) 8 | #endif 9 | #include "testdriver.h" 10 | 11 | /* make sure we don't test the builtin */ 12 | #undef isnormal 13 | #undef __isnormal 14 | 15 | static test_f_i_data const isnormal_data[] = { 16 | { __LINE__, ZERO_P, 0, NO_INEXACT_EXCEPTION }, 17 | { __LINE__, ZERO_M, 0, NO_INEXACT_EXCEPTION }, 18 | #ifdef TEST_LDOUBLE /* FIXME: messed up by truncxfdf2 */ 19 | { __LINE__, SUBNORM_P, 0, NO_INEXACT_EXCEPTION }, 20 | { __LINE__, SUBNORM_M, 0, NO_INEXACT_EXCEPTION }, 21 | #endif 22 | { __LINE__, INF_P, 0, NO_INEXACT_EXCEPTION }, 23 | { __LINE__, INF_M, 0, NO_INEXACT_EXCEPTION }, 24 | { __LINE__, QNAN_P, 0, NO_INEXACT_EXCEPTION }, 25 | { __LINE__, QNAN_M, 0, NO_INEXACT_EXCEPTION }, 26 | { __LINE__, SNAN_P, 0, NO_INEXACT_EXCEPTION }, 27 | { __LINE__, SNAN_M, 0, NO_INEXACT_EXCEPTION }, 28 | { __LINE__, MAX_P, 1, NO_INEXACT_EXCEPTION }, 29 | { __LINE__, MAX_M, 1, NO_INEXACT_EXCEPTION }, 30 | { __LINE__, MIN_P, 1, NO_INEXACT_EXCEPTION }, 31 | { __LINE__, MIN_M, 1, NO_INEXACT_EXCEPTION }, 32 | 33 | { __LINE__, HEXCONSTE(10, 0x4002, 0xa0000000L, 0x00000000L), 1, NO_INEXACT_EXCEPTION }, 34 | { __LINE__, HEXCONSTE(-10, 0xc002, 0xa0000000L, 0x00000000L), 1, NO_INEXACT_EXCEPTION }, 35 | }; 36 | 37 | int main(int argc, char **argv) 38 | { 39 | int status; 40 | 41 | status = 0; 42 | 43 | test_init(argc, argv); 44 | 45 | status |= test_table_f_i(isnormal_data, ARRAY_SIZE(isnormal_data), __FILE__); 46 | (void)check_fp; 47 | 48 | return status ? EXIT_FAILURE : EXIT_SUCCESS; 49 | } 50 | 51 | #else 52 | 53 | int main(void) 54 | { 55 | return 77; 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /tests/fneg.c: -------------------------------------------------------------------------------- 1 | #include "testconfig.h" 2 | #define TEST_FUNC_F_F __MATH_PRECNAME(wrap_neg) 3 | static REAL TEST_FUNC_F_F(REAL x) 4 | { 5 | return -x; 6 | } 7 | #include "testdriver.h" 8 | 9 | 10 | 11 | static test_f_f_data const fneg_data[] = { 12 | { __LINE__, ZERO_P, ZERO_M, FLAG_FAIL_ARANYM2 }, 13 | { __LINE__, ZERO_M, ZERO_P, 0 }, 14 | { __LINE__, INF_P, INF_M, 0 }, 15 | { __LINE__, INF_M, INF_P, 0 }, 16 | { __LINE__, QNAN_P, QNAN_M, 0 }, 17 | { __LINE__, QNAN_M, QNAN_P, 0 }, 18 | { __LINE__, SNAN_P, QNAN_P, 0 }, 19 | { __LINE__, SNAN_M, QNAN_P, 0 }, 20 | { __LINE__, SUBNORM_P, SUBNORM_M, FLAG_SUBNORM }, 21 | { __LINE__, SUBNORM_M, SUBNORM_P, FLAG_SUBNORM }, 22 | { __LINE__, MIN_M, MIN_P, FLAG_MINVAL }, 23 | { __LINE__, MIN_P, MIN_M, FLAG_MINVAL }, 24 | { __LINE__, MAX_M, MAX_P, 0 }, 25 | { __LINE__, MAX_P, MAX_M, 0 }, 26 | 27 | { __LINE__, HEXCONSTE(38.0, 0x4004, 0x98000000L, 0x00000000L), HEXCONSTE(-38.0, 0xc004, 0x98000000L, 0x00000000L), 0 }, 28 | { __LINE__, HEXCONSTE(2.718281828459045235360287471352662498, 0x4000, 0xadf85458L, 0xa2bb4a9aL), HEXCONSTE(-2.718281828459045235360287471352662498, 0xc000, 0xadf85458L, 0xa2bb4a9aL), 0 }, 29 | { __LINE__, HEXCONSTE(-2.718281828459045235360287471352662498, 0xc000, 0xadf85458L, 0xa2bb4a9aL), HEXCONSTE(2.718281828459045235360287471352662498, 0x4000, 0xadf85458L, 0xa2bb4a9aL), 0 }, 30 | { __LINE__, HEXCONSTE(-55, 0xc004, 0xdc000000L, 0x00000000L), HEXCONSTE(55, 0x4004, 0xdc000000L, 0x00000000L), 0 }, 31 | { __LINE__, HEXCONSTE(-1024, 0xc009, 0x80000000L, 0x00000000L), HEXCONSTE(1024, 0x4009, 0x80000000L, 0x00000000L), 0 }, 32 | }; 33 | 34 | int main(int argc, char **argv) 35 | { 36 | int status; 37 | 38 | status = 0; 39 | 40 | test_init(argc, argv); 41 | 42 | status |= test_table_f_f(fneg_data, ARRAY_SIZE(fneg_data), __FILE__); 43 | 44 | return status ? EXIT_FAILURE : EXIT_SUCCESS; 45 | } 46 | -------------------------------------------------------------------------------- /s_rintf.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __have_fpu_rint 6 | 7 | static float __ieee754_roundevenf(float x) 8 | { 9 | int32_t i0, j0; 10 | 11 | static const float hugeval = 1.0e30; 12 | 13 | GET_FLOAT_WORD(i0, x); 14 | j0 = ((i0 >> IEEE754_FLOAT_SHIFT) & IEEE754_FLOAT_MAXEXP) - IEEE754_FLOAT_BIAS; 15 | if (j0 < IEEE754_FLOAT_SHIFT) 16 | { 17 | if (j0 < 0) 18 | { 19 | math_force_eval(hugeval + x); 20 | 21 | if (j0 == -1 && (i0 & IC(0x007fffff)) != 0) 22 | { 23 | i0 &= IC(0x80000000); 24 | i0 |= IC(0x3f800000); 25 | } else 26 | { 27 | i0 &= IC(0x80000000); 28 | } 29 | } else 30 | { 31 | uint32_t i = UC(0x007fffff) >> j0; 32 | 33 | if ((i0 & i) == 0) 34 | /* X is integral. */ 35 | return x; 36 | 37 | /* Raise inexact if x != 0. */ 38 | math_force_eval(hugeval + x); 39 | 40 | if ((i0 & (i >> 1)) != 0 || (i0 & (UC(0x00800000) >> j0))) 41 | { 42 | i0 += UC(0x00400000) >> j0; 43 | } 44 | i0 &= ~i; 45 | } 46 | } else 47 | { 48 | if (j0 == (IEEE754_FLOAT_MAXEXP - IEEE754_FLOAT_BIAS)) 49 | /* Inf or NaN. */ 50 | return x + x; 51 | else 52 | return x; 53 | } 54 | 55 | SET_FLOAT_WORD(x, i0); 56 | return x; 57 | } 58 | 59 | 60 | float __ieee754_rintf(float x) 61 | { 62 | /* 63 | * above code relies on a FPU doing the rounding, 64 | * and using round-to-even for FE_TONEAREST 65 | */ 66 | switch (fegetround()) 67 | { 68 | case FE_UPWARD: return __ieee754_ceilf(x); 69 | case FE_DOWNWARD: return __ieee754_floorf(x); 70 | case FE_TOWARDZERO: return __ieee754_truncf(x); 71 | } 72 | /* case FE_TONEAREST: */ 73 | return __ieee754_roundevenf(x); 74 | } 75 | 76 | #endif 77 | 78 | float __rintf(float x) 79 | { 80 | return __ieee754_rintf(x); 81 | } 82 | 83 | __typeof(__rintf) rintf __attribute__((weak, alias("__rintf"))); 84 | -------------------------------------------------------------------------------- /fpu_ctrl.h: -------------------------------------------------------------------------------- 1 | /* FPU control word bits. x86-64 version. 2 | Copyright (C) 1993,1995,1996,1997,1998,2000,2001,2002 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Olaf Flebbe. 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library; if not, write to the Free 18 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 19 | 02111-1307 USA. */ 20 | 21 | #ifndef ___FPU_CONTROL_H__ 22 | #define ___FPU_CONTROL_H__ 1 23 | 24 | #if defined(__i386__) || defined(__x86_64__) 25 | 26 | /* _WIN32 does not have , include our definitions */ 27 | #define _FPU_CONTROL_H 28 | #include "../../include/bits/x86/fpu_control.h" 29 | 30 | #else 31 | 32 | #include 33 | 34 | #endif 35 | 36 | /* Default control word set at startup. */ 37 | extern fpu_control_t __fpu_control; 38 | 39 | /* Called at startup. It can be used to manipulate fpu control register. */ 40 | void __setfpucw(fpu_control_t set); 41 | 42 | #ifndef FE_ROUNDING_MASK 43 | #define FE_ROUNDING_MASK (FE_TONEAREST|FE_DOWNWARD|FE_UPWARD|FE_TOWARDZERO) 44 | #endif 45 | #ifndef FE_PRECISION_MASK 46 | #define FE_PRECISION_MASK (_FPU_EXTENDED|_FPU_DOUBLE|_FPU_SINGLE) 47 | #endif 48 | 49 | #endif /* fpu_control.h */ 50 | -------------------------------------------------------------------------------- /tests/fpclass.c: -------------------------------------------------------------------------------- 1 | #include "testconfig.h" 2 | #if defined(HAVE_FPCLASSIFY) || defined(HAVE___FPCLASSIFY) 3 | #ifdef HAVE___FPCLASSIFY 4 | int __MATH_PRECNAME(__fpclassify)(REAL x); 5 | #define TEST_FUNC_F_I __MATH_PRECNAME(__fpclassify) 6 | #else 7 | #define TEST_FUNC_F_I __MATH_PRECNAME(fpclassify) 8 | #endif 9 | #include "testdriver.h" 10 | 11 | /* make sure we don't test the builtin */ 12 | #undef fpclassify 13 | #undef __fpclassify 14 | 15 | static test_f_i_data const fpclassify_data[] = { 16 | { __LINE__, QNAN_P, FP_NAN, NO_INEXACT_EXCEPTION }, 17 | { __LINE__, QNAN_M, FP_NAN, NO_INEXACT_EXCEPTION }, 18 | { __LINE__, SNAN_P, FP_NAN, NO_INEXACT_EXCEPTION }, 19 | { __LINE__, SNAN_M, FP_NAN, NO_INEXACT_EXCEPTION }, 20 | { __LINE__, INF_P, FP_INFINITE, NO_INEXACT_EXCEPTION }, 21 | { __LINE__, INF_M, FP_INFINITE, NO_INEXACT_EXCEPTION }, 22 | { __LINE__, ZERO_P, FP_ZERO, NO_INEXACT_EXCEPTION }, 23 | { __LINE__, ZERO_M, FP_ZERO, NO_INEXACT_EXCEPTION }, 24 | #ifdef TEST_LDOUBLE /* FIXME: messed up by truncxfdf2 */ 25 | { __LINE__, SUBNORM_P, FP_SUBNORMAL, NO_INEXACT_EXCEPTION }, 26 | { __LINE__, SUBNORM_M, FP_SUBNORMAL, NO_INEXACT_EXCEPTION }, 27 | #endif 28 | { __LINE__, MAX_P, FP_NORMAL, NO_INEXACT_EXCEPTION }, 29 | { __LINE__, MAX_M, FP_NORMAL, NO_INEXACT_EXCEPTION }, 30 | { __LINE__, MIN_P, FP_NORMAL, NO_INEXACT_EXCEPTION }, 31 | { __LINE__, MIN_M, FP_NORMAL, NO_INEXACT_EXCEPTION }, 32 | 33 | { __LINE__, HEXCONSTE(1000, 0x4008, 0xfa000000L, 0x00000000L), FP_NORMAL, NO_INEXACT_EXCEPTION }, 34 | }; 35 | 36 | int main(int argc, char **argv) 37 | { 38 | int status; 39 | 40 | status = 0; 41 | 42 | test_init(argc, argv); 43 | 44 | status |= test_table_f_i(fpclassify_data, ARRAY_SIZE(fpclassify_data), __FILE__); 45 | (void)check_fp; 46 | 47 | return status ? EXIT_FAILURE : EXIT_SUCCESS; 48 | } 49 | 50 | #else 51 | 52 | int main(void) 53 | { 54 | return 77; 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /tests/nextaf.c: -------------------------------------------------------------------------------- 1 | #include "testconfig.h" 2 | #ifdef HAVE_NEXTAFTER 3 | #define TEST_FUNC_FF_F __MATH_PRECNAME(nextafter) 4 | #include "testdriver.h" 5 | 6 | 7 | static test_ff_f_data const nextafter_data[] = { 8 | { __LINE__, ZERO_P, ZERO_P, ZERO_P, NO_INEXACT_EXCEPTION }, 9 | { __LINE__, ZERO_M, ZERO_P, ZERO_P, NO_INEXACT_EXCEPTION|FLAG_FAIL_SOFTFLOAT|FLAG_FAIL_HARDFLOAT }, 10 | { __LINE__, ZERO_P, ZERO_M, ZERO_M, NO_INEXACT_EXCEPTION|FLAG_FAIL_SOFTFLOAT|FLAG_FAIL_HARDFLOAT }, 11 | { __LINE__, ZERO_M, ZERO_M, ZERO_M, NO_INEXACT_EXCEPTION|FLAG_FAIL_ARANYM2 }, 12 | 13 | { __LINE__, HEXCONSTE(9, 0x4002, 0x90000000L, 0x00000000L), HEXCONSTE(9, 0x4002, 0x90000000L, 0x00000000L), HEXCONSTE(9, 0x4002, 0x90000000L, 0x00000000L), NO_INEXACT_EXCEPTION }, 14 | { __LINE__, HEXCONSTE(-9, 0xc002, 0x90000000L, 0x00000000L), HEXCONSTE(-9, 0xc002, 0x90000000L, 0x00000000L), HEXCONSTE(-9, 0xc002, 0x90000000L, 0x00000000L), NO_INEXACT_EXCEPTION }, 15 | { __LINE__, INF_P, INF_P, INF_P, NO_INEXACT_EXCEPTION|FLAG_FAIL_ARANYM2 }, 16 | { __LINE__, INF_M, INF_M, INF_M, NO_INEXACT_EXCEPTION|FLAG_FAIL_ARANYM2 }, 17 | 18 | { __LINE__, QNAN_P, HEXCONSTE(1.1L, 0x3fff, 0x8cccccccL, 0xcccccccdL), QNAN_P, NO_INEXACT_EXCEPTION }, 19 | { __LINE__, HEXCONSTE(1.1L, 0x3fff, 0x8cccccccL, 0xcccccccdL), QNAN_P, QNAN_P, NO_INEXACT_EXCEPTION }, 20 | { __LINE__, QNAN_P, QNAN_P, QNAN_P, NO_INEXACT_EXCEPTION }, 21 | 22 | { __LINE__, MAX_P, INF_P, INF_P, INEXACT_EXCEPTION|OVERFLOW_EXCEPTION }, 23 | { __LINE__, MAX_M, INF_M, INF_M, INEXACT_EXCEPTION|OVERFLOW_EXCEPTION }, 24 | }; 25 | 26 | int main(int argc, char **argv) 27 | { 28 | int status; 29 | 30 | status = 0; 31 | 32 | test_init(argc, argv); 33 | 34 | status |= test_table_ff_f(nextafter_data, ARRAY_SIZE(nextafter_data), __FILE__); 35 | 36 | return status ? EXIT_FAILURE : EXIT_SUCCESS; 37 | } 38 | 39 | #else 40 | 41 | int main(void) 42 | { 43 | return 77; 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /include/bits/nan.h: -------------------------------------------------------------------------------- 1 | /* `NAN' constant for IEEE 754 machines. 2 | Copyright (C) 1992, 1996, 1997, 1999 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, write to the Free 17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 | 02111-1307 USA. */ 19 | 20 | #ifndef _MATH_H 21 | # error "Never use directly; include instead." 22 | #endif 23 | 24 | 25 | /* IEEE Not A Number. */ 26 | 27 | #ifdef __GNUC__ 28 | 29 | #if __GNUC_PREREQ(3,3) 30 | 31 | # define NAN (__builtin_nanf ("")) 32 | 33 | #else 34 | 35 | # define NAN \ 36 | (__extension__ \ 37 | ((union { unsigned __l __attribute__((__mode__(__SI__))); float __d; }) \ 38 | { __l: 0x7fc00000UL }).__d) 39 | 40 | #endif 41 | 42 | #else 43 | 44 | # include 45 | 46 | # if __BYTE_ORDER == __BIG_ENDIAN 47 | # define __nan_bytes { 0x7f, 0xc0, 0, 0 } 48 | # endif 49 | # if __BYTE_ORDER == __LITTLE_ENDIAN 50 | # define __nan_bytes { 0, 0, 0xc0, 0x7f } 51 | # endif 52 | 53 | static union { unsigned char __c[4]; float __d; } const __nan_union = { __nan_bytes }; 54 | # define NAN (__nan_union.__d) 55 | 56 | #endif /* GCC. */ 57 | -------------------------------------------------------------------------------- /k_cosf.c: -------------------------------------------------------------------------------- 1 | /* k_cosf.c -- float version of k_cos.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 | #ifndef __FDLIBM_H__ 17 | #include "fdlibm.h" 18 | #endif 19 | 20 | float __kernel_cosf(float x, float y) 21 | { 22 | float a, hz, z, r, qx; 23 | int32_t ix; 24 | 25 | static const float one = 1.0000000000e+00; /* 0x3f800000 */ 26 | static const float C1 = 4.1666667908e-02; /* 0x3d2aaaab */ 27 | static const float C2 = -1.3888889225e-03; /* 0xbab60b61 */ 28 | static const float C3 = 2.4801587642e-05; /* 0x37d00d01 */ 29 | static const float C4 = -2.7557314297e-07; /* 0xb493f27c */ 30 | static const float C5 = 2.0875723372e-09; /* 0x310f74f6 */ 31 | static const float C6 = -1.1359647598e-11; /* 0xad47d74e */ 32 | 33 | GET_FLOAT_WORD(ix, x); 34 | ix &= IC(0x7fffffff); /* ix = |x|'s high word */ 35 | if (ix < IC(0x32000000)) 36 | { /* if x < 2**27 */ 37 | if (((int32_t) x) == 0) 38 | return one; /* generate inexact */ 39 | } 40 | z = x * x; 41 | r = z * (C1 + z * (C2 + z * (C3 + z * (C4 + z * (C5 + z * C6))))); 42 | if (ix < IC(0x3e99999a)) /* if |x| < 0.3 */ 43 | return one - (0.5f * z - (z * r - x * y)); 44 | else 45 | { 46 | if (ix > IC(0x3f480000)) 47 | { /* x > 0.78125 */ 48 | qx = 0.28125f; 49 | } else 50 | { 51 | SET_FLOAT_WORD(qx, ix - IC(0x01000000)); /* x/4 */ 52 | } 53 | hz = 0.5f * z - qx; 54 | 55 | a = one - qx; 56 | return a - (hz - (z * r - x * y)); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /s_frexp.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_frexp.c 1.4 95/01/18 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | /* 14 | * for non-zero x 15 | * x = frexp(arg,&exp); 16 | * return a double fp quantity x such that 0.5 <= |x| <1.0 17 | * and the corresponding binary exponent "exp". That is 18 | * arg = x*2^exp. 19 | * If arg is inf, 0.0, or NaN, then frexp(arg,&exp) returns arg 20 | * with *exp=0. 21 | */ 22 | 23 | #ifndef __FDLIBM_H__ 24 | #include "fdlibm.h" 25 | #endif 26 | 27 | #ifndef __have_fpu_frexp 28 | 29 | double __ieee754_frexp(double x, int *eptr) 30 | { 31 | int32_t hx, ix, lx; 32 | static const double two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */ 33 | 34 | GET_DOUBLE_WORDS(hx, lx, x); 35 | ix = UC(0x7fffffff) & hx; 36 | *eptr = 0; 37 | if (ix >= IC(0x7ff00000) || ((ix | lx) == 0)) 38 | return x; /* 0,inf,nan */ 39 | if (ix < IC(0x00100000)) 40 | { /* subnormal */ 41 | x *= two54; 42 | GET_HIGH_WORD(hx, x); 43 | ix = hx & UC(0x7fffffff); 44 | *eptr = -54; 45 | } 46 | *eptr += (int)(ix >> 20) - 1022; 47 | hx = (hx & UC(0x800fffff)) | UC(0x3fe00000); 48 | SET_HIGH_WORD(x, hx); 49 | return x; 50 | } 51 | 52 | #endif 53 | 54 | double __frexp(double x, int *exp) 55 | { 56 | return __ieee754_frexp(x, exp); 57 | } 58 | 59 | __typeof(__frexp) frexp __attribute__((weak, alias("__frexp"))); 60 | #ifdef __NO_LONG_DOUBLE_MATH 61 | long double __frexpl(long double x, int *expt) __attribute__((alias("__frexp"))); 62 | __typeof(__frexpl) frexpl __attribute__((weak, alias("__frexp"))); 63 | #endif 64 | -------------------------------------------------------------------------------- /tests/csign.c: -------------------------------------------------------------------------------- 1 | #include "testconfig.h" 2 | #ifdef HAVE_COPYSIGN 3 | #define TEST_FUNC_FF_F __MATH_PRECNAME(copysign) 4 | #include "testdriver.h" 5 | 6 | 7 | static test_ff_f_data const copysign_data[] = { 8 | { __LINE__, ZERO_P, HEXCONSTE(4, 0x4001, 0x80000000L, 0x00000000L), ZERO_P, NO_INEXACT_EXCEPTION }, 9 | { __LINE__, ZERO_P, HEXCONSTE(-4, 0xc001, 0x80000000L, 0x00000000L), ZERO_M, NO_INEXACT_EXCEPTION|FLAG_FAIL_ARANYM2 }, 10 | { __LINE__, ZERO_M, HEXCONSTE(4, 0x4001, 0x80000000L, 0x00000000L), ZERO_P, NO_INEXACT_EXCEPTION }, 11 | { __LINE__, ZERO_M, HEXCONSTE(-4, 0xc001, 0x80000000L, 0x00000000L), ZERO_M, NO_INEXACT_EXCEPTION|FLAG_FAIL_ARANYM2 }, 12 | 13 | { __LINE__, INF_P, ZERO_P, INF_P, NO_INEXACT_EXCEPTION }, 14 | { __LINE__, INF_P, ZERO_M, INF_M, NO_INEXACT_EXCEPTION }, 15 | { __LINE__, INF_M, ZERO_P, INF_P, NO_INEXACT_EXCEPTION }, 16 | { __LINE__, INF_M, ZERO_M, INF_M, NO_INEXACT_EXCEPTION }, 17 | 18 | { __LINE__, ZERO_P, INF_P, ZERO_P, NO_INEXACT_EXCEPTION }, 19 | { __LINE__, ZERO_P, ZERO_M, ZERO_M, NO_INEXACT_EXCEPTION|FLAG_FAIL_ARANYM2 }, 20 | { __LINE__, ZERO_M, INF_P, ZERO_P, NO_INEXACT_EXCEPTION }, 21 | { __LINE__, ZERO_M, ZERO_M, ZERO_M, NO_INEXACT_EXCEPTION|FLAG_FAIL_ARANYM2 }, 22 | 23 | /* XXX More correctly we would have to check the sign of the NaN. */ 24 | { __LINE__, QNAN_P, ZERO_P, QNAN_P, NO_INEXACT_EXCEPTION }, 25 | { __LINE__, QNAN_P, ZERO_M, QNAN_P, NO_INEXACT_EXCEPTION }, 26 | { __LINE__, QNAN_M, ZERO_P, QNAN_P, NO_INEXACT_EXCEPTION }, 27 | { __LINE__, QNAN_M, ZERO_M, QNAN_P, NO_INEXACT_EXCEPTION }, 28 | }; 29 | 30 | int main(int argc, char **argv) 31 | { 32 | int status; 33 | 34 | status = 0; 35 | 36 | test_init(argc, argv); 37 | 38 | status |= test_table_ff_f(copysign_data, ARRAY_SIZE(copysign_data), __FILE__); 39 | 40 | return status ? EXIT_FAILURE : EXIT_SUCCESS; 41 | } 42 | 43 | #else 44 | 45 | int main(void) 46 | { 47 | return 77; 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /s_tanhf.c: -------------------------------------------------------------------------------- 1 | /* s_tanhf.c -- float version of s_tanh.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 | #ifndef __FDLIBM_H__ 17 | #include "fdlibm.h" 18 | #endif 19 | 20 | #ifndef __have_fpu_tanh 21 | 22 | float __ieee754_tanhf(float x) 23 | { 24 | float t, z; 25 | int32_t jx, ix; 26 | 27 | static const float one = 1.0; 28 | static const float two = 2.0; 29 | static const float tiny = 1.0e-30; 30 | 31 | GET_FLOAT_WORD(jx, x); 32 | ix = jx & IC(0x7fffffff); 33 | 34 | /* x is INF or NaN */ 35 | if (!FLT_UWORD_IS_FINITE(ix)) 36 | { 37 | if (jx >= 0) 38 | return one / x + one; /* tanh(+-inf)=+-1 */ 39 | else 40 | return one / x - one; /* tanh(NaN) = NaN */ 41 | } 42 | 43 | /* |x| < 22 */ 44 | if (ix < IC(0x41b00000)) 45 | { /* |x|<22 */ 46 | if (ix == 0) 47 | return x; /* x == +-0 */ 48 | if (ix < IC(0x24000000)) /* |x|<2**-55 */ 49 | return x * (one + x); /* tanh(small) = small */ 50 | if (ix >= IC(0x3f800000)) 51 | { /* |x|>=1 */ 52 | t = expm1f(two * __ieee754_fabsf(x)); 53 | z = one - two / (t + two); 54 | } else 55 | { 56 | t = expm1f(-two * __ieee754_fabsf(x)); 57 | z = -t / (t + two); 58 | } 59 | /* |x| > 22, return +-1 */ 60 | } else 61 | { 62 | z = one - tiny; /* raised inexact flag */ 63 | } 64 | return (jx >= 0) ? z : -z; 65 | } 66 | 67 | #endif 68 | 69 | float __tanhf(float x) 70 | { 71 | return __ieee754_tanhf(x); 72 | } 73 | 74 | __typeof(__tanhf) tanhf __attribute__((weak, alias("__tanhf"))); 75 | -------------------------------------------------------------------------------- /e_acoshf.c: -------------------------------------------------------------------------------- 1 | /* e_acoshf.c -- float version of e_acosh.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 | #ifndef __FDLIBM_H__ 17 | #include "fdlibm.h" 18 | #endif 19 | 20 | #ifndef __have_fpu_acosh 21 | 22 | float __ieee754_acoshf(float x) 23 | { 24 | float t; 25 | int32_t hx; 26 | 27 | static const float one = 1.0; 28 | static const float ln2 = 6.9314718246e-01; /* 0x3f317218 */ 29 | 30 | GET_FLOAT_WORD(hx, x); 31 | if (hx < IC(0x3f800000)) 32 | { /* x < 1 */ 33 | return (x - x) / (x - x); 34 | } else if (hx >= IC(0x4d800000)) 35 | { /* x > 2**28 */ 36 | if (!FLT_UWORD_IS_FINITE(hx)) 37 | { /* x is inf of NaN */ 38 | return x + x; 39 | } 40 | return __ieee754_logf(x) + ln2; /* acosh(huge)=log(2x) */ 41 | } else if (hx == IC(0x3f800000)) 42 | { 43 | return 0.0f; /* acosh(1) = 0 */ 44 | } else if (hx > IC(0x40000000)) 45 | { /* 2**28 > x > 2 */ 46 | t = x * x; 47 | return __ieee754_logf(2.0F * x - one / (x + __ieee754_sqrtf(t - one))); 48 | } else 49 | { /* 1 one) 36 | return x; /* return x inexact except 0 */ 37 | } 38 | if (ix > IC(0x47000000)) 39 | { /* |x| > 2**14 */ 40 | if (!FLT_UWORD_IS_FINITE(ix)) 41 | return x + x; /* x is inf or NaN */ 42 | w = __ieee754_logf(__ieee754_fabsf(x)) + ln2; 43 | } else 44 | { 45 | float xa = __ieee754_fabsf(x); 46 | 47 | if (ix > IC(0x40000000)) 48 | { /* 2**14 > |x| > 2.0 */ 49 | w = __ieee754_logf(2.0f * xa + one / (__ieee754_sqrtf(xa * xa + one) + xa)); 50 | } else 51 | { /* 2.0 > |x| > 2**-14 */ 52 | float t = xa * xa; 53 | 54 | w = __ieee754_log1pf(xa + t / (one + __ieee754_sqrtf(one + t))); 55 | } 56 | } 57 | if (hx > 0) 58 | return w; 59 | return -w; 60 | } 61 | 62 | #endif 63 | 64 | float __asinhf(float x) 65 | { 66 | return __ieee754_asinhf(x); 67 | } 68 | 69 | __typeof(__asinhf) asinhf __attribute__((weak, alias("__asinhf"))); 70 | -------------------------------------------------------------------------------- /e_log2l.c: -------------------------------------------------------------------------------- 1 | /* Base 2 logarithm. 2 | Copyright (C) 2011-2013 Free Software Foundation, Inc. 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2.1 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . */ 16 | 17 | #ifndef __FDLIBM_H__ 18 | #include "fdlibm.h" 19 | #endif 20 | 21 | #ifndef __NO_LONG_DOUBLE_MATH 22 | 23 | #ifndef __have_fpu_log2 24 | 25 | long double __ieee754_log2l(long double x) 26 | { 27 | /* Decompose x into 28 | x = 2^e * y 29 | where 30 | e is an integer, 31 | 1/2 < y < 2. 32 | Then log2(x) = e + log2(y) = e + log(y)/log(2). */ 33 | int e; 34 | long double y; 35 | 36 | y = __ieee754_frexpl(x, &e); 37 | if (y < M_SQRT1_2l) 38 | { 39 | y = 2.0L * y; 40 | e = e - 1; 41 | } 42 | 43 | return (long double) e + __ieee754_logl(y) * M_LOG2El; 44 | } 45 | 46 | #endif 47 | 48 | /* wrapper log2(x) */ 49 | long double __log2l(long double x) 50 | { 51 | if (islessequal(x, 0.0) && _LIB_VERSION != _IEEE_) 52 | { 53 | if (x == 0.0) 54 | { 55 | feraiseexcept(FE_DIVBYZERO); 56 | return __kernel_standard_l(x, x, -HUGE_VALL, KMATHERRL_LOG2_ZERO); /* log2(0) */ 57 | } else 58 | { 59 | feraiseexcept(FE_INVALID); 60 | return __kernel_standard_l(x, x, __builtin_nanl(""), KMATHERRL_LOG2_MINUS); /* log2(x<0) */ 61 | } 62 | } 63 | 64 | return __ieee754_log2l(x); 65 | } 66 | 67 | __typeof(__log2l) log2l __attribute__((weak, alias("__log2l"))); 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /s_roundl.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __NO_LONG_DOUBLE_MATH 6 | 7 | #ifndef __have_fpu_round 8 | 9 | long double __ieee754_roundl(long double x) 10 | { 11 | int32_t j0; 12 | uint32_t se, i1, i0; 13 | 14 | static const long double hugeval = 1.0e4930L; 15 | 16 | GET_LDOUBLE_WORDS(se, i0, i1, x); 17 | j0 = (se & IEEE854_LONG_DOUBLE_MAXEXP) - IEEE854_LONG_DOUBLE_BIAS; 18 | if (j0 < 31) 19 | { 20 | if (j0 < 0) 21 | { 22 | math_force_eval(hugeval + x); 23 | se &= 0x8000; 24 | i0 = i1 = 0; 25 | if (j0 == -1) 26 | { 27 | se |= 0x3fff; 28 | i0 = UC(0x80000000); 29 | } 30 | } else 31 | { 32 | uint32_t i = UC(0x7fffffff) >> j0; 33 | uint32_t j; 34 | 35 | if (((i0 & i) | i1) == 0) 36 | /* X is integral. */ 37 | return x; 38 | 39 | /* Raise inexact if x != 0. */ 40 | math_force_eval(hugeval + x); 41 | j = i0 + (UC(0x40000000) >> j0); 42 | 43 | if (j < i0) 44 | se += 1; 45 | i0 = (j & ~i) | IC(0x80000000); 46 | i1 = 0; 47 | } 48 | } else if (j0 > 62) 49 | { 50 | if (j0 == (IEEE854_LONG_DOUBLE_MAXEXP - IEEE854_LONG_DOUBLE_BIAS)) 51 | /* Inf or NaN. */ 52 | return x + x; 53 | else 54 | return x; 55 | } else 56 | { 57 | uint32_t i = UC(0xffffffff) >> (j0 - 31); 58 | uint32_t j; 59 | 60 | if ((i1 & i) == 0) 61 | /* X is integral. */ 62 | return x; 63 | 64 | /* Raise inexact if x != 0. */ 65 | math_force_eval(hugeval + x); 66 | j = i1 + (UC(1) << (62 - j0)); 67 | 68 | if (j < i1) 69 | { 70 | uint32_t k = i0 + 1; 71 | 72 | if (k < i0) 73 | { 74 | se += 1; 75 | k |= UC(0x80000000); 76 | } 77 | i0 = k; 78 | } 79 | i1 = j; 80 | i1 &= ~i; 81 | } 82 | 83 | SET_LDOUBLE_WORDS(x, se, i0, i1); 84 | return x; 85 | } 86 | 87 | #endif 88 | 89 | long double __roundl(long double x) 90 | { 91 | return __ieee754_roundl(x); 92 | } 93 | 94 | __typeof(__roundl) roundl __attribute__((weak, alias("__roundl"))); 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /s_scalbln.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #if INT_MAX != LONG_MAX 6 | 7 | #ifndef __have_fpu_scalbn 8 | 9 | double __ieee754_scalbln(double x, long n) 10 | { 11 | int32_t k, hx, lx; 12 | 13 | static const double two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */ 14 | static const double twom54 = 5.55111512312578270212e-17; /* 0x3C900000, 0x00000000 */ 15 | static const double hugeval = 1.0e+300; 16 | static const double tiny = 1.0e-300; 17 | 18 | GET_DOUBLE_WORDS(hx, lx, x); 19 | k = (hx >> IEEE754_DOUBLE_SHIFT) & IEEE754_DOUBLE_MAXEXP; /* extract exponent */ 20 | if (k == 0) 21 | { /* 0 or subnormal x */ 22 | if ((lx | (hx & IC(0x7fffffff))) == 0) 23 | return x; /* +-0 */ 24 | x *= two54; 25 | GET_HIGH_WORD(hx, x); 26 | k = ((hx & IC(0x7ff00000)) >> IEEE754_DOUBLE_SHIFT) - 54; 27 | } 28 | if (k == IEEE754_DOUBLE_MAXEXP) 29 | return x + x; /* NaN or Inf */ 30 | if (n < IC(-50000)) 31 | return tiny * copysign(tiny, x); /* underflow */ 32 | if (n > IC(50000) || k + n > 0x7fe) 33 | return hugeval * copysign(hugeval, x); /* overflow */ 34 | /* Now k and n are bounded we know that k = k+n does not 35 | overflow. */ 36 | k = k + n; 37 | if (k > 0) /* normal result */ 38 | { 39 | SET_HIGH_WORD(x, (hx & UC(0x800fffff)) | (k << IEEE754_DOUBLE_SHIFT)); 40 | return x; 41 | } 42 | if (k <= -54) 43 | return tiny * copysign(tiny, x); /*underflow */ 44 | k += 54; /* subnormal result */ 45 | SET_HIGH_WORD(x, (hx & UC(0x800fffff)) | (k << IEEE754_DOUBLE_SHIFT)); 46 | return x * twom54; 47 | } 48 | 49 | #endif 50 | 51 | double __scalbln(double x, long n) 52 | { 53 | return __ieee754_scalbln(x, n); 54 | } 55 | 56 | __typeof(__scalbln) scalbln __attribute__((weak, alias("__scalbln"))); 57 | #ifdef __NO_LONG_DOUBLE_MATH 58 | __typeof(scalblnl) __scalblnl __attribute__((alias("__scalbln"))); 59 | __typeof(__scalblnl) scalblnl __attribute__((weak, alias("__scalbln"))); 60 | #endif 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /e_sqrtl.c: -------------------------------------------------------------------------------- 1 | /* Emulation for sqrtl. 2 | Contributed by Paolo Bonzini 3 | 4 | Copyright 2002-2003, 2007, 2009-2013 Free Software Foundation, Inc. 5 | 6 | This file was taken from gnulib. 7 | 8 | This program is free software: you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2.1 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. If not, see . */ 20 | 21 | 22 | #ifndef __FDLIBM_H__ 23 | #include "fdlibm.h" 24 | #endif 25 | 26 | #ifndef __NO_LONG_DOUBLE_MATH 27 | 28 | #ifndef __have_fpu_sqrt 29 | 30 | /* A simple Newton-Raphson method. */ 31 | long double __ieee754_sqrtl(long double x) 32 | { 33 | long double delta, y; 34 | int exponent; 35 | 36 | /* Check for NaN */ 37 | if (isnanl(x)) 38 | return x; 39 | 40 | /* Check for negative numbers */ 41 | if (x < 0.0L) 42 | return (long double) sqrt(-1); 43 | 44 | /* Check for zero and infinites */ 45 | if (x + x == x) 46 | return x; 47 | 48 | __ieee754_frexpl(x, &exponent); 49 | y = __ieee754_ldexpl(x, -exponent / 2); 50 | 51 | do 52 | { 53 | delta = y; 54 | y = (y + x / y) * 0.5L; 55 | delta -= y; 56 | } while (delta != 0.0L); 57 | 58 | return y; 59 | } 60 | 61 | #endif 62 | 63 | long double __sqrtl(long double x) 64 | { 65 | if (isless(x, 0.0) && _LIB_VERSION != _IEEE_) 66 | return __kernel_standard_l(x, x, __builtin_nanl(""), KMATHERRL_SQRT); /* sqrt(negative) */ 67 | return __ieee754_sqrtl(x); 68 | } 69 | 70 | __typeof(__sqrtl) sqrtl __attribute__((weak, alias("__sqrtl"))); 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /s_scalbnf.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __have_fpu_scalbn 6 | 7 | float __ieee754_scalbnf(float x, int n) 8 | { 9 | int32_t k, ix; 10 | 11 | static const float two25 = 3.355443200e+07; /* 0x4c000000 */ 12 | static const float twom25 = 2.9802322388e-08; /* 0x33000000 */ 13 | static const float hugeval = 1.0e+30; 14 | static const float tiny = 1.0e-30; 15 | 16 | GET_FLOAT_WORD(ix, x); 17 | k = (ix & UC(0x7f800000)) >> IEEE754_FLOAT_SHIFT; /* extract exponent */ 18 | if (k == 0) 19 | { /* 0 or subnormal x */ 20 | if ((ix & UC(0x7fffffff)) == 0) 21 | return x; /* +-0 */ 22 | x *= two25; 23 | GET_FLOAT_WORD(ix, x); 24 | k = ((ix & UC(0x7f800000)) >> IEEE754_FLOAT_SHIFT) - 25; 25 | } 26 | if (k == IEEE754_FLOAT_MAXEXP) 27 | return x + x; /* NaN or Inf */ 28 | if ((int32_t)n < IC(-30000)) 29 | return tiny * copysignf(tiny, x); /*underflow */ 30 | if ((int32_t)n > IC(30000) || k + n > 0xfe) 31 | return hugeval * copysignf(hugeval, x); /* overflow */ 32 | /* Now k and n are bounded we know that k = k+n does not 33 | overflow. */ 34 | k = k + n; 35 | if (k > 0) /* normal result */ 36 | { 37 | SET_FLOAT_WORD(x, (ix & UC(0x807fffff)) | (k << IEEE754_FLOAT_SHIFT)); 38 | return x; 39 | } 40 | if (k <= -25) 41 | return tiny * copysignf(tiny, x); /*underflow */ 42 | k += 25; /* subnormal result */ 43 | SET_FLOAT_WORD(x, (ix & UC(0x807fffff)) | (k << IEEE754_FLOAT_SHIFT)); 44 | return x * twom25; 45 | } 46 | 47 | #endif 48 | 49 | float __scalbnf(float x, int n) 50 | { 51 | return __ieee754_scalbnf(x, n); 52 | } 53 | 54 | __typeof(__scalbnf) scalbnf __attribute__((weak, alias("__scalbnf"))); 55 | 56 | #if INT_MAX == LONG_MAX 57 | float __scalblnf(float x, long n) __attribute__((alias("__scalbnf"))); 58 | float scalblnf(float x, long n) __attribute__((weak, alias("__scalblnf"))); 59 | #ifndef __have_fpu_scalbn 60 | float __ieee754_scalblnf(float x, long n) __attribute__((alias("__ieee754_scalbnf"))); 61 | #endif 62 | #endif 63 | -------------------------------------------------------------------------------- /s_modff.c: -------------------------------------------------------------------------------- 1 | /* s_modff.c -- float version of s_modf.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 | #ifndef __FDLIBM_H__ 17 | #include "fdlibm.h" 18 | #endif 19 | 20 | #ifndef __have_fpu_modf 21 | 22 | float __ieee754_modff(float x, float *iptr) 23 | { 24 | int32_t i0, j0; 25 | uint32_t i; 26 | 27 | static const float one = 1.0; 28 | 29 | GET_FLOAT_WORD(i0, x); 30 | j0 = ((i0 >> IEEE754_FLOAT_SHIFT) & IEEE754_FLOAT_MAXEXP) - IEEE754_FLOAT_BIAS; /* exponent of x */ 31 | if (j0 < IEEE754_FLOAT_SHIFT) 32 | { /* integer part in x */ 33 | if (j0 < 0) 34 | { /* |x|<1 */ 35 | SET_FLOAT_WORD(*iptr, i0 & IC(0x80000000)); /* *iptr = +-0 */ 36 | return x; 37 | } else 38 | { 39 | i = IC(0x007fffff) >> j0; 40 | if ((i0 & i) == 0) 41 | { /* x is integral */ 42 | uint32_t ix; 43 | 44 | *iptr = x; 45 | GET_FLOAT_WORD(ix, x); 46 | SET_FLOAT_WORD(x, ix & IC(0x80000000)); /* return +-0 */ 47 | return x; 48 | } else 49 | { 50 | SET_FLOAT_WORD(*iptr, i0 & (~i)); 51 | return x - *iptr; 52 | } 53 | } 54 | } else 55 | { /* no fraction part */ 56 | *iptr = x * one; 57 | /* We must handle NaNs separately. */ 58 | if (j0 == (IEEE754_FLOAT_MAXEXP - IEEE754_FLOAT_BIAS) && (i0 & IC(0x7fffff)) != 0) 59 | return x * one; 60 | SET_FLOAT_WORD(x, i0 & IC(0x80000000)); /* return +-0 */ 61 | return x; 62 | } 63 | } 64 | 65 | #endif 66 | 67 | float __modff(float x, float *iptr) 68 | { 69 | return __ieee754_modff(x, iptr); 70 | } 71 | 72 | __typeof(__modff) modff __attribute__((weak, alias("__modff"))); 73 | -------------------------------------------------------------------------------- /s_llroundf.c: -------------------------------------------------------------------------------- 1 | /* Round double value to long int. 2 | Copyright (C) 1997-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Ulrich Drepper , 1997. 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library; if not, see 18 | . */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | 24 | #ifndef __NO_LONGLONG 25 | 26 | long long int __llroundf(float x) 27 | { 28 | int32_t j0; 29 | uint32_t i; 30 | long long int result; 31 | int32_t sign; 32 | 33 | GET_FLOAT_WORD(i, x); 34 | j0 = ((i >> IEEE754_FLOAT_SHIFT) & IEEE754_FLOAT_MAXEXP) - IEEE754_FLOAT_BIAS; 35 | sign = (i & IC(0x80000000)) != 0 ? -1 : 1; 36 | i &= UC(0x7fffff); 37 | i |= UC(0x800000); 38 | 39 | if (j0 < (int32_t) (8 * sizeof(long long int)) - 1) 40 | { 41 | if (j0 < 0) 42 | return j0 < -1 ? 0 : sign; 43 | else if (j0 >= IEEE754_FLOAT_SHIFT) 44 | result = (long long int) i << (j0 - IEEE754_FLOAT_SHIFT); 45 | else 46 | { 47 | i += IC(0x400000) >> j0; 48 | 49 | result = i >> (IEEE754_FLOAT_SHIFT - j0); 50 | } 51 | } else 52 | { 53 | /* The number is too large. It is left implementation defined 54 | what happens. */ 55 | return (long long int) x; 56 | } 57 | 58 | if (sign < 0) 59 | result = -result; 60 | return result; 61 | } 62 | 63 | __typeof(__llroundf) llroundf __attribute__((weak, alias("__llroundf"))); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /s_scalbnl.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __NO_LONG_DOUBLE_MATH 6 | 7 | #ifndef __have_fpu_scalbn 8 | 9 | long double __ieee754_scalbnl(long double x, int n) 10 | { 11 | int32_t k, es, hx, lx; 12 | 13 | static const long double two64 = 1.8446744073709551616e19L; 14 | static const long double twom64 = 5.421010862427522170037e-20L; 15 | static const long double hugeval = 1.0e+4900L; 16 | static const long double tiny = 1.0e-4900L; 17 | 18 | GET_LDOUBLE_WORDS(es, hx, lx, x); 19 | k = es & IEEE854_LONG_DOUBLE_MAXEXP; /* extract exponent */ 20 | if (k == 0) 21 | { /* 0 or subnormal x */ 22 | if ((lx | (hx & UC(0x7fffffff))) == 0) 23 | return x; /* +-0 */ 24 | x *= two64; 25 | GET_LDOUBLE_EXP(hx, x); 26 | k = (hx & IEEE854_LONG_DOUBLE_MAXEXP) - 64; 27 | } 28 | if (k == IEEE854_LONG_DOUBLE_MAXEXP) 29 | return x + x; /* NaN or Inf */ 30 | if ((int32_t)n < IC(-30000)) 31 | return tiny * copysignl(tiny, x); 32 | if ((int32_t)n > IC(30000) || (k + n) > 0x7ffe) 33 | return hugeval * copysignl(hugeval, x); /* overflow */ 34 | /* Now k and n are bounded we know that k = k+n does not 35 | overflow. */ 36 | k = k + n; 37 | if (k > 0) /* normal result */ 38 | { 39 | SET_LDOUBLE_EXP(x, (es & 0x8000) | k); 40 | return x; 41 | } 42 | if (k <= -64) 43 | return tiny * copysignl(tiny, x); /*underflow */ 44 | k += 64; /* subnormal result */ 45 | SET_LDOUBLE_EXP(x, (es & 0x8000) | k); 46 | return x * twom64; 47 | } 48 | 49 | #endif 50 | 51 | long double __scalbnl(long double x, int n) 52 | { 53 | return __ieee754_scalbnl(x, n); 54 | } 55 | 56 | __typeof(__scalbnl) scalbnl __attribute__((weak, alias("__scalbnl"))); 57 | 58 | #if INT_MAX == LONG_MAX 59 | long double __scalblnl(long double x, long n) __attribute__((alias("__scalbnl"))); 60 | long double scalblnl(long double x, long n) __attribute__((weak, alias("__scalblnl"))); 61 | #ifndef __have_fpu_scalbn 62 | long double __ieee754_scalblnl(long double x, long n) __attribute__((alias("__ieee754_scalbnl"))); 63 | #endif 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /.scripts/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -x 2 | 3 | SERVER=web196@server43.webgo24.de 4 | UPLOAD_DIR=$SERVER:/home/www/snapshots 5 | 6 | if [ -z "${DEPLOY_ARCHIVE+x}" ] 7 | then 8 | # zip is default 9 | DEPLOY_ARCHIVE="zip" 10 | fi 11 | 12 | toolsuffix=${CROSS_TOOL##*-} 13 | 14 | if [ -n "${CPU_TARGET+x}" ] 15 | then 16 | ARCHIVE_NAME="${PROJECT_NAME}-${PROJECT_VERSION}-${SHORT_ID}-${CPU_TARGET}-${toolsuffix}.${DEPLOY_ARCHIVE}" 17 | else 18 | ARCHIVE_NAME="${PROJECT_NAME}-${PROJECT_VERSION}-${SHORT_ID}-${toolsuffix}.${DEPLOY_ARCHIVE}" 19 | fi 20 | ARCHIVE_PATH="${DEPLOY_DIR}/${ARCHIVE_NAME}" 21 | 22 | mkdir -p "${DEPLOY_DIR}" 23 | 24 | if [ "${DEPLOY_ARCHIVE}" = "tar.bz2" ] 25 | then 26 | cd ${INSTALL_DIR} && tar cjf ${ARCHIVE_PATH} * 27 | elif [ "${DEPLOY_ARCHIVE}" = "tar.xz" ] 28 | then 29 | cd ${INSTALL_DIR} && tar cJf ${ARCHIVE_PATH} * 30 | elif [ "${DEPLOY_ARCHIVE}" = "tar.gz" ] 31 | then 32 | cd ${INSTALL_DIR} && tar czf ${ARCHIVE_PATH} * 33 | else 34 | cd $(dirname ${INSTALL_DIR}) && zip -r -9 ${ARCHIVE_PATH} $(basename ${INSTALL_DIR}) 35 | fi 36 | 37 | cd - 38 | 39 | 40 | eval "$(ssh-agent -s)" 41 | 42 | PROJECT_DIR="$PROJECT_NAME" 43 | case $PROJECT_DIR in 44 | m68k-atari-mint-gcc) PROJECT_DIR=gcc ;; 45 | m68k-atari-mint-binutils-gdb) PROJECT_DIR=binutils ;; 46 | esac 47 | 48 | upload_file() { 49 | local from="$1" 50 | local to="$2" 51 | for i in 1 2 3 52 | do 53 | scp -o "StrictHostKeyChecking no" "$from" "$to" 54 | [ $? = 0 ] && return 0 55 | sleep 1 56 | done 57 | exit 1 58 | } 59 | 60 | link_file() { 61 | local from="$1" 62 | local to="$2" 63 | for i in 1 2 3 64 | do 65 | ssh -o "StrictHostKeyChecking no" $SERVER -- "cd www/snapshots/${PROJECT_DIR}; ln -sf $from $to" 66 | [ $? = 0 ] && return 0 67 | sleep 1 68 | done 69 | exit 1 70 | } 71 | 72 | upload_file "$ARCHIVE_PATH" "${UPLOAD_DIR}/${PROJECT_DIR}/${ARCHIVE_NAME}" 73 | if test -z "${CPU_TARGET}" 74 | then 75 | link_file "$ARCHIVE_NAME" "${PROJECT_DIR}-${toolsuffix}-latest.${DEPLOY_ARCHIVE}" 76 | fi 77 | 78 | echo ${PROJECT_NAME}-${PROJECT_VERSION}-${SHORT_ID} > .latest_version 79 | upload_file .latest_version "${UPLOAD_DIR}/${PROJECT_DIR}/.latest_version" 80 | -------------------------------------------------------------------------------- /s_lroundf.c: -------------------------------------------------------------------------------- 1 | /* Round double value to long int. 2 | Copyright (C) 1997-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Ulrich Drepper , 1997. 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library; if not, see 18 | . */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | 24 | #ifndef __have_fpu_lround 25 | 26 | long int __ieee754_lroundf(float x) 27 | { 28 | int32_t j0; 29 | uint32_t i; 30 | long int result; 31 | int32_t sign; 32 | 33 | GET_FLOAT_WORD(i, x); 34 | j0 = ((i >> IEEE754_FLOAT_SHIFT) & IEEE754_FLOAT_MAXEXP) - IEEE754_FLOAT_BIAS; 35 | sign = (i & IC(0x80000000)) != 0 ? -1 : 1; 36 | i &= UC(0x7fffff); 37 | i |= UC(0x800000); 38 | 39 | if (j0 < (int32_t) (8 * sizeof(long int)) - 1) 40 | { 41 | if (j0 < 0) 42 | return j0 < -1 ? 0 : sign; 43 | else if (j0 >= IEEE754_FLOAT_SHIFT) 44 | result = (long int) i << (j0 - IEEE754_FLOAT_SHIFT); 45 | else 46 | { 47 | i += UC(0x400000) >> j0; 48 | 49 | result = i >> (IEEE754_FLOAT_SHIFT - j0); 50 | } 51 | } else 52 | { 53 | /* The number is too large. It is left implementation defined 54 | what happens. */ 55 | return (long int) x; 56 | } 57 | 58 | if (sign < 0) 59 | result = -result; 60 | return result; 61 | } 62 | 63 | #endif 64 | 65 | long int __lroundf(float x) 66 | { 67 | return __ieee754_lroundf(x); 68 | } 69 | 70 | __typeof(__lroundf) lroundf __attribute__((weak, alias("__lroundf"))); 71 | -------------------------------------------------------------------------------- /e_ilogb.c: -------------------------------------------------------------------------------- 1 | /* @(#)s_ilogb.c 1.3 95/01/18 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunSoft, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | /* ilogb(double x) 14 | * return the binary exponent of non-zero x 15 | * ilogb(0) = FP_ILOGB0 16 | * ilogb(NaN) = FP_ILOGBNAN (no signal is raised) 17 | * ilogb(+-Inf) = INT_MAX (no signal is raised) 18 | */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | 24 | #ifndef __have_fpu_ilogb 25 | 26 | int __ieee754_ilogb(double x) 27 | { 28 | int32_t hx, lx, ix; 29 | 30 | GET_HIGH_WORD(hx, x); 31 | hx &= IC(0x7fffffff); 32 | if (hx < IC(0x00100000)) 33 | { 34 | GET_LOW_WORD(lx, x); 35 | if ((hx | lx) == 0) 36 | return FP_ILOGB0; /* ilogb(0) = FP_ILOGB0 */ 37 | /* subnormal x */ 38 | if (hx == 0) 39 | { 40 | for (ix = -1043; lx > 0; lx <<= 1) 41 | ix -= 1; 42 | } else 43 | { 44 | for (ix = -1022, hx <<= 11; hx > 0; hx <<= 1) 45 | ix -= 1; 46 | } 47 | return (int)ix; 48 | } 49 | if (hx < IC(0x7ff00000)) 50 | return (int)((hx >> IEEE754_DOUBLE_SHIFT) - IEEE754_DOUBLE_BIAS); 51 | #if FP_ILOGBNAN != INT_MAX 52 | /* ISO C99 requires ilogb(+-Inf) == INT_MAX. */ 53 | GET_LOW_WORD(lx, x); 54 | if (((hx ^ IC(0x7ff00000)) | lx) == 0) 55 | return INT_MAX; 56 | #endif 57 | return FP_ILOGBNAN; 58 | } 59 | 60 | #endif 61 | 62 | /* wrapper ilogb */ 63 | int __ilogb(double x) 64 | { 65 | int r = __ieee754_ilogb(x); 66 | 67 | if (r == FP_ILOGB0 || 68 | r == FP_ILOGBNAN || 69 | r == INT_MAX) 70 | { 71 | __kernel_standard(x, x, x, KMATHERR_ILOGB); 72 | } 73 | return r; 74 | } 75 | 76 | __typeof(__ilogb) ilogb __attribute__((weak, alias("__ilogb"))); 77 | #ifdef __NO_LONG_DOUBLE_MATH 78 | __typeof(__ilogbl) __ilogbl __attribute__((alias("__ilogb"))); 79 | __typeof(__ilogbl) ilogbl __attribute__((weak, alias("__ilogb"))); 80 | #endif 81 | -------------------------------------------------------------------------------- /e_exp2l.c: -------------------------------------------------------------------------------- 1 | /* Compute 2^x. 2 | Copyright (C) 2012-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with the GNU C Library; if not, see 17 | . */ 18 | 19 | #ifndef __FDLIBM_H__ 20 | #include "fdlibm.h" 21 | #endif 22 | 23 | #ifndef __NO_LONG_DOUBLE_MATH 24 | 25 | #ifndef __have_fpu_exp2 26 | 27 | long double __ieee754_exp2l(long double x) 28 | { 29 | if (isless(x, (long double) LDBL_MAX_EXP)) 30 | { 31 | if (isgreaterequal(x, (long double) (LDBL_MIN_EXP - LDBL_MANT_DIG - 1))) 32 | { 33 | int intx = (int) x; 34 | long double fractx = x - intx; 35 | 36 | return __ieee754_scalbnl(__ieee754_expm1l(M_LN2l * fractx) + 1.0L, intx); 37 | } 38 | /* Underflow or exact zero. */ 39 | if (isinf(x)) 40 | return 0; 41 | feraiseexcept(FE_UNDERFLOW); 42 | return 0; 43 | } 44 | /* Infinity, NaN or overflow. */ 45 | return LDBL_MAX * x; 46 | } 47 | 48 | #endif 49 | 50 | long double __exp2l(long double x) 51 | { 52 | long double z = __ieee754_exp2l(x); 53 | 54 | if (!isfinite(z) && isfinite(x) && _LIB_VERSION != _IEEE_) 55 | /* exp2 overflow: 244, exp2 underflow: 245 */ 56 | return __kernel_standard_l(x, x, z, signbit(x) ? KMATHERRL_EXP2_UNDERFLOW : KMATHERRL_EXP2_OVERFLOW); 57 | 58 | return z; 59 | } 60 | 61 | 62 | __typeof(__exp2l) exp2l __attribute__((weak, alias("__exp2l"))); 63 | __typeof(__exp2l) __pow2l __attribute__((alias("__exp2l"))); 64 | __typeof(__pow2l) pow2l __attribute__((weak, alias("__pow2l"))); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /s_ceill.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __NO_LONG_DOUBLE_MATH 6 | 7 | #ifndef __have_fpu_ceil 8 | 9 | long double __ieee754_ceill(long double x) 10 | { 11 | int32_t j0; 12 | uint32_t i, j, se, i0, i1, sx; 13 | 14 | static const long double hugeval = 1.0e4930L; 15 | 16 | GET_LDOUBLE_WORDS(se, i0, i1, x); 17 | sx = (se >> 15) & 1; 18 | j0 = (se & IEEE854_LONG_DOUBLE_MAXEXP) - IEEE854_LONG_DOUBLE_BIAS; 19 | if (j0 < 31) 20 | { 21 | if (j0 < 0) 22 | { /* raise inexact if x != 0 */ 23 | math_force_eval(hugeval + x); 24 | /* return 0*sign(x) if |x|<1 */ 25 | if (sx) 26 | { 27 | se = 0x8000; 28 | i0 = UC(0x80000000); 29 | i1 = 0; 30 | } else if ((i0 | i1) != 0) 31 | { 32 | se = 0x3fff; 33 | i0 = UC(0x80000000); 34 | i1 = 0; 35 | } 36 | } else 37 | { 38 | i = UC(0x7fffffff) >> j0; 39 | if (((i0 & i) | i1) == 0) 40 | return x; /* x is integral */ 41 | math_force_eval(hugeval + x); /* raise inexact flag */ 42 | if (sx == 0) 43 | { 44 | if (j0 > 0 && (i0 + (UC(0x80000000) >> j0)) > i0) 45 | i0 += UC(0x80000000) >> j0; 46 | else 47 | { 48 | i = UC(0x7fffffff); 49 | ++se; 50 | } 51 | } 52 | i0 &= (~i); 53 | i1 = 0; 54 | } 55 | } else if (j0 > 62) 56 | { 57 | if (j0 == (IEEE854_LONG_DOUBLE_MAXEXP - IEEE854_LONG_DOUBLE_BIAS)) 58 | return x + x; /* inf or NaN */ 59 | else 60 | return x; /* x is integral */ 61 | } else 62 | { 63 | i = UC(0xffffffff) >> (j0 - 31); 64 | if ((i1 & i) == 0) 65 | return x; /* x is integral */ 66 | math_force_eval(hugeval + x); /* raise inexact flag */ 67 | if (sx == 0) 68 | { 69 | if (j0 == 31) 70 | i0 += 1; 71 | else 72 | { 73 | j = i1 + (UC(1) << (63 - j0)); 74 | if (j < i1) 75 | i0 += 1; /* got a carry */ 76 | i1 = j; 77 | } 78 | } 79 | i1 &= (~i); 80 | } 81 | SET_LDOUBLE_WORDS(x, se, i0, i1); 82 | return x; 83 | } 84 | 85 | #endif 86 | 87 | long double __ceill(long double x) 88 | { 89 | return __ieee754_ceill(x); 90 | } 91 | 92 | __typeof(__ceill) ceill __attribute__((weak, alias("__ceill"))); 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /e_ilogbl.c: -------------------------------------------------------------------------------- 1 | /* s_ilogbl.c -- long double version of s_ilogb.c. 2 | * Conversion to long double by Ulrich Drepper, 3 | * Cygnus Support, drepper@cygnus.com. 4 | */ 5 | 6 | /* 7 | * ==================================================== 8 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 9 | * 10 | * Developed at SunPro, a Sun Microsystems, Inc. business. 11 | * Permission to use, copy, modify, and distribute this 12 | * software is freely granted, provided that this notice 13 | * is preserved. 14 | * ==================================================== 15 | */ 16 | 17 | /* ilogbl(long double x) 18 | * return the binary exponent of non-zero x 19 | * ilogbl(0) = FP_ILOGB0 20 | * ilogbl(NaN) = FP_ILOGBNAN (no signal is raised) 21 | * ilogbl(+-Inf) = INT_MAX (no signal is raised) 22 | */ 23 | 24 | #ifndef __FDLIBM_H__ 25 | #include "fdlibm.h" 26 | #endif 27 | 28 | #ifndef __NO_LONG_DOUBLE_MATH 29 | 30 | #ifndef __have_fpu_ilogb 31 | 32 | int __ieee754_ilogbl(long double x) 33 | { 34 | int32_t es, hx, lx, ix; 35 | 36 | GET_LDOUBLE_EXP(es, x); 37 | es &= 0x7fff; 38 | if (es == 0) 39 | { 40 | GET_LDOUBLE_WORDS(es, hx, lx, x); 41 | hx &= IC(0x7fffffff); 42 | if ((hx | lx) == 0) 43 | return FP_ILOGB0; /* ilogbl(0) = FP_ILOGB0 */ 44 | /* subnormal x */ 45 | if (hx == 0) 46 | { 47 | for (ix = -16414; lx > 0; lx <<= 1) 48 | ix -= 1; 49 | } else 50 | { 51 | for (ix = -16383, hx <<= 1; hx > 0; hx <<= 1) 52 | ix -= 1; 53 | } 54 | return (int)ix; 55 | } 56 | if (es < 0x7fff) 57 | return (int)es - 0x3fff; 58 | #if FP_ILOGBNAN != INT_MAX 59 | GET_LDOUBLE_WORDS(es, hx, lx, x); 60 | if (((hx & IC(0x7fffffff)) | lx) == 0) 61 | /* ISO C99 requires ilogbl(+-Inf) == INT_MAX. */ 62 | return INT_MAX; 63 | #endif 64 | return FP_ILOGBNAN; 65 | } 66 | 67 | #endif 68 | 69 | /* wrapper ilogbl */ 70 | int __ilogbl(long double x) 71 | { 72 | int r = __ieee754_ilogbl(x); 73 | 74 | if (r == FP_ILOGB0 || 75 | r == FP_ILOGBNAN || 76 | r == INT_MAX) 77 | { 78 | __kernel_standard_l(x, x, x, KMATHERRL_ILOGB); 79 | } 80 | return r; 81 | } 82 | 83 | __typeof(__ilogbl) ilogbl __attribute__((weak, alias("__ilogbl"))); 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /s_nextafterf.c: -------------------------------------------------------------------------------- 1 | /* s_nextafterf.c -- float version of s_nextafter.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 | #ifndef __FDLIBM_H__ 17 | #include "fdlibm.h" 18 | #endif 19 | 20 | float __nextafterf(float x, float y) 21 | { 22 | int32_t hx, hy, ix, iy; 23 | 24 | GET_FLOAT_WORD(hx, x); 25 | GET_FLOAT_WORD(hy, y); 26 | ix = hx & IC(0x7fffffff); /* |x| */ 27 | iy = hy & IC(0x7fffffff); /* |y| */ 28 | 29 | if ((ix > IC(0x7f800000)) || /* x is nan */ 30 | (iy > IC(0x7f800000))) /* y is nan */ 31 | return x + y; 32 | if (x == y) 33 | return y; /* x=y, return y */ 34 | if (ix == 0) 35 | { /* x == 0 */ 36 | float u; 37 | 38 | SET_FLOAT_WORD(x, (hy & IC(0x80000000)) | 1); /* return +-minsubnormal */ 39 | u = math_opt_barrier(x); 40 | u = u * u; 41 | math_force_eval(u); /* raise underflow flag */ 42 | return x; 43 | } 44 | if (hx >= 0) 45 | { /* x > 0 */ 46 | if (hx > hy) 47 | { /* x > y, x -= ulp */ 48 | hx -= 1; 49 | } else 50 | { /* x < y, x += ulp */ 51 | hx += 1; 52 | } 53 | } else 54 | { /* x < 0 */ 55 | if (hy >= 0 || hx > hy) 56 | { /* x < y, x -= ulp */ 57 | hx -= 1; 58 | } else 59 | { /* x > y, x += ulp */ 60 | hx += 1; 61 | } 62 | } 63 | hy = hx & IC(0x7f800000); 64 | if (hy >= IC(0x7f800000)) 65 | { 66 | x = x + x; /* overflow */ 67 | math_force_eval(x); 68 | return x; /* overflow */ 69 | } 70 | if (hy < IC(0x00800000)) 71 | { 72 | float u = x * x; /* underflow */ 73 | math_force_eval(u); /* raise underflow flag */ 74 | } 75 | SET_FLOAT_WORD(x, hx); 76 | return x; 77 | } 78 | 79 | __typeof(__nextafterf) nextafterf __attribute__((weak, alias("__nextafterf"))); 80 | -------------------------------------------------------------------------------- /e_sqrtf.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __have_fpu_sqrt 6 | 7 | float __ieee754_sqrtf(float x) 8 | { 9 | float z; 10 | int32_t sign = IC(0x80000000); 11 | int32_t ix, s, q, m, t, i; 12 | uint32_t r; 13 | 14 | static const float one = 1.0; 15 | static const float tiny = 1.0e-30; 16 | 17 | GET_FLOAT_WORD(ix, x); 18 | 19 | /* take care of Inf and NaN */ 20 | if ((ix & IC(0x7f800000)) == IC(0x7f800000)) 21 | { 22 | return x * x + x; /* sqrt(NaN)=NaN, sqrt(+inf)=+inf 23 | sqrt(-inf)=sNaN */ 24 | } 25 | /* take care of zero */ 26 | if (ix <= 0) 27 | { 28 | if ((ix & (~sign)) == 0) 29 | return x; /* sqrt(+-0) = +-0 */ 30 | else if (ix < 0) 31 | return (x - x) / (x - x); /* sqrt(-ve) = sNaN */ 32 | } 33 | /* normalize x */ 34 | m = (ix >> 23); 35 | if (m == 0) 36 | { /* subnormal x */ 37 | for (i = 0; (ix & IC(0x00800000)) == 0; i++) 38 | ix <<= 1; 39 | m -= i - 1; 40 | } 41 | m -= 127; /* unbias exponent */ 42 | ix = (ix & IC(0x007fffff)) | IC(0x00800000); 43 | if (m & 1) /* odd m, double x to make it even */ 44 | ix += ix; 45 | m >>= 1; /* m = [m/2] */ 46 | 47 | /* generate sqrt(x) bit by bit */ 48 | ix += ix; 49 | q = s = 0; /* q = sqrt(x) */ 50 | r = IC(0x01000000); /* r = moving bit from right to left */ 51 | 52 | while (r != 0) 53 | { 54 | t = s + r; 55 | if (t <= ix) 56 | { 57 | s = t + r; 58 | ix -= t; 59 | q += r; 60 | } 61 | ix += ix; 62 | r >>= 1; 63 | } 64 | 65 | /* use floating add to find out rounding direction */ 66 | if (ix != 0) 67 | { 68 | z = one - tiny; /* trigger inexact flag */ 69 | if (z >= one) 70 | { 71 | z = one + tiny; 72 | if (z > one) 73 | q += 2; 74 | else 75 | q += (q & 1); 76 | } 77 | } 78 | ix = (q >> 1) + IC(0x3f000000); 79 | ix += (m << 23); 80 | SET_FLOAT_WORD(z, ix); 81 | return z; 82 | } 83 | #endif 84 | 85 | float __sqrtf(float x) 86 | { 87 | if (isless(x, 0.0) && _LIB_VERSION != _IEEE_) 88 | return __kernel_standard_f(x, x, __builtin_nanf(""), KMATHERRF_SQRT); /* sqrt(negative) */ 89 | return __ieee754_sqrtf(x); 90 | } 91 | 92 | __typeof(__sqrtf) sqrtf __attribute__((weak, alias("__sqrtf"))); 93 | -------------------------------------------------------------------------------- /tests/signb.c: -------------------------------------------------------------------------------- 1 | #include "testconfig.h" 2 | #if defined(HAVE_SIGNBIT) || defined(HAVE___SIGNBIT) 3 | /* FIXME: that use in the function from mintlib */ 4 | #if defined(HAVE___SIGNBIT) && 0 5 | int __MATH_PRECNAME(__signbit)(REAL x); 6 | #define TEST_FUNC_F_I __MATH_PRECNAME(__signbit) 7 | #else 8 | /* FIXME: not declared */ 9 | #undef signbit 10 | int __MATH_PRECNAME(signbit)(REAL x); 11 | #define TEST_FUNC_F_I __MATH_PRECNAME(signbit) 12 | #endif 13 | #define INT_IS_BOOL 14 | #include "testdriver.h" 15 | 16 | /* make sure we don't test the builtin */ 17 | #undef signbit 18 | #undef __signbit 19 | 20 | static test_f_i_data const signbit_data[] = { 21 | { __LINE__, ZERO_P, 0, NO_INEXACT_EXCEPTION }, 22 | { __LINE__, ZERO_M, 1, NO_INEXACT_EXCEPTION|FLAG_FAIL_ARANYM2 }, 23 | { __LINE__, SUBNORM_P, 0, NO_INEXACT_EXCEPTION }, 24 | { __LINE__, SUBNORM_M, 1, NO_INEXACT_EXCEPTION }, 25 | { __LINE__, INF_P, 0, NO_INEXACT_EXCEPTION }, 26 | { __LINE__, INF_M, 1, NO_INEXACT_EXCEPTION }, 27 | { __LINE__, QNAN_P, 0, NO_INEXACT_EXCEPTION }, 28 | { __LINE__, QNAN_M, 1, NO_INEXACT_EXCEPTION }, 29 | { __LINE__, SNAN_P, 0, NO_INEXACT_EXCEPTION }, 30 | { __LINE__, SNAN_M, 1, NO_INEXACT_EXCEPTION }, 31 | { __LINE__, MAX_P, 0, NO_INEXACT_EXCEPTION }, 32 | { __LINE__, MAX_M, 1, NO_INEXACT_EXCEPTION }, 33 | { __LINE__, MIN_P, 0, NO_INEXACT_EXCEPTION }, 34 | { __LINE__, MIN_M, 1, NO_INEXACT_EXCEPTION }, 35 | 36 | { __LINE__, HEXCONSTE(10, 0x4002, 0xa0000000L, 0x00000000L), 0, NO_INEXACT_EXCEPTION }, 37 | { __LINE__, HEXCONSTE(-10, 0xc002, 0xa0000000L, 0x00000000L), 1, NO_INEXACT_EXCEPTION }, 38 | 39 | /* signbit (x) != 0 for x < 0. */ 40 | { __LINE__, HEXCONSTE(-1, 0xbfff, 0x80000000L, 0x00000000L), 1, NO_INEXACT_EXCEPTION }, 41 | /* signbit (x) == 0 for x >= 0. */ 42 | { __LINE__, HEXCONSTE(1, 0x3fff, 0x80000000L, 0x00000000L), 0, NO_INEXACT_EXCEPTION }, 43 | }; 44 | 45 | int main(int argc, char **argv) 46 | { 47 | int status; 48 | 49 | status = 0; 50 | 51 | test_init(argc, argv); 52 | 53 | status |= test_table_f_i(signbit_data, ARRAY_SIZE(signbit_data), __FILE__); 54 | (void)check_fp; 55 | 56 | return status ? EXIT_FAILURE : EXIT_SUCCESS; 57 | } 58 | 59 | #else 60 | 61 | int main(void) 62 | { 63 | return 77; 64 | } 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /e_sinhf.c: -------------------------------------------------------------------------------- 1 | /* e_sinhf.c -- float version of e_sinh.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 | #ifndef __FDLIBM_H__ 17 | #include "fdlibm.h" 18 | #endif 19 | 20 | #ifndef __have_fpu_sinh 21 | 22 | float __ieee754_sinhf(float x) 23 | { 24 | float t, w, h; 25 | int32_t ix, jx; 26 | 27 | static const float one = 1.0; 28 | static const float shuge = 1.0e37; 29 | 30 | GET_FLOAT_WORD(jx, x); 31 | ix = jx & IC(0x7fffffff); 32 | 33 | /* x is INF or NaN */ 34 | if (!FLT_UWORD_IS_FINITE(ix)) 35 | return x + x; 36 | 37 | h = 0.5; 38 | if (jx < 0) 39 | h = -h; 40 | /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */ 41 | if (ix < IC(0x41b00000)) 42 | { /* |x|<22 */ 43 | if (ix < IC(0x31800000)) /* |x|<2**-28 */ 44 | if (shuge + x > one) 45 | return x; /* sinh(tiny) = tiny with inexact */ 46 | t = __ieee754_expm1f(__ieee754_fabsf(x)); 47 | if (ix < IC(0x3f800000)) 48 | return h * (2.0f * t - t * t / (t + one)); 49 | return h * (t + t / (t + one)); 50 | } 51 | 52 | /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */ 53 | if (ix <= FLT_UWORD_LOG_MAX) 54 | return h * __ieee754_expf(__ieee754_fabsf(x)); 55 | 56 | /* |x| in [log(maxdouble), overflowthresold] */ 57 | if (ix <= FLT_UWORD_LOG_2MAX) 58 | { 59 | w = __ieee754_expf(0.5f * __ieee754_fabsf(x)); 60 | t = h * w; 61 | return t * w; 62 | } 63 | 64 | /* |x| > overflowthresold, sinh(x) overflow */ 65 | return x * shuge; 66 | } 67 | 68 | #endif 69 | 70 | float __sinhf(float x) 71 | { 72 | float z = __ieee754_sinhf(x); 73 | 74 | if (!isfinite(z) && isfinite(x) && _LIB_VERSION != _IEEE_) 75 | return __kernel_standard_f(x, x, z, KMATHERRF_SINH); /* sinh overflow */ 76 | 77 | return z; 78 | } 79 | 80 | __typeof(__sinhf) sinhf __attribute__((weak, alias("__sinhf"))); 81 | -------------------------------------------------------------------------------- /s_cbrtf.c: -------------------------------------------------------------------------------- 1 | /* Compute cubic root of float value. 2 | Copyright (C) 1997-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Dirk Alboth and 5 | Ulrich Drepper , 1997. 6 | 7 | The GNU C Library is free software; you can redistribute it and/or 8 | modify it under the terms of the GNU Lesser General Public 9 | License as published by the Free Software Foundation; either 10 | version 2.1 of the License, or (at your option) any later version. 11 | 12 | The GNU C Library is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | Lesser General Public License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public 18 | License along with the GNU C Library; if not, see 19 | . */ 20 | 21 | #ifndef __FDLIBM_H__ 22 | #include "fdlibm.h" 23 | #endif 24 | 25 | float __cbrtf(float x) 26 | { 27 | float xm, ym, u, t2; 28 | int xe; 29 | int x_class; 30 | 31 | static const float factor[5] = { 32 | 0.62996052494743658238361, /* 1 / 2^(2/3) */ 33 | 0.79370052598409973737585, /* 1 / 2^(1/3) */ 34 | 1.0, 35 | 1.2599210498948731647672, /* 2^(1/3) */ 36 | 1.5874010519681994747517 /* 2^(2/3) */ 37 | }; 38 | 39 | /* Reduce X. XM now is an range 1.0 to 0.5. */ 40 | xm = __ieee754_frexpf(__ieee754_fabsf(x), &xe); 41 | 42 | /* If X is not finite or is null return it (with raising exceptions 43 | if necessary. 44 | Note: *Our* version of `frexp' sets XE to zero if the argument is 45 | Inf or NaN. This is not portable but faster. */ 46 | if (xe == 0 && ((x_class = fpclassify(x)) == FP_ZERO || x_class == FP_NAN || x_class == FP_INFINITE)) 47 | return x + x; 48 | 49 | u = (0.492659620528969547F + (0.697570460207922770F - 0.191502161678719066F * xm) * xm); 50 | 51 | t2 = u * u * u; 52 | 53 | ym = u * (t2 + 2.0F * xm) / (2.0F * t2 + xm) * factor[2 + xe % 3]; 54 | 55 | return __ieee754_ldexpf(x > 0.0F ? ym : -ym, xe / 3); 56 | } 57 | 58 | __typeof(__cbrtf) cbrtf __attribute__((weak, alias("__cbrtf"))); 59 | -------------------------------------------------------------------------------- /s_floorl.c: -------------------------------------------------------------------------------- 1 | #ifndef __FDLIBM_H__ 2 | #include "fdlibm.h" 3 | #endif 4 | 5 | #ifndef __NO_LONG_DOUBLE_MATH 6 | 7 | #ifndef __have_fpu_floor 8 | 9 | long double __ieee754_floorl(long double x) 10 | { 11 | int32_t j0; 12 | uint32_t i, j, se, i0, i1, sx; 13 | 14 | static const long double hugeval = 1.0e4930L; 15 | 16 | GET_LDOUBLE_WORDS(se, i0, i1, x); 17 | sx = (se >> 15) & 1; 18 | j0 = (se & IEEE854_LONG_DOUBLE_MAXEXP) - IEEE854_LONG_DOUBLE_BIAS; 19 | if (j0 < 31) 20 | { 21 | if (j0 < 0) 22 | { /* raise inexact if x != 0 */ 23 | if (hugeval + x > 0.0) 24 | { /* return 0*sign(x) if |x|<1 */ 25 | if (sx == 0) 26 | { 27 | se = 0; 28 | i0 = i1 = 0; 29 | } else if (((se & IEEE854_LONG_DOUBLE_MAXEXP) | i0 | i1) != 0) 30 | { 31 | se = 0xbfff; 32 | i0 = IC(0x80000000); /* explicit */ 33 | i1 = 0; 34 | } 35 | } 36 | } else 37 | { 38 | i = UC(0x7fffffff) >> j0; 39 | if (((i0 & i) | i1) == 0) 40 | return x; /* x is integral */ 41 | if (hugeval + x > 0.0) 42 | { /* raise inexact flag */ 43 | if (sx) 44 | { 45 | if (j0 > 0 && (i0 + (UC(0x80000000) >> j0)) > i0) 46 | i0 += UC(0x80000000) >> j0; 47 | else 48 | { 49 | i = UC(0x7fffffff); 50 | ++se; 51 | } 52 | } 53 | i0 &= (~i); 54 | i1 = 0; 55 | } 56 | } 57 | } else if (j0 > 62) 58 | { 59 | if (j0 == (IEEE854_LONG_DOUBLE_MAXEXP - IEEE854_LONG_DOUBLE_BIAS)) 60 | return x + x; /* inf or NaN */ 61 | else 62 | return x; /* x is integral */ 63 | } else 64 | { 65 | i = UC(0xffffffff) >> (j0 - 31); 66 | if ((i1 & i) == 0) 67 | return x; /* x is integral */ 68 | if (hugeval + x > 0.0) 69 | { /* raise inexact flag */ 70 | if (sx) 71 | { 72 | if (j0 == 31) 73 | i0 += 1; 74 | else 75 | { 76 | j = i1 + (UC(1) << (63 - j0)); 77 | if (j < i1) 78 | i0 += 1; /* got a carry */ 79 | i1 = j; 80 | } 81 | } 82 | i1 &= (~i); 83 | } 84 | } 85 | SET_LDOUBLE_WORDS(x, se, i0, i1); 86 | return x; 87 | } 88 | 89 | #endif 90 | 91 | long double __floorl(long double x) 92 | { 93 | return __ieee754_floorl(x); 94 | } 95 | 96 | __typeof(__floorl) floorl __attribute__((weak, alias("__floorl"))); 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /e_remainderf.c: -------------------------------------------------------------------------------- 1 | /* e_remainderf.c -- float version of e_remainder.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 | #ifndef __FDLIBM_H__ 17 | #include "fdlibm.h" 18 | #endif 19 | 20 | #ifndef __have_fpu_remainder 21 | 22 | float __ieee754_remainderf(float x, float p) 23 | { 24 | int32_t hx, hp; 25 | uint32_t sx; 26 | float p_half; 27 | 28 | static const float zero = 0.0; 29 | 30 | GET_FLOAT_WORD(hx, x); 31 | GET_FLOAT_WORD(hp, p); 32 | sx = hx & IC(0x80000000); 33 | hp &= IC(0x7fffffff); 34 | hx &= IC(0x7fffffff); 35 | 36 | /* purge off exception values */ 37 | if (FLT_UWORD_IS_ZERO(hp) || !FLT_UWORD_IS_FINITE(hx) || FLT_UWORD_IS_NAN(hp)) 38 | return (x * p) / (x * p); 39 | 40 | if (hp <= FLT_UWORD_HALF_MAX) 41 | x = __ieee754_fmodf(x, p + p); /* now x < 2p */ 42 | if ((hx - hp) == 0) 43 | return zero * x; 44 | x = __ieee754_fabsf(x); 45 | p = __ieee754_fabsf(p); 46 | if (hp < IC(0x01000000)) 47 | { 48 | if (x + x > p) 49 | { 50 | x -= p; 51 | if (x + x >= p) 52 | x -= p; 53 | } 54 | } else 55 | { 56 | p_half = (float) 0.5 *p; 57 | 58 | if (x > p_half) 59 | { 60 | x -= p; 61 | if (x >= p_half) 62 | x -= p; 63 | } 64 | } 65 | GET_FLOAT_WORD(hx, x); 66 | SET_FLOAT_WORD(x, hx ^ sx); 67 | return x; 68 | } 69 | 70 | #endif 71 | 72 | /* wrapper remainder */ 73 | float __remainderf(float x, float y) 74 | { 75 | if (((y == 0.0F && !isnan(x)) 76 | || (isinf(x) && !isnan(y))) && _LIB_VERSION != _IEEE_) 77 | return __kernel_standard_f(x, y, y, KMATHERRF_REMAINDER); /* remainder domain */ 78 | 79 | return __ieee754_remainderf(x, y); 80 | } 81 | 82 | __typeof(__remainderf) remainderf __attribute__((weak, alias("__remainderf"))); 83 | __typeof(__remainderf) __dremf __attribute__((alias("__remainderf"))); 84 | __typeof(remainderf) dremf __attribute__((weak, alias("__dremf"))); 85 | -------------------------------------------------------------------------------- /fesetenv.c: -------------------------------------------------------------------------------- 1 | /* Install given floating-point environment. 2 | Copyright (C) 1997-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | Contributed by Andreas Schwab 5 | 6 | The GNU C Library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 2.1 of the License, or (at your option) any later version. 10 | 11 | The GNU C Library is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with the GNU C Library. If not, see 18 | . */ 19 | 20 | #ifndef __FDLIBM_H__ 21 | #include "fdlibm.h" 22 | #endif 23 | #include "fpu_ctrl.h" 24 | 25 | int __fesetenv(const fenv_t *envp) 26 | { 27 | fenv_t temp; 28 | 29 | /* Install the environment specified by ENVP. But there are a few 30 | values which we do not want to come from the saved environment. 31 | Therefore, we get the current environment and replace the values 32 | we want to use from the environment specified by the parameter. */ 33 | fegetenv(&temp); 34 | 35 | temp.__status_register &= ~FE_ALL_EXCEPT; 36 | temp.__control_register &= ~((FE_ALL_EXCEPT << 6) | FE_ROUNDING_MASK | FE_PRECISION_MASK); 37 | if (envp == FE_DFL_ENV) 38 | { 39 | temp.__control_register |= FE_TONEAREST | _FPU_EXTENDED; 40 | } else if (envp == FE_NOMASK_ENV) 41 | { 42 | temp.__control_register |= FE_ALL_EXCEPT << 6; 43 | temp.__control_register |= FE_TONEAREST | _FPU_EXTENDED; 44 | } else 45 | { 46 | temp.__control_register |= (envp->__control_register & ((FE_ALL_EXCEPT << 6) | FE_ROUNDING_MASK | FE_PRECISION_MASK)); 47 | temp.__status_register |= envp->__status_register & FE_ALL_EXCEPT; 48 | } 49 | 50 | _FPU_SETCW(temp.__control_register); 51 | _FPU_SETSR(temp.__status_register); 52 | 53 | /* Success. */ 54 | return 0; 55 | } 56 | 57 | __typeof(__fesetenv) fesetenv __attribute__((weak, alias("__fesetenv"))); 58 | -------------------------------------------------------------------------------- /include/bits/mathdef.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | The GNU C Library is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU Lesser General Public 6 | License as published by the Free Software Foundation; either 7 | version 2.1 of the License, or (at your option) any later version. 8 | 9 | The GNU C Library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Lesser General Public License for more details. 13 | 14 | You should have received a copy of the GNU Lesser General Public 15 | License along with the GNU C Library; if not, write to the Free 16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 | 02111-1307 USA. */ 18 | 19 | #if !defined _MATH_H && !defined _COMPLEX_H 20 | # error "Never use directly; include instead" 21 | #endif 22 | 23 | /* The m68k FPUs evaluate all values in the 96 bit floating-point format 24 | which is also available for the user as `long double'. Therefore we 25 | define: */ 26 | #ifndef __FLT_EVAL_METHOD__ 27 | # if defined(__HAVE_68881__) 28 | # define __FLT_EVAL_METHOD__ 2 29 | # elif defined(__HAVE_FPU__) /* coldfire, double == long double */ 30 | # define __FLT_EVAL_METHOD__ 1 31 | # else 32 | # define __FLT_EVAL_METHOD__ 0 33 | # endif 34 | #endif 35 | 36 | #if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF 37 | # define _MATH_H_MATHDEF 1 38 | 39 | #if __FLT_EVAL_METHOD__ == 0 40 | 41 | typedef float float_t; 42 | typedef double double_t; 43 | 44 | #elif __FLT_EVAL_METHOD__ == 1 45 | 46 | typedef double float_t; 47 | typedef double double_t; 48 | 49 | #elif __FLT_EVAL_METHOD__ == 2 50 | 51 | typedef long double float_t; /* `float' expressions are evaluated as 52 | `long double'. */ 53 | typedef long double double_t; /* `double' expressions are evaluated as 54 | `long double'. */ 55 | #endif 56 | 57 | #endif /* ISO C99 */ 58 | 59 | /* The values returned by `ilogb' for 0 and NaN respectively. */ 60 | #define FP_ILOGB0 (-__INT_MAX__ - 1) 61 | #define FP_ILOGBNAN (__INT_MAX__) 62 | --------------------------------------------------------------------------------