summaryrefslogtreecommitdiff
path: root/src/setjmp/mips
AgeCommit message (Collapse)AuthorLines
2019-09-26fix mips setjmp/longjmp fpu state on r6, related issuesRich Felker-24/+12
mips32 has two fpu register file variants: FR=0 with 32 32-bit registers, where pairs of neighboring even/odd registers are used to represent doubles, and FR=1 with 32 64-bit registers, each of which can store a single or double. up through r5 (our "mips" arch), the supported ABI uses FR=0, but modern compilers generate "fpxx" model code that can safely operate with either model. r6, which is an incompatible but similar ISA, drops FR=0 and only provides the FR=1 model. as such, setjmp and longjmp, which depended on being able to save and restore call-saved doubles by storing and loading their 32-bit halves, were completely broken in the presence of floating point code on mips r6. to fix this, use the s.d and l.d mnemonics to store and load fpu registers. these expand to the existing swc1 and lwc1 instructions for pairs of 32-bit fpu registers on mips1, but on mips2 and later they translate directly to the 64-bit sdc1 and ldc1. with FR=0, sdc1 and ldc1 behave just like the pairs of swc1 and lwc1 instructions they replace, storing or loading the even/odd pair of fpu registers that can be treated as separate single-precision floats or as a unit representing a double. but with FR=1, they store/load individual 64-bit registers. this yields the ABI-correct behavior on mips r6, and should make linking of pre-r6 (plain "mips") code with "fp64" model code workable, although this is and will likely remain unsupported usage. in addition to the mips r6 problem this change fixes, reportedly clang's internal assembler refuses to assemble swc1 and lwc1 instructions for odd register indices when building for "fpxx" model (the default). this caused setjmp and longjmp not to build. by using the s.d and l.d forms, this problem is avoided too. as a bonus, code size is reduced everywhere but mips1.
2016-01-20switch sh and mips setjmp asm from .sub system to .S filesRich Felker-1/+6
2012-12-05remove mips setjmp/longjmp code to save/restore fenvRich Felker-5/+1
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.
2012-07-22add floating point register saving/restoring to mips setjmp/longjmpRich Felker-1/+29
also fix the alignment of jmp_buf to meet the abi. linux always emulates fpu on mips if it's not present, so enabling this code unconditionally is "safe" but may be slow. in the long term it may be preferable to find a way to disable it on soft float builds.
2012-07-11initial version of mips (o32) port, based on work by Richard Pennington (rdp)Rich Felker-0/+50
basically, this version of the code was obtained by starting with rdp's work from his ellcc source tree, adapting it to musl's build system and coding style, auditing the bits headers for discrepencies with kernel definitions or glibc/LSB ABI or large file issues, fixing up incompatibility with the old binutils from aboriginal linux, and adding some new special cases to deal with the oddities of sigaction and pipe syscall interfaces on mips. at present, minimal test programs work, but some interfaces are broken or missing. threaded programs probably will not link.