about summary refs log tree commit diff
path: root/elf/dl-sysdep.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2014-11-04 16:34:49 +0000
committerJoseph Myers <joseph@codesourcery.com>2014-11-04 16:34:49 +0000
commit2004e7fb76bd6806253436d63ab3bda7e24c9cc1 (patch)
treef3b91ec17f5d05879524bc75c2fd67d12c4290e0 /elf/dl-sysdep.c
parent97827bfc5f5e039f29766369035cf73f0df27888 (diff)
downloadglibc-2004e7fb76bd6806253436d63ab3bda7e24c9cc1.tar.gz
glibc-2004e7fb76bd6806253436d63ab3bda7e24c9cc1.tar.xz
glibc-2004e7fb76bd6806253436d63ab3bda7e24c9cc1.zip
soft-fp: Add _FP_TO_INT_ROUND.
Continuing the series of patches adding soft-fp features from the
kernel version of soft-fp to glibc so that glibc's version is able to
replace the old fork of soft-fp in the kernel, this patch adds the
last major such feature: _FP_TO_INT_ROUND, converting a floating-point
number to an integer with rounding according to the current rounding
direction (as opposed to truncating towards zero, which _FP_TO_INT
does).

The general structure of the implementation follows that of
_FP_TO_INT, but of course is more complicated.  As with glibc's
_FP_TO_INT it works with raw input (the kernel versions of these
macros predate the conversion of _FP_TO_INT and many other macros to
raw or semi-raw input).  I have not tried to work out what bugs there
might be in the kernel version that this might fix; it's a
from-scratch implementation based on _FP_TO_INT.

Tested for powerpc (soft-float) that there is no change to the
installed shared libraries; also tested with the libm tests with lrint
/ lrintf / llrint / llrintf made to use _FP_TO_INT_ROUND, to provide
some test of the functionality.  As we don't have benchmarks for those
functions, I haven't actually included the soft-fp versions of them,
although I expect them to be faster than the existing code (given that
the existing code involves adding and subtracting numbers such as
0x1p52 to achieve the desired rounding, which is not particularly
efficient when the underlying floating point is software floating
point).

2014-11-04  Joseph Myers  <joseph@codesourcery.com>

	* soft-fp/op-common.h (_FP_TO_INT_ROUND): New macro.
	* soft-fp/double.h [_FP_W_TYPE_SIZE < 64] (FP_TO_INT_ROUND_D): New
	macro.
	[_FP_W_TYPE_SIZE >= 64] (FP_TO_INT_ROUND_D): Likewise.
	* soft-fp/extended.h [_FP_W_TYPE_SIZE < 64] (FP_TO_INT_ROUND_E):
	New macro.
	[_FP_W_TYPE_SIZE >= 64] (FP_TO_INT_ROUND_E): Likewise.
	* soft-fp/quad.h [_FP_W_TYPE_SIZE < 64] (FP_TO_INT_ROUND_Q): New
	macro.
	[_FP_W_TYPE_SIZE >= 64] (FP_TO_INT_ROUND_Q): Likewise.
	* soft-fp/single.h (FP_TO_INT_ROUND_S): New macro.
Diffstat (limited to 'elf/dl-sysdep.c')
0 files changed, 0 insertions, 0 deletions