Ticket #7007: 0002-Add-glibc-ilogbl-implemenation.patch
File 0002-Add-glibc-ilogbl-implemenation.patch, 7.0 KB (added by , 11 years ago) |
---|
-
new file src/system/libroot/posix/glibc/arch/generic/e_ilogbl.c
From 53cc623c5b2422c2e5805902bff39ffcad227764 Mon Sep 17 00:00:00 2001 From: Sam Toyer <sam@qxcv.net> Date: Sun, 2 Dec 2012 00:08:31 +1000 Subject: [PATCH 2/5] Add glibc ilogbl implemenation --- .../libroot/posix/glibc/arch/generic/e_ilogbl.c | 59 ++++++++++++++++++++ .../libroot/posix/glibc/arch/generic/w_ilogbl.c | 38 +++++++++++++ src/system/libroot/posix/glibc/arch/x86/Jamfile | 2 + src/system/libroot/posix/glibc/arch/x86_64/Jamfile | 24 ++++---- 4 files changed, 111 insertions(+), 12 deletions(-) create mode 100644 src/system/libroot/posix/glibc/arch/generic/e_ilogbl.c create mode 100644 src/system/libroot/posix/glibc/arch/generic/w_ilogbl.c diff --git a/src/system/libroot/posix/glibc/arch/generic/e_ilogbl.c b/src/system/libroot/posix/glibc/arch/generic/e_ilogbl.c new file mode 100644 index 0000000..0c7d9d5
- + 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 #if defined(LIBM_SCCS) && !defined(lint) 18 static char rcsid[] = "$NetBSD: $"; 19 #endif 20 21 /* ilogbl(long double x) 22 * return the binary exponent of non-zero x 23 * ilogbl(0) = FP_ILOGB0 24 * ilogbl(NaN) = FP_ILOGBNAN (no signal is raised) 25 * ilogbl(+-Inf) = INT_MAX (no signal is raised) 26 */ 27 28 #include <limits.h> 29 #include <math.h> 30 #include <math_private.h> 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 GET_LDOUBLE_WORDS(es,hx,lx,x); 40 if((hx|lx)==0) 41 return FP_ILOGB0; /* ilogbl(0) = FP_ILOGB0 */ 42 else /* subnormal x */ 43 if(hx==0) { 44 for (ix = -16415; lx>0; lx<<=1) ix -=1; 45 } else { 46 for (ix = -16383; hx>0; hx<<=1) ix -=1; 47 } 48 return ix; 49 } 50 else if (es<0x7fff) return es-0x3fff; 51 else if (FP_ILOGBNAN != INT_MAX) 52 { 53 GET_LDOUBLE_WORDS(es,hx,lx,x); 54 if (((hx & 0x7fffffff)|lx) == 0) 55 /* ISO C99 requires ilogbl(+-Inf) == INT_MAX. */ 56 return INT_MAX; 57 } 58 return FP_ILOGBNAN; 59 } -
new file src/system/libroot/posix/glibc/arch/generic/w_ilogbl.c
diff --git a/src/system/libroot/posix/glibc/arch/generic/w_ilogbl.c b/src/system/libroot/posix/glibc/arch/generic/w_ilogbl.c new file mode 100644 index 0000000..e02e78c
- + 1 /* Copyright (C) 2012 Free Software Foundation, Inc. 2 This file is part of the GNU C Library. 3 Contributed by Adhemerval Zanella <azanella@linux.vnet.ibm.com>, 2011. 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 <http://www.gnu.org/licenses/>. */ 18 19 #include <math.h> 20 #include <errno.h> 21 #include <limits.h> 22 #include <math_private.h> 23 24 /* wrapper ilogbl */ 25 int 26 __ilogbl (long double x) 27 { 28 int r = __ieee754_ilogbl (x); 29 if (__builtin_expect (r == FP_ILOGB0, 0) 30 || __builtin_expect (r == FP_ILOGBNAN, 0) 31 || __builtin_expect (r == INT_MAX, 0)) 32 { 33 __set_errno (EDOM); 34 /*feraiseexcept (FE_INVALID);*/ 35 } 36 return r; 37 } 38 weak_alias (__ilogbl, ilogbl) -
src/system/libroot/posix/glibc/arch/x86/Jamfile
diff --git a/src/system/libroot/posix/glibc/arch/x86/Jamfile b/src/system/libroot/posix/glibc/arch/x86/Jamfile index 4035668..3699585 100644
a b local genericSources = 34 34 e_j1.c e_j1f.c 35 35 e_jn.c e_jnf.c 36 36 e_hypotl.c 37 e_ilogbl.c 37 38 e_lgamma_r.c e_lgammaf_r.c e_lgammal_r.c 38 39 k_cos.c k_cosf.c 39 40 k_sin.c k_sinf.c … … local genericSources = 84 85 w_exp2.c w_exp2f.c w_exp2l.c 85 86 w_fmod.c w_fmodf.c w_fmodl.c 86 87 w_hypot.c w_hypotf.c w_hypotl.c 88 w_ilogbl.c 87 89 w_j0.c w_j0f.c 88 90 w_j1.c w_j1f.c 89 91 w_jn.c w_jnf.c -
src/system/libroot/posix/glibc/arch/x86_64/Jamfile
diff --git a/src/system/libroot/posix/glibc/arch/x86_64/Jamfile b/src/system/libroot/posix/glibc/arch/x86_64/Jamfile index 8be5c91..a0567f4 100644
a b local genericSources = 35 35 e_asinl.c e_atan2.c e_atan2f.c e_atanh.c e_atanhf.c e_atanhl.c e_cosh.c 36 36 e_coshf.c e_coshl.c e_exp.c e_exp10.c e_exp10f.c e_exp10l.c e_exp2.c 37 37 e_exp2f.c e_expf.c e_fmod.c e_fmodf.c e_gamma_r.c e_gammaf_r.c e_gammal_r.c 38 e_hypot.c e_hypotf.c e_hypotl.c e_ j0.c e_j0f.c e_j0l.c e_j1.c e_j1f.c39 e_j1 l.c e_jn.c e_jnf.c e_jnl.c e_lgamma_r.c e_lgammaf_r.c e_lgammal_r.c40 e_l og.c e_log10.c e_log10f.c e_log2.c e_log2f.c e_logf.c e_pow.c e_powf.c41 e_ rem_pio2.c e_rem_pio2f.c e_remainder.c e_remainderf.c e_scalb.c42 e_scalb f.c e_sinh.c e_sinhf.c e_sinhl.c38 e_hypot.c e_hypotf.c e_hypotl.c e_ilogbl.c e_j0.c e_j0f.c e_j0l.c e_j1.c 39 e_j1f.c e_j1l.c e_jn.c e_jnf.c e_jnl.c e_lgamma_r.c e_lgammaf_r.c 40 e_lgammal_r.c e_log.c e_log10.c e_log10f.c e_log2.c e_log2f.c e_logf.c 41 e_pow.c e_powf.c e_rem_pio2.c e_rem_pio2f.c e_remainder.c e_remainderf.c 42 e_scalb.c e_scalbf.c e_sinh.c e_sinhf.c e_sinhl.c 43 43 44 44 k_cos.c k_cosf.c k_rem_pio2.c k_rem_pio2f.c k_sin.c k_sinf.c k_tan.c 45 45 k_tanf.c … … local genericSources = 75 75 w_atanhl.c w_cosh.c w_coshf.c w_coshl.c w_drem.c w_dremf.c w_dreml.c 76 76 w_exp.c w_exp10.c w_exp10f.c w_exp10l.c w_exp2.c w_exp2f.c w_exp2l.c 77 77 w_expf.c w_expl.c w_fmod.c w_fmodf.c w_fmodl.c w_hypot.c w_hypotf.c 78 w_hypotl.c w_ j0.c w_j0f.c w_j0l.c w_j1.c w_j1f.c w_j1l.c w_jn.c w_jnf.c79 w_jn l.c w_lgamma.c w_lgamma_r.c w_lgammaf.c w_lgammaf_r.c w_lgammal.c80 w_lgammal _r.c w_log.c w_log10.c w_log10f.c w_log10l.c w_log2.c w_log2f.c81 w_log2 l.c w_logf.c w_logl.c w_pow.c w_powf.c w_powl.c w_remainder.c82 w_remainder f.c w_remainderl.c w_scalb.c w_scalbf.c w_scalbl.c w_sinh.c83 w_sinh f.c w_sinhl.c w_sqrt.c w_sqrtf.c w_sqrtl.c w_tgamma.c w_tgammaf.c84 w_tgamma l.c78 w_hypotl.c w_ilogbl.c w_j0.c w_j0f.c w_j0l.c w_j1.c w_j1f.c w_j1l.c w_jn.c 79 w_jnf.c w_jnl.c w_lgamma.c w_lgamma_r.c w_lgammaf.c w_lgammaf_r.c 80 w_lgammal.c w_lgammal_r.c w_log.c w_log10.c w_log10f.c w_log10l.c w_log2.c 81 w_log2f.c w_log2l.c w_logf.c w_logl.c w_pow.c w_powf.c w_powl.c 82 w_remainder.c w_remainderf.c w_remainderl.c w_scalb.c w_scalbf.c w_scalbl.c 83 w_sinh.c w_sinhf.c w_sinhl.c w_sqrt.c w_sqrtf.c w_sqrtl.c w_tgamma.c 84 w_tgammaf.c w_tgammal.c 85 85 ; 86 86 87 87