fenv.s (2667B)
1 # This file is vendored from musl and is licensed under MIT license: 2 # 3 # ---------------------------------------------------------------------- 4 # Copyright © 2005-2020 Rich Felker, et al. 5 # 6 # Permission is hereby granted, free of charge, to any person obtaining 7 # a copy of this software and associated documentation files (the 8 # "Software"), to deal in the Software without restriction, including 9 # without limitation the rights to use, copy, modify, merge, publish, 10 # distribute, sublicense, and/or sell copies of the Software, and to 11 # permit persons to whom the Software is furnished to do so, subject to 12 # the following conditions: 13 # 14 # The above copyright notice and this permission notice shall be 15 # included in all copies or substantial portions of the Software. 16 # 17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 # ---------------------------------------------------------------------- 25 26 .section ".text.rt.feclearexcept","ax" 27 .global rt.feclearexcept 28 .type rt.feclearexcept,@function 29 rt.feclearexcept: 30 # maintain exceptions in the sse mxcsr, clear x87 exceptions 31 endbr64 32 mov %edi,%ecx 33 and $0x3f,%ecx 34 fnstsw %ax 35 test %eax,%ecx 36 jz 1f 37 fnclex 38 1: stmxcsr -8(%rsp) 39 and $0x3f,%eax 40 or %eax,-8(%rsp) 41 test %ecx,-8(%rsp) 42 jz 1f 43 not %ecx 44 and %ecx,-8(%rsp) 45 ldmxcsr -8(%rsp) 46 1: xor %eax,%eax 47 ret 48 49 .section ".text.rt.feraiseexcept","ax" 50 .global rt.feraiseexcept 51 .type rt.feraiseexcept,@function 52 rt.feraiseexcept: 53 endbr64 54 and $0x3f,%edi 55 stmxcsr -8(%rsp) 56 or %edi,-8(%rsp) 57 ldmxcsr -8(%rsp) 58 xor %eax,%eax 59 ret 60 61 .section ".text.rt.fesetround","ax" 62 .global rt.fesetround 63 .type rt.fesetround,@function 64 rt.fesetround: 65 endbr64 66 push %rax 67 xor %eax,%eax 68 mov %edi,%ecx 69 fnstcw (%rsp) 70 andb $0xf3,1(%rsp) 71 or %ch,1(%rsp) 72 fldcw (%rsp) 73 stmxcsr (%rsp) 74 shl $3,%ch 75 andb $0x9f,1(%rsp) 76 or %ch,1(%rsp) 77 ldmxcsr (%rsp) 78 pop %rcx 79 ret 80 81 .section ".text.rt.fegetround","ax" 82 .global rt.fegetround 83 .type rt.fegetround,@function 84 rt.fegetround: 85 endbr64 86 push %rax 87 stmxcsr (%rsp) 88 pop %rax 89 shr $3,%eax 90 and $0xc00,%eax 91 ret 92 93 .section ".text.rt.fetestexcept","ax" 94 .global rt.fetestexcept 95 .type rt.fetestexcept,@function 96 rt.fetestexcept: 97 endbr64 98 and $0x3f,%edi 99 push %rax 100 stmxcsr (%rsp) 101 pop %rsi 102 fnstsw %ax 103 or %esi,%eax 104 and %edi,%eax 105 ret