glibc/sysdeps/unix/sysv/linux/m68k
Joseph Myers 41c67149b9 Add roundeven, roundevenf, roundevenl.
TS 18661-1 defines roundeven functions that round a floating-point
number to the nearest integer, in that floating-point type, with ties
rounding to even (whereas the round functions round ties away from
zero).  As with other such functions, they raise no exceptions apart
from "invalid" for signaling NaNs.  There was a previous user request
for this functionality in glibc in
<https://sourceware.org/ml/libc-help/2015-02/msg00005.html>.

This patch implements these functions for glibc.  The implementations
use integer bit-manipulation (or roundeven on the high and low parts,
in the IBM long double case).  It's possible that there may be faster
approaches on some architectures (in particular, on AArch64 the frintn
instruction should do exactly what's required); I'll leave it to
architecture maintainers or others interested to implement such
architecture-specific versions if desired.  (Where architectures have
instructions to round to nearest integer in the current rounding mode,
implementations saving and restoring the rounding mode - and dealing
with exceptions if those instructions generate "inexact" - are also
possible, though their performance depends on the cost of manipulating
exceptions / rounding mode state.)

Tested for x86_64, x86, mips64 and powerpc.

	* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
	(roundeven): New declaration.
	* math/tgmath.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (roundeven): New
	macro.
	* math/Versions (roundeven): New libm symbol at version
	GLIBC_2.25.
	(roundevenf): Likewise.
	(roundevenl): Likewise.
	* math/Makefile (libm-calls): Add s_roundevenF.
	* math/libm-test.inc (roundeven_test_data): New array.
	(roundeven_test): New function.
	(main): Call roundeven_test.
	* math/test-tgmath.c (NCALLS): Increase to 134.
	(F(compile_test)): Call roundeven.
	(F(roundeven)): New function.
	* manual/arith.texi (Rounding Functions): Document roundeven,
	roundevenf and roundevenl.
	* manual/libm-err-tab.pl (@all_functions): Add roundeven.
	* include/math.h (roundeven): Use libm_hidden_proto.
	* sysdeps/ieee754/dbl-64/s_roundeven.c: New file.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_roundeven.c: Likewise.
	* sysdeps/ieee754/flt-32/s_roundevenf.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_roundevenl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_roundevenl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_roundevenl.c: Likewise.
	* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add
	roundeven.
	(CFLAGS-nldbl-roundeven.c): New variable.
	* sysdeps/ieee754/ldbl-opt/nldbl-roundeven.c: New file.
	* 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-12-21 01:48:27 +00:00
..
bits Make padding in struct sockaddr_storage explicit [BZ #20111] 2016-05-23 19:43:09 +02:00
coldfire Add roundeven, roundevenf, roundevenl. 2016-12-21 01:48:27 +00:00
m680x0 Add roundeven, roundevenf, roundevenl. 2016-12-21 01:48:27 +00:00
sys Installed-header hygiene (BZ#20366): stack_t. 2016-09-23 08:43:56 -04:00
____longjmp_chk.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
alphasort64.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
arch-fork.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
brk.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
c++-types.data m68k: Consolidate nptl/ subdirectories under linux/... 2014-06-23 09:24:18 -07:00
clone.S Remove cached PID/TID in clone 2016-11-24 19:38:51 -02:00
configure Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
configure.ac Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
dl-librecon.h Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
dl-static.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
fcntl.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
fxstat.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
fxstatat.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
getdents64.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
getmsg.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
getpagesize.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
getsysstats.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
glob64.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
Implies NPTL is no longer an add-on! 2014-07-07 09:29:06 -07:00
init-first.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
kernel-features.h Remove __ASSUME_FUTEX_LOCK_PI 2016-06-13 08:36:34 -03:00
ldconfig.h Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
ldsodefs.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
libc-m68k-vdso.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
localplt.data ld.so: Remove __libc_memalign 2016-11-30 16:23:58 +01:00
lockf64.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
lxstat.c Whitespace fixes 2014-02-10 20:24:03 +01:00
m68k-helpers.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
m68k-vdso.c Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
m68k-vdso.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
Makefile Consolidate Linux setrlimit and getrlimit implementation 2016-11-17 15:54:22 -02:00
mmap64.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
mmap.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
mremap.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
pt-vfork.c m68k: Consolidate NPTL/non versions of vfork 2014-06-14 21:37:34 +02:00
putmsg.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
readdir64_r.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
readdir64.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
register-dump.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
scandir64.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
semtimedop.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
setegid.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
seteuid.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
setgid.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
setgroups.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
setregid.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
setresgid.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
setresuid.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
setreuid.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
setuid.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
sigcontextinfo.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
syscall.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
syscalls.list Fix linux personality syscall wrapper 2015-12-31 00:17:48 +00:00
sysdep-cancel.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
sysdep.h Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
sysdep.S Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
Versions Revert {send,sendm,recv,recvm}msg conformance changes 2016-06-10 11:58:16 -03:00
versionsort64.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00
vfork.S Remove cached PID/TID in clone 2016-11-24 19:38:51 -02:00
xstat.c Move m68k from ports to libc 2014-02-10 20:22:40 +01:00