<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/include/math-emu, branch v5.4.175</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.4.175</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.4.175'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2019-08-29T16:06:56Z</updated>
<entry>
<title>nds32: Mark expected switch fall-throughs</title>
<updated>2019-08-29T16:06:56Z</updated>
<author>
<name>Gustavo A. R. Silva</name>
<email>gustavo@embeddedor.com</email>
</author>
<published>2019-08-27T16:57:07Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=7c9eb2dbd770b7c9980d5839dd305a70fbc5df67'/>
<id>urn:sha1:7c9eb2dbd770b7c9980d5839dd305a70fbc5df67</id>
<content type='text'>
Mark switch cases where we are expecting to fall through.

This patch fixes the following warnings (Building: allmodconfig nds32):

include/math-emu/soft-fp.h:124:8: warning: this statement may fall through [-Wimplicit-fallthrough=]
arch/nds32/kernel/signal.c:362:20: warning: this statement may fall through [-Wimplicit-fallthrough=]
arch/nds32/kernel/signal.c:315:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
include/math-emu/op-common.h:417:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
include/math-emu/op-common.h:430:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
include/math-emu/op-common.h:310:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
include/math-emu/op-common.h:320:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
include/math-emu/op-common.h:310:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
include/math-emu/op-common.h:320:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
include/math-emu/soft-fp.h:124:8: warning: this statement may fall through [-Wimplicit-fallthrough=]
include/math-emu/op-common.h:417:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
include/math-emu/op-common.h:430:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
include/math-emu/op-common.h:310:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
include/math-emu/op-common.h:320:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
include/math-emu/op-common.h:310:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
include/math-emu/op-common.h:320:11: warning: this statement may fall through [-Wimplicit-fallthrough=]

Reported-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Signed-off-by: Gustavo A. R. Silva &lt;gustavo@embeddedor.com&gt;
</content>
</entry>
<entry>
<title>math-emu: Use statement expressions to fix Wshift-count-overflow warning</title>
<updated>2019-05-31T07:23:25Z</updated>
<author>
<name>Vincent Chen</name>
<email>vincentc@andestech.com</email>
</author>
<published>2019-05-27T06:17:21Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=8183db10db6377ac58ad048a4c827425a614695c'/>
<id>urn:sha1:8183db10db6377ac58ad048a4c827425a614695c</id>
<content type='text'>
To avoid "shift count &gt;= width of type" warning, using statement
expressions to implement the conditional controlling before constant shift

The modification in op-2.h is taken from the glibc
commit 'sysdeps/unix/sysv/lin ("fe0b1e854ad32")'.

Signed-off-by: Vincent Chen &lt;vincentc@andestech.com&gt;
Acked-by: Greentime Hu &lt;greentime@andestech.com&gt;
Signed-off-by: Greentime Hu &lt;greentime@andestech.com&gt;
</content>
</entry>
<entry>
<title>math-emu/soft-fp.h: (_FP_ROUND_ZERO) cast 0 to void to fix warning</title>
<updated>2018-11-22T10:13:42Z</updated>
<author>
<name>Vincent Chen</name>
<email>vincentc@andestech.com</email>
</author>
<published>2018-11-22T03:14:38Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=83312f1b7ae205dca647bf52bbe2d51303cdedfb'/>
<id>urn:sha1:83312f1b7ae205dca647bf52bbe2d51303cdedfb</id>
<content type='text'>
_FP_ROUND_ZERO is defined as 0 and used as a statemente in macro
_FP_ROUND. This generates "error: statement with no effect
[-Werror=unused-value]" from gcc. Defining _FP_ROUND_ZERO as (void)0 to
fix it.

This modification is quoted from glibc 'commit &lt;In libc/:&gt;
(8ed1e7d5894000c155acbd06f)'

Signed-off-by: Vincent Chen &lt;vincentc@andestech.com&gt;
Acked-by: Greentime Hu &lt;greentime@andestech.com&gt;
Signed-off-by: Greentime Hu &lt;greentime@andestech.com&gt;
</content>
</entry>
<entry>
<title>math-emu/op-2.h: Use statement expressions to prevent negative constant shift</title>
<updated>2018-11-22T10:13:33Z</updated>
<author>
<name>Vincent Chen</name>
<email>vincentc@andestech.com</email>
</author>
<published>2018-11-22T03:14:37Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=7adb3e998f5bea3e1fd2f76c1cf80d76b8af6626'/>
<id>urn:sha1:7adb3e998f5bea3e1fd2f76c1cf80d76b8af6626</id>
<content type='text'>
This modification is quoted from glibc 'commit &lt;
sysdeps/unix/sysv/linux/sparc/sparc64/dl-procinfo.c: Moved to&gt;
(fe0b1e854ad32a69b260)'

