master
1.global feclearexcept
2.type feclearexcept,@function
3feclearexcept:
4 # maintain exceptions in the sse mxcsr, clear x87 exceptions
5 mov %edi,%ecx
6 and $0x3f,%ecx
7 fnstsw %ax
8 test %eax,%ecx
9 jz 1f
10 fnclex
111: stmxcsr -8(%esp)
12 and $0x3f,%eax
13 or %eax,-8(%esp)
14 test %ecx,-8(%esp)
15 jz 1f
16 not %ecx
17 and %ecx,-8(%esp)
18 ldmxcsr -8(%esp)
191: xor %eax,%eax
20 ret
21
22.global feraiseexcept
23.type feraiseexcept,@function
24feraiseexcept:
25 and $0x3f,%edi
26 stmxcsr -8(%esp)
27 or %edi,-8(%esp)
28 ldmxcsr -8(%esp)
29 xor %eax,%eax
30 ret
31
32.global __fesetround
33.hidden __fesetround
34.type __fesetround,@function
35__fesetround:
36 push %rax
37 xor %eax,%eax
38 mov %edi,%ecx
39 fnstcw (%esp)
40 andb $0xf3,1(%esp)
41 or %ch,1(%esp)
42 fldcw (%esp)
43 stmxcsr (%esp)
44 shl $3,%ch
45 andb $0x9f,1(%esp)
46 or %ch,1(%esp)
47 ldmxcsr (%esp)
48 pop %rcx
49 ret
50
51.global fegetround
52.type fegetround,@function
53fegetround:
54 push %rax
55 stmxcsr (%esp)
56 pop %rax
57 shr $3,%eax
58 and $0xc00,%eax
59 ret
60
61.global fegetenv
62.type fegetenv,@function
63fegetenv:
64 xor %eax,%eax
65 fnstenv (%edi)
66 stmxcsr 28(%edi)
67 ret
68
69.global fesetenv
70.type fesetenv,@function
71fesetenv:
72 xor %eax,%eax
73 inc %edi
74 jz 1f
75 fldenv -1(%edi)
76 ldmxcsr 27(%edi)
77 ret
781: push %rax
79 push %rax
80 pushq $0xffff
81 pushq $0x37f
82 fldenv (%esp)
83 pushq $0x1f80
84 ldmxcsr (%esp)
85 add $40,%esp
86 ret
87
88.global fetestexcept
89.type fetestexcept,@function
90fetestexcept:
91 and $0x3f,%edi
92 push %rax
93 stmxcsr (%esp)
94 pop %rsi
95 fnstsw %ax
96 or %esi,%eax
97 and %edi,%eax
98 ret