about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2016-10-15 00:36:48 +0000
committerJoseph Myers <joseph@codesourcery.com>2016-10-15 00:36:48 +0000
commitcc6a8d74575e36e2c9da8454dd1d23000c5455dd (patch)
tree8c7b1e3c8989409ef5ed166bbdf1cc97eaf7b7ef
parente223d1fe72e820d96f43831412ab267a1ace04d0 (diff)
downloadglibc-cc6a8d74575e36e2c9da8454dd1d23000c5455dd.tar.gz
glibc-cc6a8d74575e36e2c9da8454dd1d23000c5455dd.tar.xz
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.
-rw-r--r--ChangeLog69
-rw-r--r--NEWS3
-rw-r--r--manual/arith.texi14
-rwxr-xr-xmanual/libm-err-tab.pl3
-rw-r--r--math/Makefile2
-rw-r--r--math/Versions1
-rw-r--r--math/bits/mathcalls.h4
-rw-r--r--math/libm-test.inc251
-rw-r--r--math/test-tgmath.c12
-rw-r--r--math/tgmath.h4
-rw-r--r--sysdeps/ieee754/dbl-64/s_totalordermag.c48
-rw-r--r--sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c46
-rw-r--r--sysdeps/ieee754/flt-32/s_totalordermagf.c43
-rw-r--r--sysdeps/ieee754/ldbl-128/s_totalordermagl.c47
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_totalordermagl.c63
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c11
-rw-r--r--sysdeps/ieee754/ldbl-96/s_totalordermagl.c50
-rw-r--r--sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c13
-rw-r--r--sysdeps/ieee754/ldbl-opt/Makefile3
-rw-r--r--sysdeps/ieee754/ldbl-opt/nldbl-totalordermag.c26
-rw-r--r--sysdeps/nacl/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/aarch64/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/alpha/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/arm/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/hppa/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/i386/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/ia64/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/microblaze/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips32/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/nios2/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/sh/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/64/libm.abilist3
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist3
47 files changed, 786 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 9e50bf4189..b383ba1176 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,72 @@
+2016-10-15  Joseph Myers  <joseph@codesourcery.com>
+
+	* 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.
+
 2016-10-14  Steve Ellcey  <sellcey@caviumnetworks.com>
 
 	* sysdeps/ieee754/dbl-64/e_pow.c (checkint) Make conditions explicitly
diff --git a/NEWS b/NEWS
index 22a5a5afd4..5251242736 100644
--- a/NEWS
+++ b/NEWS
@@ -55,7 +55,8 @@ Version 2.25
 
   - Classification macros: iscanonical, issubnormal, iszero.
 
-  - Total order functions: totalorder, totalorderf, totalorderl.
+  - Total order functions: totalorder, totalorderf, totalorderl,
+    totalordermag, totalordermagf, totalordermagl.
 
 * The <sys/quota.h> header now includes the <linux/quota.h> header.  Support
   for the Linux quota interface which predates kernel version 2.4.22 has
diff --git a/manual/arith.texi b/manual/arith.texi
index 75d34c8427..282ca45e08 100644
--- a/manual/arith.texi
+++ b/manual/arith.texi
@@ -1968,6 +1968,20 @@ increasing payload; positive quiet NaNs, in order of increasing
 payload.
 @end deftypefun
 
+@comment math.h
+@comment ISO
+@deftypefun int totalordermag (double @var{x}, double @var{y})
+@comment ISO
+@deftypefunx int totalordermagf (float @var{x}, float @var{y})
+@comment ISO
+@deftypefunx int totalordermagl (long double @var{x}, long double @var{y})
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+These functions determine whether the total order relationship,
+defined in IEEE 754-2008, is true for the absolute values of @var{x}
+and @var{y}, returning nonzero if it is true and zero if it is false.
+No exceptions are raised even for signaling NaNs.
+@end deftypefun
+
 Not all machines provide hardware support for these operations.  On
 machines that don't, the macros can be very slow.  Therefore, you should
 not use these functions when NaN is not a concern.
diff --git a/manual/libm-err-tab.pl b/manual/libm-err-tab.pl
index 9989605e5b..102ff7b03a 100755
--- a/manual/libm-err-tab.pl
+++ b/manual/libm-err-tab.pl
@@ -79,7 +79,8 @@ use vars qw (%results @all_floats %suffices @all_functions);
     "trunc", "y0", "y1", "yn" );
 # fpclassify, iscanonical, isnormal, isfinite, isinf, isnan, issignaling,
 # issubnormal, iszero, signbit, iseqsig, isgreater, isgreaterequal, isless,