Signed-off-by: Vincent Chen &lt;vincentc@andestech.com&gt;
Acked-by: Greentime Hu &lt;greentime@andestech.com&gt;
Signed-off-by: Greentime Hu &lt;greentime@andestech.com&gt;
</content>
</entry>
<entry>
<title>math-emu: fix floating-point to integer overflow detection</title>
<updated>2014-01-08T00:36:24Z</updated>
<author>
<name>Joseph Myers</name>
<email>joseph@codesourcery.com</email>
</author>
<published>2013-11-04T16:54:15Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=d06b3326dfd02f3f036b670d622fe56eb68a5f30'/>
<id>urn:sha1:d06b3326dfd02f3f036b670d622fe56eb68a5f30</id>
<content type='text'>
On overflow, the math-emu macro _FP_TO_INT_ROUND tries to saturate its
result (subject to the value of rsigned specifying the desired
overflow semantics).  However, if the rounding step has the effect of
increasing the exponent so as to cause overflow (if the rounded result
is 1 larger than the largest positive value with the given number of
bits, allowing for signedness), the overflow does not get detected,
meaning that for unsigned results 0 is produced instead of the maximum
unsigned integer with the give number of bits, without an exception
being raised for overflow, and that for signed results the minimum
(negative) value is produced instead of the maximum (positive) value,
again without an exception.  This patch makes the code check for
rounding increasing the exponent and adjusts the exponent value as
needed for the overflow check.

Signed-off-by: Joseph Myers &lt;joseph@codesourcery.com&gt;
Signed-off-by: Scott Wood &lt;scottwood@freescale.com&gt;
</content>
</entry>
<entry>
<title>math-emu: fix floating-point to integer unsigned saturation</title>
<updated>2014-01-08T00:34:47Z</updated>
<author>
<name>Joseph Myers</name>
<email>joseph@codesourcery.com</email>
</author>
<published>2013-11-04T16:53:50Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=4f6db5efff8256c7f608285877e892e7e649137a'/>
<id>urn:sha1:4f6db5efff8256c7f608285877e892e7e649137a</id>
<content type='text'>
The math-emu macros _FP_TO_INT and _FP_TO_INT_ROUND are supposed to
saturate their results for out-of-range arguments, except in the case
rsigned == 2 (when instead the low bits of the result are taken).
However, in the case rsigned == 0 (converting to unsigned integers),
they mistakenly produce 0 for positive results and the maximum
unsigned integer for negative results, the opposite of correct
unsigned saturation.  This patch fixes the logic.

Signed-off-by: Joseph Myers &lt;joseph@codesourcery.com&gt;
Signed-off-by: Scott Wood &lt;scottwood@freescale.com&gt;
</content>
</entry>
<entry>
<title>math-emu: correct test for downshifting fraction in _FP_FROM_INT()</title>
<updated>2010-07-21T01:45:14Z</updated>
<author>
<name>Mikael Pettersson</name>
<email>mikpe@it.uu.se</email>
</author>
<published>2010-07-21T01:45:14Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f8324e20f8289dffc646d64366332e05eaacab25'/>
<id>urn:sha1:f8324e20f8289dffc646d64366332e05eaacab25</id>
<content type='text'>
The kernel's math-emu code contains a macro _FP_FROM_INT() which is
used to convert an integer to a raw normalized floating-point value.
It does this basically in three steps:

1. Compute the exponent from the number of leading zero bits.
2. Downshift large fractions to put the MSB in the right position
   for normalized fractions.
3. Upshift small fractions to put the MSB in the right position.

There is an boundary error in step 2, causing a fraction with its
MSB exactly one bit above the normalized MSB position to not be
downshifted.  This results in a non-normalized raw float, which when
packed becomes a massively inaccurate representation for that input.

The impact of this depends on a number of arch-specific factors,
but it is known to have broken emulation of FXTOD instructions
on UltraSPARC III, which was originally reported as GCC bug 44631
&lt;http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44631&gt;.

Any arch which uses math-emu to emulate conversions from integers to
same-size floats may be affected.

The fix is simple: the exponent comparison used to determine if the
fraction should be downshifted must be "&lt;=" not "&lt;".

I'm sending a kernel module to test this as a reply to this message.
There are also SPARC user-space test cases in the GCC bug entry.

