diff options
author | Joseph Myers <joseph@codesourcery.com> | 2016-10-15 00:36:48 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2016-10-15 00:36:48 +0000 |
commit | cc6a8d74575e36e2c9da8454dd1d23000c5455dd (patch) | |
tree | 8c7b1e3c8989409ef5ed166bbdf1cc97eaf7b7ef /sysdeps/ieee754/dbl-64 | |
parent | e223d1fe72e820d96f43831412ab267a1ace04d0 (diff) | |
download | glibc-cc6a8d74575e36e2c9da8454dd1d23000c5455dd.tar glibc-cc6a8d74575e36e2c9da8454dd1d23000c5455dd.tar.gz glibc-cc6a8d74575e36e2c9da8454dd1d23000c5455dd.tar.bz2 glibc-cc6a8d74575e36e2c9da8454dd1d23000c5455dd.zip |
Add totalordermag, totalordermagf, totalordermagl.
In addition to the totalorder functions, TS 18661-1 defines
totalordermag functions, which do the same comparison but on the
absolute values of the arguments. This patch implements these
functions for glibc, including the type-generic macro in <tgmath.h>.
In general the implementations are similar to but simpler than those
for the totalorder functions.
Tested for x86_64, x86, mips64 and powerpc.
* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(totalordermag): New declaration.
* math/tgmath.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (totalordermag):
New macro.
* math/Versions (totalordermag): New libm symbol at version
GLIBC_2.25.
(totalordermagf): Likewise.
(totalordermagl): Likewise.
* math/Makefile (libm-calls): Add s_totalordermagF.
* math/libm-test.inc (totalordermag_test_data): New array.
(totalordermag_test): New function.
(main): Call totalordermag_test.
* math/test-tgmath.c (NCALLS): Increase to 125.
(F(compile_test)): Call totalordermag.
(F(totalordermag)): New function.
* manual/arith.texi (FP Comparison Functions): Document
totalordermag, totalordermagf and totalordermagl.
* manual/libm-err-tab.pl: Update comment on interfaces without
ulps tabulated.
* sysdeps/ieee754/dbl-64/s_totalordermag.c: New file.
* sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c: Likewise.
* sysdeps/ieee754/flt-32/s_totalordermagf.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_totalordermagl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_totalordermagl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_totalordermagl.c: Likewise.
* sysdeps/ieee754/ldbl-opt/nldbl-totalordermag.c: Likewise.
* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add
totalordermag.
(CFLAGS-nldbl-totalordermag.c): New variable.
* sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c
(do_test): Also test totalordermagl.
* sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c (do_test):
Likewise.
* sysdeps/nacl/libm.abilist: Update.
* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
Diffstat (limited to 'sysdeps/ieee754/dbl-64')
-rw-r--r-- | sysdeps/ieee754/dbl-64/s_totalordermag.c | 48 | ||||
-rw-r--r-- | sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c | 46 |
2 files changed, 94 insertions, 0 deletions
diff --git a/sysdeps/ieee754/dbl-64/s_totalordermag.c b/sysdeps/ieee754/dbl-64/s_totalordermag.c new file mode 100644 index 0000000000..e41dade54a --- /dev/null +++ b/sysdeps/ieee754/dbl-64/s_totalordermag.c @@ -0,0 +1,48 @@ +/* Total order operation on absolute values. dbl-64 version. + 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 + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include <math_private.h> +#include <stdint.h> + +int +totalordermag (double x, double y) +{ + uint32_t hx, hy; + uint32_t lx, ly; + EXTRACT_WORDS (hx, lx, x); + EXTRACT_WORDS (hy, ly, y); + hx &= 0x7fffffff; + hy &= 0x7fffffff; +#ifdef HIGH_ORDER_BIT_IS_SET_FOR_SNAN + /* For the preferred quiet NaN convention, this operation is a + comparison of the representations of the absolute values of the + arguments. If both arguments are NaNs, invert the + quiet/signaling bit so comparing that way works. */ + if ((hx > 0x7ff00000 || (hx == 0x7ff00000 && lx != 0)) + && (hy > 0x7ff00000 || (hy == 0x7ff00000 && ly != 0))) + { + hx ^= 0x00080000; + hy ^= 0x00080000; + } +#endif + return hx < hy || (hx == hy && lx <= ly); +} +#ifdef NO_LONG_DOUBLE +weak_alias (totalordermag, totalordermagl) +#endif diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c new file mode 100644 index 0000000000..38f2e1ba8f --- /dev/null +++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c @@ -0,0 +1,46 @@ +/* Total order operation on absolute values. dbl-64/wordsize-64 version. + 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 + <http://www.gnu.org/licenses/>. */ + +#include <math.h> +#include <math_private.h> +#include <stdint.h> + +int +totalordermag (double x, double y) +{ + uint64_t ix, iy; + EXTRACT_WORDS64 (ix, x); + EXTRACT_WORDS64 (iy, y); + ix &= 0x7fffffffffffffffULL; + iy &= 0x7fffffffffffffffULL; +#ifdef HIGH_ORDER_BIT_IS_SET_FOR_SNAN + /* For the preferred quiet NaN convention, this operation is a + comparison of the representations of the absolute values of the + arguments. If both arguments are NaNs, invert the + quiet/signaling bit so comparing that way works. */ + if (ix > 0x7ff0000000000000ULL && iy > 0x7ff0000000000000ULL) + { + ix ^= 0x0008000000000000ULL; + iy ^= 0x0008000000000000ULL; + } +#endif + return ix <= iy; +} +#ifdef NO_LONG_DOUBLE +weak_alias (totalordermag, totalordermagl) +#endif |