-# islessequal, islessgreater, isunordered, totalorder are not tabulated.
+# islessequal, islessgreater, isunordered, totalorder, totalordermag
+# are not tabulated.
 
 if ($#ARGV == 0) {
   $sources = $ARGV[0];
diff --git a/math/Makefile b/math/Makefile
index ffaeb7c958..7c378fc5c3 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -72,7 +72,7 @@ libm-calls =								  \
 	s_fmaF s_lrintF s_llrintF s_lroundF s_llroundF e_exp10F w_log2F	  \
 	s_issignalingF $(calls:s_%=m_%) x2y2m1F				  \
 	gamma_productF lgamma_negF lgamma_productF			  \
-	s_nextupF s_totalorderF $(gen-libm-calls)
+	s_nextupF s_totalorderF s_totalordermagF $(gen-libm-calls)
 
 libm-compat-calls-ldouble-yes = w_lgamma_compatl k_standardl
 libm-compat-calls = w_lgamma_compatf w_lgamma_compat k_standard k_standardf \
diff --git a/math/Versions b/math/Versions
index 29246de94a..67e826a40e 100644
--- a/math/Versions
+++ b/math/Versions
@@ -218,5 +218,6 @@ libm {
     fesetexcept; fetestexceptflag; fegetmode; fesetmode;
     __iscanonicall; __iseqsigf; __iseqsig; __iseqsigl;
     totalorder; totalorderf; totalorderl;
+    totalordermag; totalordermagf; totalordermagl;
   }
 }
diff --git a/math/bits/mathcalls.h b/math/bits/mathcalls.h
index c800c2d27d..030130656c 100644
--- a/math/bits/mathcalls.h
+++ b/math/bits/mathcalls.h
@@ -390,6 +390,10 @@ __MATHDECL_1 (int, __issignaling,, (_Mdouble_ __value))
 /* Total order operation.  */
 __MATHDECL_1 (int, totalorder,, (_Mdouble_ __x, _Mdouble_ __y))
      __attribute__ ((__const__));
+
+/* Total order operation on absolute values.  */
+__MATHDECL_1 (int, totalordermag,, (_Mdouble_ __x, _Mdouble_ __y))
+     __attribute__ ((__const__));
 #endif
 
 #if defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 4ad0938ff7..91451bfa99 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -54,7 +54,7 @@
    pow, pow10, remainder, remquo, rint, lrint, llrint,
    round, lround, llround,
    scalb, scalbn, scalbln, signbit, sin, sincos, sinh, sqrt,
-   tan, tanh, tgamma, totalorder, trunc,
+   tan, tanh, tgamma, totalorder, totalordermag, trunc,
    y0, y1, yn, significand
 
    and for the following complex math functions:
@@ -12517,6 +12517,254 @@ totalorder_test (void)
 }
 
 