Signed-off-by: Mikael Pettersson &lt;mikpe@it.uu.se&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>Fix misspellings of "truly" in comments.</title>
<updated>2010-02-04T10:55:45Z</updated>
<author>
<name>Adam Buchbinder</name>
<email>adam.buchbinder@gmail.com</email>
</author>
<published>2009-12-11T21:35:39Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=c41b20e721ea4f6f20f66a66e7f0c3c97a2ca9c2'/>
<id>urn:sha1:c41b20e721ea4f6f20f66a66e7f0c3c97a2ca9c2</id>
<content type='text'>
Some comments misspell "truly"; this fixes them. No code changes.

Signed-off-by: Adam Buchbinder &lt;adam.buchbinder@gmail.com&gt;
Signed-off-by: Jiri Kosina &lt;jkosina@suse.cz&gt;
</content>
</entry>
<entry>
<title>math-emu: Fix thinko in _FP_DIV</title>
<updated>2008-10-23T05:09:59Z</updated>
<author>
<name>David S. Miller</name>
<email>davem@davemloft.net</email>
</author>
<published>2008-10-23T05:09:59Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=60b8267338aafde5315fc65ff385f3d4d75eccfe'/>
<id>urn:sha1:60b8267338aafde5315fc65ff385f3d4d75eccfe</id>
<content type='text'>
In commit 48d6c64311ddb6417b901639530ccbc47bdc7635 ("math-emu: Add
support for reporting exact invalid exception") code was added to
set the new FP_EX_INVALID_{IDI,ZDZ} exception flag bits.

However there is a missing break statement for the
_FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_INF) switch case, the
code just falls into _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_ZERO)
which then proceeds to overwrite all of the settings.

Fix by adding the missing break.

Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>math-emu: Fix signalling of underflow and inexact while packing result.</title>
<updated>2008-10-23T04:53:53Z</updated>
<author>
<name>Kumar Gala</name>
<email>galak@kernel.crashing.org</email>
</author>
<published>2008-10-22T05:19:00Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=930cc144a043ff95e56b6888fa51c618b33f89e7'/>
<id>urn:sha1:930cc144a043ff95e56b6888fa51c618b33f89e7</id>
<content type='text'>
I'm trying to move the powerpc math-emu code to use the include/math-emu bits.

In doing so I've been using TestFloat to see how good or bad we are
doing.  For the most part the current math-emu code that PPC uses has
a number of issues that the code in include/math-emu seems to solve
(plus bugs we've had for ever that no one every realized).

Anyways, I've come across a case that we are flagging underflow and
inexact because we think we have a denormalized result from a double
precision divide:

000.FFFFFFFFFFFFF / 3FE.FFFFFFFFFFFFE
	soft: 001.0000000000000 .....  syst: 001.0000000000000 ...ux

What it looks like is the results out of FP_DIV_D are:

D:
sign:	  0
mantissa: 01000000 00000000
exp:	 -1023 (0)

The problem seems like we aren't normalizing the result and bumping the exp.

Now that I'm digging into this a bit I'm thinking my issue has to do with
the fix DaveM put in place from back in Aug 2007 (commit
405849610fd96b4f34cd1875c4c033228fea6c0f):

[MATH-EMU]: Fix underflow exception reporting.

    2) we ended up rounding back up to normal (this is the case where
       we set the exponent to 1 and set the fraction to zero), this
       should set inexact too
...

    Another example, "0x0.0000000000001p-1022 / 16.0", should signal both
    inexact and underflow.  The cpu implementations and ieee1754
    literature is very clear about this.  This is case #2 above.

Here is the distilled glibc test case from Jakub Jelinek which prompted that
commit:

--------------------
#include &lt;float.h&gt;
#include &lt;fenv.h&gt;
#include &lt;stdio.h&gt;

volatile double d = DBL_MIN;
volatile double e = 0x0.0000000000001p-1022;
volatile double f = 16.0;
int
main (void)
{
  printf ("%x\n", fetestexcept (FE_UNDERFLOW));
  d /= f;
  printf ("%x\n", fetestexcept (FE_UNDERFLOW));
  e /= f;
  printf ("%x\n", fetestexcept (FE_UNDERFLOW));
  return 0;
}
--------------------

It looks like the case I have we are exact before rounding, but think it
looks like the rounding case since it appears as if "overflow is set".

000.FFFFFFFFFFFFF / 3FE.FFFFFFFFFFFFE = 001.0000000000000

I think the following adds the check for my case and still works for the
issue your commit was trying to resolve.

Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
</feed>
