From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16140 invoked by alias); 9 Nov 2016 18:41:37 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 16060 invoked by uid 89); 9 Nov 2016 18:41:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL,BAYES_00,KAM_ASCII_DIVIDERS,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=murphy, yx, xx, 2411 X-HELO: mx0a-001b2d01.pphosted.com From: "Gabriel F. T. Gomes" To: libc-alpha@sourceware.org Subject: [PATCH 3/8] float128: Add wrappers for IEEE functions. Date: Wed, 09 Nov 2016 18:41:00 -0000 In-Reply-To: <1478716859-3246-1-git-send-email-gftg@linux.vnet.ibm.com> References: <1478716859-3246-1-git-send-email-gftg@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16110918-0032-0000-0000-000002ACEA90 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16110918-0033-0000-0000-00000F2CA9EE Message-Id: <1478716859-3246-4-git-send-email-gftg@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-11-09_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=4 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1611090343 X-SW-Source: 2016-11/txt/msg00355.txt.bz2 From: "Paul E. Murphy" These are copied from the long double version. posix style errors are assumed, and inlined. Where a function is not defined by TS 18661-3, the wrapper is not implemented. * sysdeps/ieee754/float128/w_acosf128.c: New file. * sysdeps/ieee754/float128/w_acoshf128.c: Likewise * sysdeps/ieee754/float128/w_asinf128.c: Likewise * sysdeps/ieee754/float128/w_atan2f128.c: Likewise * sysdeps/ieee754/float128/w_atanhf128.c: Likewise * sysdeps/ieee754/float128/w_coshf128.c: Likewise * sysdeps/ieee754/float128/w_exp10f128.c: Likewise * sysdeps/ieee754/float128/w_exp2f128.c: Likewise * sysdeps/ieee754/float128/w_expf128.c: Likewise * sysdeps/ieee754/float128/w_fmodf128.c: Likewise * sysdeps/ieee754/float128/w_hypotf128.c: Likewise * sysdeps/ieee754/float128/w_j0f128.c: Likewise * sysdeps/ieee754/float128/w_j1f128.c: Likewise * sysdeps/ieee754/float128/w_jnf128.c: Likewise * sysdeps/ieee754/float128/w_lgammaf128.c: Likewise * sysdeps/ieee754/float128/w_lgammaf128_r.c: Likewise * sysdeps/ieee754/float128/w_log10f128.c: Likewise * sysdeps/ieee754/float128/w_log2f128.c: Likewise * sysdeps/ieee754/float128/w_logf128.c: Likewise * sysdeps/ieee754/float128/w_powf128.c: Likewise * sysdeps/ieee754/float128/w_remainderf128.c: Likewise * sysdeps/ieee754/float128/w_sinhf128.c: Likewise * sysdeps/ieee754/float128/w_sqrtf128.c: Likewise * sysdeps/ieee754/float128/w_tgammaf128.c: Likewise * sysdeps/ieee754/float128/w_ilogbf128.c: Likewise * sysdeps/ieee754/float128/w_log1pf128.c: Likewise * sysdeps/ieee754/float128/w_scalbf128.c: Likewise * sysdeps/ieee754/float128/w_scalblnf128.c: Likewise --- sysdeps/ieee754/float128/w_acosf128.c | 35 ++++++++++++ sysdeps/ieee754/float128/w_acoshf128.c | 35 ++++++++++++ sysdeps/ieee754/float128/w_asinf128.c | 37 +++++++++++++ sysdeps/ieee754/float128/w_atan2f128.c | 35 ++++++++++++ sysdeps/ieee754/float128/w_atanhf128.c | 40 ++++++++++++++ sysdeps/ieee754/float128/w_coshf128.c | 33 ++++++++++++ sysdeps/ieee754/float128/w_exp10f128.c | 38 +++++++++++++ sysdeps/ieee754/float128/w_exp2f128.c | 36 +++++++++++++ sysdeps/ieee754/float128/w_expf128.c | 34 ++++++++++++ sysdeps/ieee754/float128/w_fmodf128.c | 37 +++++++++++++ sysdeps/ieee754/float128/w_hypotf128.c | 34 ++++++++++++ sysdeps/ieee754/float128/w_ilogbf128.c | 38 +++++++++++++ sysdeps/ieee754/float128/w_j0f128.c | 56 +++++++++++++++++++ sysdeps/ieee754/float128/w_j1f128.c | 55 +++++++++++++++++++ sysdeps/ieee754/float128/w_jnf128.c | 75 ++++++++++++++++++++++++++ sysdeps/ieee754/float128/w_lgammaf128.c | 34 ++++++++++++ sysdeps/ieee754/float128/w_lgammaf128_r.c | 34 ++++++++++++ sysdeps/ieee754/float128/w_log10f128.c | 44 +++++++++++++++ sysdeps/ieee754/float128/w_log1pf128.c | 36 +++++++++++++ sysdeps/ieee754/float128/w_log2f128.c | 44 +++++++++++++++ sysdeps/ieee754/float128/w_logf128.c | 44 +++++++++++++++ sysdeps/ieee754/float128/w_powf128.c | 86 ++++++++++++++++++++++++++++++ sysdeps/ieee754/float128/w_remainderf128.c | 35 ++++++++++++ sysdeps/ieee754/float128/w_scalbf128.c | 1 + sysdeps/ieee754/float128/w_scalblnf128.c | 36 +++++++++++++ sysdeps/ieee754/float128/w_sinhf128.c | 35 ++++++++++++ sysdeps/ieee754/float128/w_sqrtf128.c | 35 ++++++++++++ sysdeps/ieee754/float128/w_tgammaf128.c | 54 +++++++++++++++++++ 28 files changed, 1136 insertions(+) create mode 100644 sysdeps/ieee754/float128/w_acosf128.c create mode 100644 sysdeps/ieee754/float128/w_acoshf128.c create mode 100644 sysdeps/ieee754/float128/w_asinf128.c create mode 100644 sysdeps/ieee754/float128/w_atan2f128.c create mode 100644 sysdeps/ieee754/float128/w_atanhf128.c create mode 100644 sysdeps/ieee754/float128/w_coshf128.c create mode 100644 sysdeps/ieee754/float128/w_exp10f128.c create mode 100644 sysdeps/ieee754/float128/w_exp2f128.c create mode 100644 sysdeps/ieee754/float128/w_expf128.c create mode 100644 sysdeps/ieee754/float128/w_fmodf128.c create mode 100644 sysdeps/ieee754/float128/w_hypotf128.c create mode 100644 sysdeps/ieee754/float128/w_ilogbf128.c create mode 100644 sysdeps/ieee754/float128/w_j0f128.c create mode 100644 sysdeps/ieee754/float128/w_j1f128.c create mode 100644 sysdeps/ieee754/float128/w_jnf128.c create mode 100644 sysdeps/ieee754/float128/w_lgammaf128.c create mode 100644 sysdeps/ieee754/float128/w_lgammaf128_r.c create mode 100644 sysdeps/ieee754/float128/w_log10f128.c create mode 100644 sysdeps/ieee754/float128/w_log1pf128.c create mode 100644 sysdeps/ieee754/float128/w_log2f128.c create mode 100644 sysdeps/ieee754/float128/w_logf128.c create mode 100644 sysdeps/ieee754/float128/w_powf128.c create mode 100644 sysdeps/ieee754/float128/w_remainderf128.c create mode 100644 sysdeps/ieee754/float128/w_scalbf128.c create mode 100644 sysdeps/ieee754/float128/w_scalblnf128.c create mode 100644 sysdeps/ieee754/float128/w_sinhf128.c create mode 100644 sysdeps/ieee754/float128/w_sqrtf128.c create mode 100644 sysdeps/ieee754/float128/w_tgammaf128.c diff --git a/sysdeps/ieee754/float128/w_acosf128.c b/sysdeps/ieee754/float128/w_acosf128.c new file mode 100644 index 0000000..cedbc98 --- /dev/null +++ b/sysdeps/ieee754/float128/w_acosf128.c @@ -0,0 +1,35 @@ +/* Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +_Float128 +__acosf128 (_Float128 x) +{ + if (__builtin_expect (isgreater (fabsf128 (x), 1), 0)) + { + /* acos(|x|>1) */ + feraiseexcept (FE_INVALID); + __set_errno (EDOM); + return NAN; + } + + return __ieee754_acosf128 (x); +} +weak_alias (__acosf128, acosf128) diff --git a/sysdeps/ieee754/float128/w_acoshf128.c b/sysdeps/ieee754/float128/w_acoshf128.c new file mode 100644 index 0000000..3dea220 --- /dev/null +++ b/sysdeps/ieee754/float128/w_acoshf128.c @@ -0,0 +1,35 @@ +/* Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +static _Float128 zero = 0; + +_Float128 +__acoshf128 (_Float128 x) +{ + if (__builtin_expect (isless (x, 1), 0)) + { + /* acosh(x<1) */ + __set_errno (EDOM); + return zero / zero; + } + + return __ieee754_acoshf128 (x); +} +weak_alias (__acoshf128, acoshf128) diff --git a/sysdeps/ieee754/float128/w_asinf128.c b/sysdeps/ieee754/float128/w_asinf128.c new file mode 100644 index 0000000..e92f16a --- /dev/null +++ b/sysdeps/ieee754/float128/w_asinf128.c @@ -0,0 +1,37 @@ +/* Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + + +/* wrapper asinf128 */ +_Float128 +__asinf128 (_Float128 x) +{ + if (__builtin_expect (isgreater (fabsf128 (x), 1), 0)) + { + /* asin(|x|>1) */ + feraiseexcept (FE_INVALID); + __set_errno (EDOM); + return NAN; + } + + return __ieee754_asinf128 (x); +} +weak_alias (__asinf128, asinf128) diff --git a/sysdeps/ieee754/float128/w_atan2f128.c b/sysdeps/ieee754/float128/w_atan2f128.c new file mode 100644 index 0000000..c58183b --- /dev/null +++ b/sysdeps/ieee754/float128/w_atan2f128.c @@ -0,0 +1,35 @@ +/* Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * wrapper atan2f128(y,x) + */ + +#include +#include +#include + + +_Float128 +__atan2f128 (_Float128 y, _Float128 x) +{ + _Float128 z = __ieee754_atan2f128 (y, x); + if (__glibc_unlikely (z == 0 && y != 0 && isfinite (x))) + __set_errno (ERANGE); + return z; +} +weak_alias (__atan2f128, atan2f128) diff --git a/sysdeps/ieee754/float128/w_atanhf128.c b/sysdeps/ieee754/float128/w_atanhf128.c new file mode 100644 index 0000000..d997b0c --- /dev/null +++ b/sysdeps/ieee754/float128/w_atanhf128.c @@ -0,0 +1,40 @@ +/* Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +static _Float128 zero = 0; + +/* wrapper atanhf128 */ +_Float128 +__atanhf128 (_Float128 x) +{ + _Float128 fabs_x = fabsf128 (x); + if (__builtin_expect (isgreaterequal (fabs_x, 1), 0)) + { + if (fabs_x > 1) + { + __set_errno (EDOM); + return zero / zero; + } + __set_errno (ERANGE); + return x / zero; + } + return __ieee754_atanhf128 (x); +} +weak_alias (__atanhf128, atanhf128) diff --git a/sysdeps/ieee754/float128/w_coshf128.c b/sysdeps/ieee754/float128/w_coshf128.c new file mode 100644 index 0000000..09fdaa7 --- /dev/null +++ b/sysdeps/ieee754/float128/w_coshf128.c @@ -0,0 +1,33 @@ +/* w_acoshf128.c -- _Float128 version of w_acosh.c. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper coshf128(x) + */ + +#include +#include + +_Float128 +__coshf128 (_Float128 x) +{ + _Float128 z = __ieee754_coshf128 (x); + if (__builtin_expect (!isfinite (z), 0) && isfinite (x)) + { + __set_errno (ERANGE); + return HUGE_VAL_F128; + } + return z; +} +weak_alias (__coshf128, coshf128) diff --git a/sysdeps/ieee754/float128/w_exp10f128.c b/sysdeps/ieee754/float128/w_exp10f128.c new file mode 100644 index 0000000..8bbd850 --- /dev/null +++ b/sysdeps/ieee754/float128/w_exp10f128.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + + +/* + * wrapper exp10f128(x) + */ + +#include +#include + +_Float128 +__exp10f128 (_Float128 x) +{ + _Float128 z = __ieee754_exp10f128 (x); + if (__builtin_expect (!isfinite (z) || z == 0, 0) && isfinite (x)) + { + /* exp10f128 overflow if x > 0, underflow if x < 0. */ + __set_errno (ERANGE); + return signbit (x) == 0 ? HUGE_VAL_F128 : 0; + } + return z; +} +weak_alias (__exp10f128, exp10f128) diff --git a/sysdeps/ieee754/float128/w_exp2f128.c b/sysdeps/ieee754/float128/w_exp2f128.c new file mode 100644 index 0000000..59e7acd --- /dev/null +++ b/sysdeps/ieee754/float128/w_exp2f128.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* + * wrapper exp2f128(x) + */ + +#include +#include + +_Float128 +__exp2f128 (_Float128 x) +{ + _Float128 z = __ieee754_exp2f128 (x); + if (__builtin_expect (!isfinite (z) || z == 0, 0) && isfinite (x)) + { + __set_errno (ERANGE); + return signbit (x) == 0 ? HUGE_VAL_F128 : 0; + } + return z; +} +weak_alias (__exp2f128, exp2f128) diff --git a/sysdeps/ieee754/float128/w_expf128.c b/sysdeps/ieee754/float128/w_expf128.c new file mode 100644 index 0000000..4fe7426 --- /dev/null +++ b/sysdeps/ieee754/float128/w_expf128.c @@ -0,0 +1,34 @@ +/* w_expf128.c -- _Float128 version of w_exp.c. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper expf128(x) + */ + +#include +#include + +_Float128 +__expf128(_Float128 x) +{ + _Float128 z = __ieee754_expf128 (x); + if (__glibc_unlikely (!isfinite (z) || z == 0) && isfinite (x)) + { + __set_errno (ERANGE); + return signbit (x) == 0 ? HUGE_VAL_F128 : 0; + } + return z; +} +hidden_def (__expf128) +weak_alias (__expf128, expf128) diff --git a/sysdeps/ieee754/float128/w_fmodf128.c b/sysdeps/ieee754/float128/w_fmodf128.c new file mode 100644 index 0000000..82fcd51 --- /dev/null +++ b/sysdeps/ieee754/float128/w_fmodf128.c @@ -0,0 +1,37 @@ +/* Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +static _Float128 zero = 0; + +/* wrapper fmodf128 */ +_Float128 +__fmodf128 (_Float128 x, _Float128 y) +{ + if (__builtin_expect (isinf (x) || y == 0, 0) + && !isnan (y) && !isnan (x)) + { + /* fmod(+-Inf,y) or fmod(x,0) */ + __set_errno (EDOM); + return zero / zero; + } + + return __ieee754_fmodf128 (x, y); +} +weak_alias (__fmodf128, fmodf128) diff --git a/sysdeps/ieee754/float128/w_hypotf128.c b/sysdeps/ieee754/float128/w_hypotf128.c new file mode 100644 index 0000000..c497e16 --- /dev/null +++ b/sysdeps/ieee754/float128/w_hypotf128.c @@ -0,0 +1,34 @@ +/* w_hypotf128.c -- _Float128 version of w_hypot.c. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper hypotf128(x,y) + */ + +#include +#include + +_Float128 +__hypotf128(_Float128 x, _Float128 y) +{ + _Float128 z; + z = __ieee754_hypotf128 (x,y); + if(__builtin_expect (!isfinite (z), 0) && isfinite (x) && isfinite (y)) + { + __set_errno (ERANGE); + return HUGE_VAL_F128; + } + return z; +} +weak_alias (__hypotf128, hypotf128) diff --git a/sysdeps/ieee754/float128/w_ilogbf128.c b/sysdeps/ieee754/float128/w_ilogbf128.c new file mode 100644 index 0000000..9b162b2 --- /dev/null +++ b/sysdeps/ieee754/float128/w_ilogbf128.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2012-2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Adhemerval Zanella , 2011. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +/* wrapper ilogbf128 */ +int +__ilogbf128 (_Float128 x) +{ + int r = __ieee754_ilogbf128 (x); + if (__builtin_expect (r == FP_ILOGB0, 0) + || __builtin_expect (r == FP_ILOGBNAN, 0) + || __builtin_expect (r == INT_MAX, 0)) + { + __set_errno (EDOM); + feraiseexcept (FE_INVALID); + } + return r; +} +weak_alias (__ilogbf128, ilogbf128) diff --git a/sysdeps/ieee754/float128/w_j0f128.c b/sysdeps/ieee754/float128/w_j0f128.c new file mode 100644 index 0000000..cfd036d --- /dev/null +++ b/sysdeps/ieee754/float128/w_j0f128.c @@ -0,0 +1,56 @@ +/* Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + + +/* wrapper j0f128 */ +_Float128 +__j0f128 (_Float128 x) +{ + return __ieee754_j0f128 (x); +} +weak_alias (__j0f128, j0f128) + + +/* wrapper y0f128 */ +_Float128 +__y0f128 (_Float128 x) +{ + if (__builtin_expect (islessequal (x, 0) || isgreater (x, X_TLOSS), 0)) + { + if (x < 0) + { + /* d = zero/(x-x) */ + feraiseexcept (FE_INVALID); + __set_errno (EDOM); + return NAN; + } + else if (x == 0) + { + /* d = -one/(x-x) */ + feraiseexcept (FE_DIVBYZERO); + __set_errno (ERANGE); + return -HUGE_VAL_F128; + } + } + + return __ieee754_y0f128 (x); +} +weak_alias (__y0f128, y0f128) diff --git a/sysdeps/ieee754/float128/w_j1f128.c b/sysdeps/ieee754/float128/w_j1f128.c new file mode 100644 index 0000000..2a6b956 --- /dev/null +++ b/sysdeps/ieee754/float128/w_j1f128.c @@ -0,0 +1,55 @@ +/* Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + + +/* wrapper j1f128 */ +_Float128 +__j1f128 (_Float128 x) +{ + return __ieee754_j1f128 (x); +} +weak_alias (__j1f128, j1f128) + + +/* wrapper y1f128 */ +_Float128 +__y1f128 (_Float128 x) +{ + if (__builtin_expect (islessequal (x, 0) || isgreater (x, X_TLOSS), 0)) + { + if (x < 0) + { + /* d = zero/(x-x) */ + feraiseexcept (FE_INVALID); + __set_errno (EDOM); + return NAN; + } + else if (x == 0) + { + /* d = -one/(x-x) */ + feraiseexcept (FE_DIVBYZERO); + __set_errno (ERANGE); + return -HUGE_VAL_F128; + } + } + return __ieee754_y1f128 (x); +} +weak_alias (__y1f128, y1f128) diff --git a/sysdeps/ieee754/float128/w_jnf128.c b/sysdeps/ieee754/float128/w_jnf128.c new file mode 100644 index 0000000..5d59f78 --- /dev/null +++ b/sysdeps/ieee754/float128/w_jnf128.c @@ -0,0 +1,75 @@ +/* w_jnf128.c -- _Float128 version of w_jn.c. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper jn(int n, _Float128 x), yn(int n, _Float128 x) + * floating point Bessel's function of the 1st and 2nd kind + * of order n + * + * Special cases: + * y0(0)=y1(0)=yn(n,0) = -inf with division by zero signal; + * y0(-ve)=y1(-ve)=yn(n,-ve) are NaN with invalid signal. + * Note 2. About jn(n,x), yn(n,x) + * For n=0, j0(x) is called, + * for n=1, j1(x) is called, + * for nx, a continued fraction approximation to + * j(n,x)/j(n-1,x) is evaluated and then backward + * recursion is used starting from a supposed value + * for j(n,x). The resulting value of j(0,x) is + * compared with the actual value to correct the + * supposed value of j(n,x). + * + * yn(n,x) is similar in all respects, except + * that forward recursion is used for all + * values of n>1. + * + */ + +#include +#include + +_Float128 +__jnf128 (int n, _Float128 x) +{ + return __ieee754_jnf128 (n, x); +} +weak_alias (__jnf128, jnf128) + +_Float128 +__ynf128 (int n, _Float128 x) /* wrapper ynf128 */ +{ + _Float128 z = __ieee754_ynf128 (n, x); + if (isnan (x)) + return z; + + if (x <= 0) + { + if (x == 0) + { + /* d= -one/(x-x); */ + __set_errno (ERANGE); + return n < 0 && (n & 1) != 0 ? HUGE_VAL_F128 : -HUGE_VAL_F128; + } + else + { + /* d = zero/(x-x); */ + __set_errno (EDOM); + return NAN; + } + } + return z; +} +weak_alias (__ynf128, ynf128) diff --git a/sysdeps/ieee754/float128/w_lgammaf128.c b/sysdeps/ieee754/float128/w_lgammaf128.c new file mode 100644 index 0000000..cb23e65 --- /dev/null +++ b/sysdeps/ieee754/float128/w_lgammaf128.c @@ -0,0 +1,34 @@ +/* w_lgammaf128.c -- _Float128 version of w_lgamma.c. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper _Float128 lgammaf128(_Float128 x, int *signgamp) + */ + +#include +#include + +_Float128 +__lgammaf128 (_Float128 x) +{ + _Float128 y = __ieee754_lgammaf128_r (x, &__signgam); + if (__builtin_expect( !isfinite (y), 0) && isfinite (x)) + { + __set_errno (ERANGE); + return HUGE_VAL_F128; + } + return y; +} + +weak_alias (__lgammaf128, lgammaf128) diff --git a/sysdeps/ieee754/float128/w_lgammaf128_r.c b/sysdeps/ieee754/float128/w_lgammaf128_r.c new file mode 100644 index 0000000..626c6a8 --- /dev/null +++ b/sysdeps/ieee754/float128/w_lgammaf128_r.c @@ -0,0 +1,34 @@ +/* w_lgammaf128_r.c -- _Float128 version of w_lgamma_r.c. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper _Float128 lgammaf128_r(_Float128 x, int *signgamp) + */ + +#include +#include + + +_Float128 +__lgammaf128_r(_Float128 x, int *signgamp) +{ + _Float128 y = __ieee754_lgammaf128_r (x, signgamp); + if (__builtin_expect (!isfinite (y), 0) && isfinite (x)) + { + __set_errno (ERANGE); + return HUGE_VAL_F128; + } + return y; +} +weak_alias (__lgammaf128_r, lgammaf128_r) diff --git a/sysdeps/ieee754/float128/w_log10f128.c b/sysdeps/ieee754/float128/w_log10f128.c new file mode 100644 index 0000000..aeb0ffc --- /dev/null +++ b/sysdeps/ieee754/float128/w_log10f128.c @@ -0,0 +1,44 @@ +/* Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + + +/* wrapper log10f128(x) */ +_Float128 +__log10f128 (_Float128 x) +{ + if (__builtin_expect (islessequal (x, 0), 0)) + { + if (x == 0) + { + feraiseexcept (FE_DIVBYZERO); + __set_errno (ERANGE); + return -HUGE_VAL_F128; + } + else + { + feraiseexcept (FE_INVALID); + __set_errno (EDOM); + return NAN; + } + } + return __ieee754_log10f128 (x); +} +weak_alias (__log10f128, log10f128) diff --git a/sysdeps/ieee754/float128/w_log1pf128.c b/sysdeps/ieee754/float128/w_log1pf128.c new file mode 100644 index 0000000..359610c --- /dev/null +++ b/sysdeps/ieee754/float128/w_log1pf128.c @@ -0,0 +1,36 @@ +/* Wrapper for __log1pf128 that handles setting errno. + Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +_Float128 +__w_log1pf128 (_Float128 x) +{ + if (__glibc_unlikely (islessequal (x, -1))) + { + if (x == -1) + __set_errno (ERANGE); + else + __set_errno (EDOM); + } + + return __log1pf128 (x); +} +weak_alias (__w_log1pf128, log1pf128) diff --git a/sysdeps/ieee754/float128/w_log2f128.c b/sysdeps/ieee754/float128/w_log2f128.c new file mode 100644 index 0000000..8d28c58 --- /dev/null +++ b/sysdeps/ieee754/float128/w_log2f128.c @@ -0,0 +1,44 @@ +/* Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + + +/* wrapper log2f128(x) */ +_Float128 +__log2f128 (_Float128 x) +{ + if (__builtin_expect (islessequal (x, 0), 0)) + { + if (x == 0) + { + feraiseexcept (FE_DIVBYZERO); + __set_errno (ERANGE); + return -HUGE_VAL_F128; + } + else + { + feraiseexcept (FE_INVALID); + __set_errno (EDOM); + return NAN; + } + } + return __ieee754_log2f128 (x); +} +weak_alias (__log2f128, log2f128) diff --git a/sysdeps/ieee754/float128/w_logf128.c b/sysdeps/ieee754/float128/w_logf128.c new file mode 100644 index 0000000..d031013 --- /dev/null +++ b/sysdeps/ieee754/float128/w_logf128.c @@ -0,0 +1,44 @@ +/* Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + + +/* wrapper logf128(x) */ +_Float128 +__logf128 (_Float128 x) +{ + if (__builtin_expect (islessequal (x, 0), 0)) + { + if (x == 0) + { + feraiseexcept (FE_DIVBYZERO); + __set_errno (ERANGE); + return -HUGE_VAL_F128; + } + else + { + feraiseexcept (FE_INVALID); + __set_errno (EDOM); + return NAN; + } + } + return __ieee754_logf128 (x); +} +weak_alias (__logf128, logf128) diff --git a/sysdeps/ieee754/float128/w_powf128.c b/sysdeps/ieee754/float128/w_powf128.c new file mode 100644 index 0000000..e17aff1 --- /dev/null +++ b/sysdeps/ieee754/float128/w_powf128.c @@ -0,0 +1,86 @@ +/* Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +static _Float128 zero = 0; + +/* wrapper powf128 */ +_Float128 +__powf128 (_Float128 x, _Float128 y) +{ + _Float128 z = __ieee754_powf128 (x, y); + if (__glibc_unlikely (!isfinite (z))) + { + if (isnan (x)) + { + if (y == 0) + { + /* pow(NaN,0.0) */ + return 1; + } + } + else if (isfinite (x) && isfinite (y)) + { + if (isnan (z)) + { + /* pow neg**non-int */ + __set_errno (EDOM); + return zero / zero; + } + else if (x == 0 && y < 0) + { + __set_errno (ERANGE); + return signbit (x) && signbit (z) ? + -HUGE_VAL_F128 : HUGE_VAL_F128; + } + else + { + /* pow overflow */ + _Float128 retval = HUGE_VAL_F128; + y *= __f128 (0.5); + if (x < 0 && __rintf128 (y) != y) + retval = -HUGE_VAL_F128; + __set_errno (ERANGE); + return retval; + } + } + } + else if (__builtin_expect (z == 0, 0) && isfinite (x) && isfinite (y)) + { + if (x == 0) + { + if (y == 0) + { + return 1; + } + } + else + { + /* pow underflow */ + _Float128 retval = 0; + y *= __f128 (0.5); + if (x < 0 && __rintf128 (y) != y) + retval = __f128 (-0.0); + __set_errno (ERANGE); + return retval; + } + } + return z; +} +weak_alias (__powf128, powf128) diff --git a/sysdeps/ieee754/float128/w_remainderf128.c b/sysdeps/ieee754/float128/w_remainderf128.c new file mode 100644 index 0000000..dcd4661 --- /dev/null +++ b/sysdeps/ieee754/float128/w_remainderf128.c @@ -0,0 +1,35 @@ +/* Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +static _Float128 zero = 0; + +/* wrapper remainderf128 */ +_Float128 +__remainderf128 (_Float128 x, _Float128 y) +{ + if (((__builtin_expect (y == 0, 0) && !isnan (x)) + || (__builtin_expect (isinf (x), 0) && !isnan (y)))) + { + __set_errno (EDOM); + return zero / zero; + } + return __ieee754_remainderf128 (x, y); +} +weak_alias (__remainderf128, remainderf128) diff --git a/sysdeps/ieee754/float128/w_scalbf128.c b/sysdeps/ieee754/float128/w_scalbf128.c new file mode 100644 index 0000000..067b724 --- /dev/null +++ b/sysdeps/ieee754/float128/w_scalbf128.c @@ -0,0 +1 @@ +/* Not defined for _FloatN types. */ diff --git a/sysdeps/ieee754/float128/w_scalblnf128.c b/sysdeps/ieee754/float128/w_scalblnf128.c new file mode 100644 index 0000000..e4ef464 --- /dev/null +++ b/sysdeps/ieee754/float128/w_scalblnf128.c @@ -0,0 +1,36 @@ +/* Wrapper for __scalblnf128 handles setting errno. + Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +_Float128 +__w_scalblnf128 (_Float128 x, long int n) +{ + if (!isfinite (x) || x == 0) + return x + x; + + x = __scalblnf128 (x, n); + + if (!isfinite (x) || x == 0) + __set_errno (ERANGE); + + return x; +} +weak_alias (__w_scalblnf128, scalblnf128) diff --git a/sysdeps/ieee754/float128/w_sinhf128.c b/sysdeps/ieee754/float128/w_sinhf128.c new file mode 100644 index 0000000..df6515a --- /dev/null +++ b/sysdeps/ieee754/float128/w_sinhf128.c @@ -0,0 +1,35 @@ +/* w_sinhf128.c -- _Float128 version of w_sinh.c. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * wrapper sinhf128(x) + */ + +#include +#include + +static _Float128 zero = 0.0; + +_Float128 +__sinhf128 (_Float128 x) +{ + _Float128 z = __ieee754_sinhf128 (x); + if (__builtin_expect (!isfinite (z), 0) && isfinite (x)) + { + __set_errno (ERANGE); + return x > zero ? HUGE_VAL_F128 : -HUGE_VAL_F128; + } + return z; +} +weak_alias (__sinhf128, sinhf128) diff --git a/sysdeps/ieee754/float128/w_sqrtf128.c b/sysdeps/ieee754/float128/w_sqrtf128.c new file mode 100644 index 0000000..32c354c --- /dev/null +++ b/sysdeps/ieee754/float128/w_sqrtf128.c @@ -0,0 +1,35 @@ +/* Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +static _Float128 zero = 0; + +/* wrapper sqrtf128 */ +_Float128 +__sqrtf128 (_Float128 x) +{ + if (__builtin_expect (isless (x, 0), 0) && _LIB_VERSION != _IEEE_) + { + __set_errno (EDOM); + return zero / zero; + } + + return __ieee754_sqrtf128 (x); +} +weak_alias (__sqrtf128, sqrtf128) diff --git a/sysdeps/ieee754/float128/w_tgammaf128.c b/sysdeps/ieee754/float128/w_tgammaf128.c new file mode 100644 index 0000000..5699d66 --- /dev/null +++ b/sysdeps/ieee754/float128/w_tgammaf128.c @@ -0,0 +1,54 @@ +/* w_tgammaf128.c -- _Float128 version of w_gamma.c. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* _Float128 gammaf128(_Float128 x) + * Return the Gamma function of x. + */ + +#include +#include +#include + +_Float128 +__tgammaf128 (_Float128 x) +{ + int local_signgam; + _Float128 y = __ieee754_gammaf128_r (x, &local_signgam); + + if (__glibc_unlikely (!isfinite (y) || y == 0) + && (isfinite (x) || (isinf (x) && x < 0))) + { + if (x == 0) + { + __set_errno (ERANGE); + return __copysignf128 (HUGE_VAL_F128, x); + } + else if (__floorf128 (x) == x && x < 0) + { + __set_errno (EDOM); + return NAN; + } + else if (y == 0) + { + __set_errno (ERANGE); /* tgamma underflow */ + } + else + { + __set_errno (ERANGE); + return __copysignf128 (HUGE_VAL_F128, x); + } + } + return local_signgam < 0 ? - y : y; +} +weak_alias (__tgammaf128, tgammaf128) -- 2.4.11