+static const struct test_ff_i_data totalordermag_test_data[] =
+  {
+    TEST_ff_b (totalordermag, minus_zero, minus_zero, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, minus_zero, plus_zero, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, minus_zero, 1, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, minus_zero, minus_infty, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, minus_zero, plus_infty, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, minus_zero, qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, minus_zero, -qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, minus_zero, snan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, minus_zero, -snan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_zero, minus_zero, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_zero, plus_zero, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_zero, 1, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_zero, minus_infty, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_zero, plus_infty, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_zero, qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_zero, -qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_zero, snan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_zero, -snan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 1, minus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 1, plus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 1, 1, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 1, minus_infty, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 1, plus_infty, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 1, qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 1, -qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 1, snan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 1, -snan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, minus_infty, minus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, minus_infty, plus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, minus_infty, 1, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, minus_infty, minus_infty, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, minus_infty, plus_infty, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, minus_infty, qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, minus_infty, -qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, minus_infty, snan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, minus_infty, -snan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_infty, minus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_infty, plus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_infty, 1, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_infty, minus_infty, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_infty, plus_infty, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_infty, qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_infty, -qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_infty, snan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_infty, -snan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value, minus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value, minus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value, plus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value, plus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value, 1, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value, 1, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value, minus_infty, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value, minus_infty, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value, plus_infty, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value, plus_infty, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value, minus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value, minus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value, plus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value, plus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value, 1, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value, 1, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value, minus_infty, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value, minus_infty, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value, plus_infty, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value, plus_infty, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value, qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value, -qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value, qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value, -qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value, qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value, -qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value, qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value, -qnan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value, snan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value, -snan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value, snan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value, -snan_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value, snan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value, -snan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value, snan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value, -snan_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, minus_zero, -min_subnorm_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, minus_zero, min_subnorm_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_zero, -min_subnorm_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, plus_zero, min_subnorm_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -min_subnorm_value, minus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -min_subnorm_value, plus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, min_subnorm_value, minus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, min_subnorm_value, plus_zero, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, min_value, max_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, min_value, -max_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -min_value, max_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -min_value, -max_value, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, max_value, min_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, max_value, -min_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -max_value, min_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -max_value, -min_value, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x1"), qnan_value_pl ("0x1"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x1"), qnan_value_pl ("0x2"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x1"), qnan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x2"), qnan_value_pl ("0x1"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x2"), qnan_value_pl ("0x2"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x2"), qnan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x3fffff"), qnan_value_pl ("0x1"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x3fffff"), qnan_value_pl ("0x2"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x3fffff"), qnan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x1"), -qnan_value_pl ("0x1"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x1"), -qnan_value_pl ("0x2"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x1"), -qnan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x2"), -qnan_value_pl ("0x1"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x2"), -qnan_value_pl ("0x2"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x2"), -qnan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x3fffff"), -qnan_value_pl ("0x1"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x3fffff"), -qnan_value_pl ("0x2"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x3fffff"), -qnan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x1"), qnan_value_pl ("0x1"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x1"), qnan_value_pl ("0x2"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x1"), qnan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x2"), qnan_value_pl ("0x1"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x2"), qnan_value_pl ("0x2"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x2"), qnan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x3fffff"), qnan_value_pl ("0x1"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x3fffff"), qnan_value_pl ("0x2"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x3fffff"), qnan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x1"), -qnan_value_pl ("0x1"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x1"), -qnan_value_pl ("0x2"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x1"), -qnan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x2"), -qnan_value_pl ("0x1"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x2"), -qnan_value_pl ("0x2"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x2"), -qnan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x3fffff"), -qnan_value_pl ("0x1"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x3fffff"), -qnan_value_pl ("0x2"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x3fffff"), -qnan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x1"), snan_value_pl ("0x1"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x1"), snan_value_pl ("0x2"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x1"), snan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x2"), snan_value_pl ("0x1"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x2"), snan_value_pl ("0x2"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x2"), snan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x3fffff"), snan_value_pl ("0x1"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x3fffff"), snan_value_pl ("0x2"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x3fffff"), snan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x1"), -snan_value_pl ("0x1"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x1"), -snan_value_pl ("0x2"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x1"), -snan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x2"), -snan_value_pl ("0x1"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x2"), -snan_value_pl ("0x2"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x2"), -snan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x3fffff"), -snan_value_pl ("0x1"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x3fffff"), -snan_value_pl ("0x2"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x3fffff"), -snan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x1"), snan_value_pl ("0x1"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x1"), snan_value_pl ("0x2"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x1"), snan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x2"), snan_value_pl ("0x1"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x2"), snan_value_pl ("0x2"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x2"), snan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x3fffff"), snan_value_pl ("0x1"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x3fffff"), snan_value_pl ("0x2"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x3fffff"), snan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x1"), -snan_value_pl ("0x1"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x1"), -snan_value_pl ("0x2"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x1"), -snan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x2"), -snan_value_pl ("0x1"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x2"), -snan_value_pl ("0x2"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x2"), -snan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x3fffff"), -snan_value_pl ("0x1"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x3fffff"), -snan_value_pl ("0x2"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x3fffff"), -snan_value_pl ("0x3fffff"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x3fffff"), qnan_value_pl ("0x1"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x3fffff"), -qnan_value_pl ("0x1"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x1"), snan_value_pl ("0x3fffff"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x1"), -snan_value_pl ("0x3fffff"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#if PAYLOAD_DIG >= 34
+    TEST_ff_b (totalordermag, qnan_value_pl ("0xffffffff"), qnan_value_pl ("0x100000000"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0xffffffff"), -qnan_value_pl ("0x100000000"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x100000000"), qnan_value_pl ("0xffffffff"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x100000000"), -qnan_value_pl ("0xffffffff"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0xffffffff"), snan_value_pl ("0x100000000"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0xffffffff"), -snan_value_pl ("0x100000000"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x100000000"), snan_value_pl ("0xffffffff"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x100000000"), -snan_value_pl ("0xffffffff"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x100000000"), qnan_value_pl ("0x200000000"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x100000000"), -qnan_value_pl ("0x200000000"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x200000000"), qnan_value_pl ("0x100000000"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x200000000"), -qnan_value_pl ("0x100000000"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x100000000"), snan_value_pl ("0x200000000"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x100000000"), -snan_value_pl ("0x200000000"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x200000000"), snan_value_pl ("0x100000000"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x200000000"), -snan_value_pl ("0x100000000"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#endif
+#if PAYLOAD_DIG >= 66
+    TEST_ff_b (totalordermag, qnan_value_pl ("0xffffffffffffffff"), qnan_value_pl ("0x10000000000000000"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0xffffffffffffffff"), -qnan_value_pl ("0x10000000000000000"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x10000000000000000"), qnan_value_pl ("0xffffffffffffffff"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x10000000000000000"), -qnan_value_pl ("0xffffffffffffffff"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0xffffffffffffffff"), snan_value_pl ("0x10000000000000000"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0xffffffffffffffff"), -snan_value_pl ("0x10000000000000000"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x10000000000000000"), snan_value_pl ("0xffffffffffffffff"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x10000000000000000"), -snan_value_pl ("0xffffffffffffffff"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x10000000000000000"), qnan_value_pl ("0x20000000000000000"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x10000000000000000"), -qnan_value_pl ("0x20000000000000000"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, qnan_value_pl ("0x20000000000000000"), qnan_value_pl ("0x10000000000000000"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -qnan_value_pl ("0x20000000000000000"), -qnan_value_pl ("0x10000000000000000"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x10000000000000000"), snan_value_pl ("0x20000000000000000"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x10000000000000000"), -snan_value_pl ("0x20000000000000000"), 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, snan_value_pl ("0x20000000000000000"), snan_value_pl ("0x10000000000000000"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, -snan_value_pl ("0x20000000000000000"), -snan_value_pl ("0x10000000000000000"), 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#endif
+    TEST_ff_b (totalordermag, 1, 0x1.000002p0, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 0x1.000002p0, 1, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 1, 0x0.ffffffp0, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 0x0.ffffffp0, 1, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#if MANT_DIG >= 53
+    TEST_ff_b (totalordermag, 1, 0x1.0000000000001p0, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 0x1.0000000000001p0, 1, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 1, 0x0.fffffffffffff8p0, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 0x0.fffffffffffff8p0, 1, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#endif
+#if MANT_DIG >= 64
+    TEST_ff_b (totalordermag, 1, 0x1.0000000000000002p0, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 0x1.0000000000000002p0, 1, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 1, 0x0.ffffffffffffffffp0, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 0x0.ffffffffffffffffp0, 1, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#endif
+#if MANT_DIG >= 106
+    TEST_ff_b (totalordermag, 1, 0x1.000000000000000000000000008p0, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 0x1.000000000000000000000000008p0, 1, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 1, 0x0.ffffffffffffffffffffffffffcp0, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 0x0.ffffffffffffffffffffffffffcp0, 1, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#endif
+#if MANT_DIG >= 113
+    TEST_ff_b (totalordermag, 1, 0x1.0000000000000000000000000001p0, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 0x1.0000000000000000000000000001p0, 1, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 1, 0x0.ffffffffffffffffffffffffffff8p0, 0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_b (totalordermag, 0x0.ffffffffffffffffffffffffffff8p0, 1, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+#endif
+  };
+
+static void
+totalordermag_test (void)
+{
+  ALL_RM_TEST (totalordermag, 1, totalordermag_test_data, RUN_TEST_LOOP_ff_b, END);
+}
+
+
 static const struct test_f_f_data trunc_test_data[] =
   {
     TEST_f_f (trunc, plus_infty, plus_infty, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
@@ -13181,6 +13429,7 @@ main (int argc, char **argv)
 
   /* Total order functions:  */
   totalorder_test ();
+  totalordermag_test ();
 
   /* Complex functions:  */
   cabs_test ();
diff --git a/math/test-tgmath.c b/math/test-tgmath.c
index a24058c9bd..a919c64aab 100644
--- a/math/test-tgmath.c
+++ b/math/test-tgmath.c
@@ -50,7 +50,7 @@ int count_cdouble;
 int count_cfloat;
 int count_cldouble;
 
-#define NCALLS     122
+#define NCALLS     125
 #define NCALLS_INT 4
 #define NCCALLS    47
 
@@ -286,6 +286,7 @@ F(compile_test) (void)
   a = fmin (fmin (x, a), fmin (c, b));
   b = fma (sin (a), sin (x), sin (c));
   a = totalorder (totalorder (x, b), totalorder (c, x));
+  b = totalordermag (totalordermag (x, a), totalordermag (c, x));
 
 #ifdef TEST_INT
   a = atan2 (i, b);
@@ -383,6 +384,7 @@ F(compile_test) (void)
       a = fmin (y, y);
       a = fma (y, y, y);
       a = totalorder (y, y);
+      a = totalordermag (y, y);
 
 #ifdef TEST_INT
       a = atan2 (i, y);
@@ -884,6 +886,14 @@ int
   return x + y;
 }
 
+int
+(F(totalordermag)) (TYPE x, TYPE y)
+{
+  ++count;
+  P ();
+  return x + y;
+}
+
 complex TYPE
 (F(cacos)) (complex TYPE x)
 {
diff --git a/math/tgmath.h b/math/tgmath.h
index 267e2921d5..0d51ae60be 100644
--- a/math/tgmath.h
+++ b/math/tgmath.h
@@ -441,6 +441,10 @@
 /* Total order operation.  */
 # define totalorder(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2,	\
 							   totalorder)
+
+/* Total order operation on absolute values.  */
+# define totalordermag(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, \
+							      totalordermag)
 #endif
 
 
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
diff --git a/sysdeps/ieee754/flt-32/s_totalordermagf.c b/sysdeps/ieee754/flt-32/s_totalordermagf.c
new file mode 100644
index 0000000000..7c01edc29a
--- /dev/null
+++ b/sysdeps/ieee754/flt-32/s_totalordermagf.c
@@ -0,0 +1,43 @@
+/* Total order operation on absolute values.  flt-32 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
+totalordermagf (float x, float y)
+{
+  uint32_t ix, iy;
+  GET_FLOAT_WORD (ix, x);
+  GET_FLOAT_WORD (iy, y);
+  ix &= 0x7fffffff;
+  iy &= 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 (ix > 0x7f800000 && iy > 0x7f800000)
+    {
+      ix ^= 0x00400000;
+      iy ^= 0x00400000;
+    }
+#endif
+  return ix <= iy;
+}
diff --git a/sysdeps/ieee754/ldbl-128/s_totalordermagl.c b/sysdeps/ieee754/ldbl-128/s_totalordermagl.c
new file mode 100644
index 0000000000..bcfeecd4c4
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128/s_totalordermagl.c
@@ -0,0 +1,47 @@
+/* Total order operation on absolute values.  ldbl-128 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
+totalordermagl (_Float128 x, _Float128 y)
+{
+  uint64_t hx, hy;
+  uint64_t lx, ly;
+  GET_LDOUBLE_WORDS64 (hx, lx, x);
+  GET_LDOUBLE_WORDS64 (hy, ly, y);
+  hx &= 0x7fffffffffffffffULL;
+  hy &= 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 ((hx > 0x7fff000000000000ULL || (hx == 0x7fff000000000000ULL
+				      && lx != 0))
+      && (hy > 0x7fff000000000000ULL || (hy == 0x7fff000000000000ULL
+					 && ly != 0)))
+    {
+      hx ^= 0x0000800000000000ULL;
+      hy ^= 0x0000800000000000ULL;
+    }
+#endif
+  return hx < hy || (hx == hy && lx <= ly);
+}
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_totalordermagl.c b/sysdeps/ieee754/ldbl-128ibm/s_totalordermagl.c
new file mode 100644
index 0000000000..509a23a669
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm/s_totalordermagl.c
@@ -0,0 +1,63 @@
+/* Total order operation on absolute values.  ldbl-128ibm 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
+totalordermagl (long double x, long double y)
+{
+  double xhi, xlo, yhi, ylo;
+  int64_t hx, hy, lx, ly;
+
+  ldbl_unpack (x, &xhi, &xlo);
+  EXTRACT_WORDS64 (hx, xhi);
+  ldbl_unpack (y, &yhi, &ylo);
+  EXTRACT_WORDS64 (hy, yhi);
+#ifdef HIGH_ORDER_BIT_IS_SET_FOR_SNAN
+# error not implemented
+#endif
+  uint64_t x_sign = hx & 0x8000000000000000ULL;
+  uint64_t y_sign = hy & 0x8000000000000000ULL;
+  hx ^= x_sign;
+  hy ^= y_sign;
+  if (hx < hy)
+    return 1;
+  else if (hx > hy)
+    return 0;
+
+  /* The high doubles are identical.  If they are NaNs or both the low
+     parts are zero, the low parts are not significant (and if they
+     are infinities, both the low parts must be zero).  */
+  if (hx >= 0x7ff0000000000000ULL)
+    return 1;
+  EXTRACT_WORDS64 (lx, xlo);
+  EXTRACT_WORDS64 (ly, ylo);
+  if (((lx | ly) & 0x7fffffffffffffffULL) == 0)
+    return 1;
+  lx ^= x_sign;
+  ly ^= y_sign;
+
+  /* Otherwise compare the low parts.  */
+  uint64_t lx_sign = lx >> 63;
+  uint64_t ly_sign = ly >> 63;
+  lx ^= lx_sign >> 1;
+  ly ^= ly_sign >> 1;
+  return lx <= ly;
+}
diff --git a/sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c b/sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c
index 78b162c4fc..8e61a89f53 100644
--- a/sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c
+++ b/sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c
@@ -1,4 +1,4 @@
-/* Test totalorderl for ldbl-128ibm.
+/* Test totalorderl and totalordermagl for ldbl-128ibm.
    Copyright (C) 2016 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -55,6 +55,15 @@ do_test (void)
 	  printf ("FAIL: test %zu\n", i);
 	  result = 1;
 	}
+      to1 = totalordermagl (ldx, ldy);
+      to2 = totalordermagl (ldy, ldx);
+      if (to1 && to2)
+	printf ("PASS: test %zu (totalordermagl)\n", i);
+      else
+	{
+	  printf ("FAIL: test %zu (totalordermagl)\n", i);
+	  result = 1;
+	}
     }
 
   return result;
diff --git a/sysdeps/ieee754/ldbl-96/s_totalordermagl.c b/sysdeps/ieee754/ldbl-96/s_totalordermagl.c
new file mode 100644
index 0000000000..0167f0fb81
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-96/s_totalordermagl.c
@@ -0,0 +1,50 @@
+/* Total order operation on absolute values.  ldbl-96 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 <float.h>
+#include <math.h>
+#include <math_private.h>
+#include <stdint.h>
+
+int
+totalordermagl (long double x, long double y)
+{
+  uint16_t expx, expy;
+  uint32_t hx, hy;
+  uint32_t lx, ly;
+  GET_LDOUBLE_WORDS (expx, hx, lx, x);
+  GET_LDOUBLE_WORDS (expy, hy, ly, y);
+  expx &= 0x7fff;
+  expy &= 0x7fff;
+  if (LDBL_MIN_EXP == -16382)
+    {
+      /* M68K variant: for the greatest exponent, the high mantissa
+	 bit is not significant and both values of it are valid, so
+	 set it before comparing.  For the Intel variant, only one
+	 value of the high mantissa bit is valid for each exponent, so
+	 this is not necessary.  */
+      if (expx == 0x7fff)
+	hx |= 0x80000000;
+      if (expy == 0x7fff)
+	hy |= 0x80000000;
+    }
+#ifdef HIGH_ORDER_BIT_IS_SET_FOR_SNAN
+# error not implemented
+#endif
+  return expx < expy || (expx == expy && (hx < hy || (hx == hy && lx <= ly)));
+}
diff --git a/sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c b/sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c
index 07fa772414..6afc1b5c1b 100644
--- a/sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c
+++ b/sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c
@@ -1,4 +1,4 @@
-/* Test totalorderl for ldbl-96.
+/* Test totalorderl and totalordermagl for ldbl-96.
    Copyright (C) 2016 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -62,6 +62,17 @@ do_test (void)
 	    printf ("FAIL: test %zu\n", i);
 	    result = 1;
 	  }
+	to1 = totalordermagl (ldx, ldy);
+	to2 = totalordermagl (ldy, ldx);
+	to3 = totalordermagl (ldnx, ldny);
+	to4 = totalordermagl (ldny, ldnx);
+	if (to1 && to2 && to3 && to4)
+	  printf ("PASS: test %zu (totalordermagl)\n", i);
+	else
+	  {
+	    printf ("FAIL: test %zu (totalordermagl)\n", i);
+	    result = 1;
+	  }
       }
 
   return result;
diff --git a/sysdeps/ieee754/ldbl-opt/Makefile b/sysdeps/ieee754/ldbl-opt/Makefile
index 12255d6951..4c7db9e353 100644
--- a/sysdeps/ieee754/ldbl-opt/Makefile
+++ b/sysdeps/ieee754/ldbl-opt/Makefile
@@ -41,7 +41,7 @@ libnldbl-calls = asprintf dprintf fprintf fscanf fwprintf fwscanf iovfscanf \
 		 isoc99_vscanf isoc99_vfscanf isoc99_vsscanf \
 		 isoc99_wscanf isoc99_fwscanf isoc99_swscanf \
 		 isoc99_vwscanf isoc99_vfwscanf isoc99_vswscanf \
-		 nextup nextdown totalorder
+		 nextup nextdown totalorder totalordermag
 libnldbl-routines = $(libnldbl-calls:%=nldbl-%)
 libnldbl-inhibit-o = $(object-suffixes)
 libnldbl-static-only-routines = $(libnldbl-routines)
@@ -143,6 +143,7 @@ CFLAGS-nldbl-tan.c = -fno-builtin-tanl
 CFLAGS-nldbl-tanh.c = -fno-builtin-tanhl
 CFLAGS-nldbl-tgamma.c = -fno-builtin-tgammal
 CFLAGS-nldbl-totalorder.c = -fno-builtin-totalorderl
+CFLAGS-nldbl-totalordermag.c = -fno-builtin-totalordermagl
 CFLAGS-nldbl-trunc.c = -fno-builtin-truncl
 CFLAGS-nldbl-y0.c = -fno-builtin-y0l
 CFLAGS-nldbl-y1.c = -fno-builtin-y1l
diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-totalordermag.c b/sysdeps/ieee754/ldbl-opt/nldbl-totalordermag.c
new file mode 100644
index 0000000000..2780383aea
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/nldbl-totalordermag.c
@@ -0,0 +1,26 @@
+/* Compatibility routine for IEEE double as long double for totalordermag.
+   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 "nldbl-compat.h"
+
+double
+attribute_hidden
+totalordermagl (double x, double y)
+{
+  return totalordermag (x, y);
+}
diff --git a/sysdeps/nacl/libm.abilist b/sysdeps/nacl/libm.abilist
index 8f01f60887..190ba085ba 100644
--- a/sysdeps/nacl/libm.abilist
+++ b/sysdeps/nacl/libm.abilist
@@ -389,3 +389,6 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
diff --git a/sysdeps/unix/sysv/linux/aarch64/libm.abilist b/sysdeps/unix/sysv/linux/aarch64/libm.abilist
index 32a464ac50..1fd3fb62b8 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libm.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libm.abilist
@@ -421,3 +421,6 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
diff --git a/sysdeps/unix/sysv/linux/alpha/libm.abilist b/sysdeps/unix/sysv/linux/alpha/libm.abilist
index 3c7ed06bf4..b1e79fcab0 100644
--- a/sysdeps/unix/sysv/linux/alpha/libm.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libm.abilist
@@ -431,6 +431,9 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
 GLIBC_2.3.4 GLIBC_2.3.4 A
 GLIBC_2.3.4 __c1_cabsf F
 GLIBC_2.3.4 __c1_cacosf F
diff --git a/sysdeps/unix/sysv/linux/arm/libm.abilist b/sysdeps/unix/sysv/linux/arm/libm.abilist
index df07c0813f..0592b847c4 100644
--- a/sysdeps/unix/sysv/linux/arm/libm.abilist
+++ b/sysdeps/unix/sysv/linux/arm/libm.abilist
@@ -78,6 +78,9 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
 GLIBC_2.4 GLIBC_2.4 A
 GLIBC_2.4 _LIB_VERSION D 0x4
 GLIBC_2.4 __clog10 F
diff --git a/sysdeps/unix/sysv/linux/hppa/libm.abilist b/sysdeps/unix/sysv/linux/hppa/libm.abilist
index 8843496ece..0557b1083a 100644
--- a/sysdeps/unix/sysv/linux/hppa/libm.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libm.abilist
@@ -390,5 +390,8 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
 GLIBC_2.4 GLIBC_2.4 A
 GLIBC_2.4 exp2l F
diff --git a/sysdeps/unix/sysv/linux/i386/libm.abilist b/sysdeps/unix/sysv/linux/i386/libm.abilist
index d190600993..06993220fc 100644
--- a/sysdeps/unix/sysv/linux/i386/libm.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libm.abilist
@@ -434,4 +434,7 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
 GLIBC_2.4 GLIBC_2.4 A
diff --git a/sysdeps/unix/sysv/linux/ia64/libm.abilist b/sysdeps/unix/sysv/linux/ia64/libm.abilist
index 134ac93610..67d722f35d 100644
--- a/sysdeps/unix/sysv/linux/ia64/libm.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libm.abilist
@@ -363,4 +363,7 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
 GLIBC_2.4 GLIBC_2.4 A
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist
index df07c0813f..0592b847c4 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist
@@ -78,6 +78,9 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
 GLIBC_2.4 GLIBC_2.4 A
 GLIBC_2.4 _LIB_VERSION D 0x4
 GLIBC_2.4 __clog10 F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist
index 92330262a5..65dee5a212 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist
@@ -432,4 +432,7 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
 GLIBC_2.4 GLIBC_2.4 A
diff --git a/sysdeps/unix/sysv/linux/microblaze/libm.abilist b/sysdeps/unix/sysv/linux/microblaze/libm.abilist
index c2e2341007..eef3ebf9d8 100644
--- a/sysdeps/unix/sysv/linux/microblaze/libm.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/libm.abilist
@@ -389,3 +389,6 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/libm.abilist b/sysdeps/unix/sysv/linux/mips/mips32/libm.abilist
index 0711143030..9c62c802a5 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/libm.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/libm.abilist
@@ -391,6 +391,9 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
 GLIBC_2.4 GLIBC_2.4 A
 GLIBC_2.4 exp2l F
 _gp_disp _gp_disp A
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/libm.abilist b/sysdeps/unix/sysv/linux/mips/mips64/libm.abilist
index 8a8c95b529..d9e3a35348 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/libm.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/libm.abilist
@@ -423,4 +423,7 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
 GLIBC_2.4 GLIBC_2.4 A
diff --git a/sysdeps/unix/sysv/linux/nios2/libm.abilist b/sysdeps/unix/sysv/linux/nios2/libm.abilist
index c0c94ac4fd..927961ae6d 100644
--- a/sysdeps/unix/sysv/linux/nios2/libm.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libm.abilist
@@ -389,3 +389,6 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist
index 2bec6c63b4..a507182964 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist
@@ -434,6 +434,9 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
 GLIBC_2.4 GLIBC_2.4 A
 GLIBC_2.4 __clog10l F
 GLIBC_2.4 __finitel F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist
index 4e04409a83..b3bd812726 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist
@@ -433,6 +433,9 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
 GLIBC_2.4 GLIBC_2.4 A
 GLIBC_2.4 __clog10l F
 GLIBC_2.4 __finitel F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist
index 1a30becc27..b051337fc4 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist
@@ -428,3 +428,6 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist
index 015a1149f2..b7a94bc977 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist
@@ -109,6 +109,9 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 _LIB_VERSION D 0x4
 GLIBC_2.3 __clog10 F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist
index 0c2c3e90a4..48d4e646b1 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist
@@ -421,6 +421,9 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
 GLIBC_2.4 GLIBC_2.4 A
 GLIBC_2.4 __clog10l F
 GLIBC_2.4 __finitel F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist
index d192753020..9e664874a5 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist
@@ -419,6 +419,9 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
 GLIBC_2.4 GLIBC_2.4 A
 GLIBC_2.4 __clog10l F
 GLIBC_2.4 __finitel F
diff --git a/sysdeps/unix/sysv/linux/sh/libm.abilist b/sysdeps/unix/sysv/linux/sh/libm.abilist
index 3f6a29622c..43be8f846d 100644
--- a/sysdeps/unix/sysv/linux/sh/libm.abilist
+++ b/sysdeps/unix/sysv/linux/sh/libm.abilist
@@ -390,5 +390,8 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
 GLIBC_2.4 GLIBC_2.4 A
 GLIBC_2.4 exp2l F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist
index 739a06134a..25c59063d2 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist
@@ -424,6 +424,9 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
 GLIBC_2.4 GLIBC_2.4 A
 GLIBC_2.4 __clog10l F
 GLIBC_2.4 __finitel F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist
index 80fd387a32..1b161ea081 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist
@@ -422,4 +422,7 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
 GLIBC_2.4 GLIBC_2.4 A
diff --git a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist
index 6154ee8980..b58d62a481 100644
--- a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist
+++ b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist
@@ -390,3 +390,6 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
diff --git a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist
index 6154ee8980..b58d62a481 100644
--- a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist
+++ b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist
@@ -390,3 +390,6 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
diff --git a/sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist b/sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist
index 6154ee8980..b58d62a481 100644
--- a/sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist
+++ b/sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist
@@ -390,3 +390,6 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libm.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libm.abilist
index 9b2c5abfe6..d17bb8bc86 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libm.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libm.abilist
@@ -423,4 +423,7 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F
 GLIBC_2.4 GLIBC_2.4 A
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist
index a93e4837e6..5f8686fe05 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist
@@ -422,3 +422,6 @@ GLIBC_2.25 fetestexceptflag F
 GLIBC_2.25 totalorder F
 GLIBC_2.25 totalorderf F
 GLIBC_2.25 totalorderl F
+GLIBC_2.25 totalordermag F
+GLIBC_2.25 totalordermagf F
+GLIBC_2.25 totalordermagl F