remove mips setjmp/longjmp code to save/restore fenv
authorRich Felker <dalias@aerifal.cx>
Wed, 5 Dec 2012 17:52:40 +0000 (12:52 -0500)
committerRich Felker <dalias@aerifal.cx>
Wed, 5 Dec 2012 17:52:40 +0000 (12:52 -0500)
nothing in the standard requires or even allows the fenv state to be
restored by longjmp. restoring the exception flags is not such a big
deal since it's probably valid to clobber them completely, but
restoring the rounding mode yields an observable side effect not
sanctioned by ISO C. saving/restoring it also wastes a few cycles and
16 bytes of code.

as for historical behavior, reportedly SGI IRIX did save/restore fenv,
and this is where glibc and uClibc got the behavior from. a few other
systems save/restore it too (on archs other than mips), even though
this is apparently wrong. further details are documented here:

http://www-personal.umich.edu/~williams/archive/computation/setjmp-fpmode.html

as musl aims for standards conformance rather than coddling historical
programs expecting non-conforming behavior, and as it's unlikely that
any historical programs actually depend on the incorrect behavior
(such programs would break on other archs, anyway), I'm making the
change not to save/restore fenv on mips.

src/setjmp/mips/longjmp.s
src/setjmp/mips/setjmp.s

index fc8e7260c80caca76419d4e3cb039eb0131ac3ca..a972d67788e8c3dd6fe855954e485381b0e2b852 100644 (file)
@@ -10,9 +10,7 @@ longjmp:
        bne     $2, $0, 1f
        nop
        addu    $2, $2, 1
-1:     lw      $8,  48($4)
-       ctc1    $8,  $31
-       lwc1    $20, 56($4)
+1:     lwc1    $20, 56($4)
        lwc1    $21, 60($4)
        lwc1    $22, 64($4)
        lwc1    $23, 68($4)
index 1b79525f2851674e666f38232b64d546587d8ad2..53d702a91875606447d0d68aeb308daeb71d06a4 100644 (file)
@@ -21,8 +21,6 @@ setjmp:
        sw      $23, 36($4)
        sw      $30, 40($4)
        sw      $28, 44($4)
-       cfc1    $8, $31
-       sw      $8,  48($4)
        swc1    $20, 56($4)
        swc1    $21, 60($4)
        swc1    $22, 64($4)