about summary refs log tree commit diff
path: root/math/test-tgmath.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2016-12-20 00:46:53 +0000
committerJoseph Myers <joseph@codesourcery.com>2016-12-20 00:46:53 +0000
commit525f803984f278e65dc07ca1156bdeca63755810 (patch)
tree776b2000f6c8a0d5d3a0141f9b4b5aa5492da119 /math/test-tgmath.c
parent353683a22ed8a493a6bd1d78d63e144bc3e85d2f (diff)
downloadglibc-525f803984f278e65dc07ca1156bdeca63755810.tar.gz
glibc-525f803984f278e65dc07ca1156bdeca63755810.tar.xz
glibc-525f803984f278e65dc07ca1156bdeca63755810.zip
Add fmaxmag, fminmag functions.
TS 18661-1 defines fmaxmag and fminmag functions that return the
argument with maximum / minimum magnitude (acting like fmax / fmin if
the arguments have the same magnitude or either argument is a NaN).
These correspond to the IEEE 754-2008 operations maxNumMag and
minNumMag.  This patch implements these functions for glibc.  They are
implemented with type-generic templates.  Tests are based on those for
fmax and fmin.

Tested for x86_64, x86, mips64 and powerpc.

	* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(fmaxmag): New declaration.
	(fminmag): Likewise.
	* math/tgmath.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (fmaxmag): New
	macro.
	[__GLIBC_USE (IEC_60559_BFP_EXT)] (fminmag): Likewise.
	* math/Versions (fmaxmag): New libm symbol at version GLIBC_2.25.
	(fmaxmagf): Likewise.
	(fmaxmagl): Likewise.
	(fminmag): Likewise.
	(fminmagf): Likewise.
	(fminmagl): Likewise.
	* math/Makefile (gen-libm-calls): Add s_fmaxmagF and s_fminmagF.
	* math/s_fmaxmag_template.c: New file.
	* math/s_fminmag_template.c: Likewise.
	* math/libm-test.inc (fmaxmag_test_data): New array.
	(fmaxmag_test): New function.
	(fminmag_test_data): New array.
	(fminmag_test): New function.
	(main): Call fmaxmag_test and fminmag_test.
	* math/test-tgmath.c (NCALLS): Increase to 132.
	(F(compile_test)): Call fmaxmag and fminmag.
	(F(fminmag)): New function.
	(F(fmaxmag)): Likewise.
	* manual/arith.texi (Misc FP Arithmetic): Document fminmag,
	fminmagf, fminmagl, fmaxmag, fmaxmagf and fmaxmagl.
	* manual/libm-err-tab.pl (@all_functions): Add fmaxmag and
	fminmag.
	* sysdeps/ieee754/ldbl-opt/nldbl-fmaxmag.c: New file.
	* sysdeps/ieee754/ldbl-opt/nldbl-fminmag.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/s_fmaxmagl.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/s_fminmagl.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add fmaxmag
	and fminmag.
	(CFLAGS-nldbl-fmaxmag.c): New variable.
	(CFLAGS-nldbl-fminmag.c): 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 'math/test-tgmath.c')
-rw-r--r--math/test-tgmath.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/math/test-tgmath.c b/math/test-tgmath.c
index be2c2fc3d4..b9095271ea 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     126
+#define NCALLS     132
 #define NCALLS_INT 4
 #define NCCALLS    47
 
@@ -285,6 +285,8 @@ F(compile_test) (void)
   a = fdim (fdim (x, a), fdim (c, b));
   b = fmax (fmax (a, x), fmax (c, b));
   a = fmin (fmin (x, a), fmin (c, b));
+  b = fmaxmag (fmaxmag (a, x), fmaxmag (c, b));
+  a = fminmag (fminmag (x, a), fminmag (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));
@@ -384,6 +386,8 @@ F(compile_test) (void)
       a = fdim (y, y);
       a = fmax (y, y);
       a = fmin (y, y);
+      a = fmaxmag (y, y);
+      a = fminmag (y, y);
       a = fma (y, y, y);
       a = totalorder (y, y);
       a = totalordermag (y, y);
@@ -881,6 +885,22 @@ TYPE
 }
 
 TYPE
+(F(fminmag)) (TYPE x, TYPE y)
+{
+  ++count;
+  P ();
+  return x + y;
+}
+
+TYPE
+(F(fmaxmag)) (TYPE x, TYPE y)
+{
+  ++count;
+  P ();
+  return x + y;
+}
+
+TYPE
 (F(fma)) (TYPE x, TYPE y, TYPE z)
 {
   ++count;