x86_64 fenv support (untested; at least known to build successfully)
[musl] / src / fenv / x86_64 / fenv.s
1 2:      not %edi
2         sub $32,%rsp
3         fnstenv (%rsp)
4         and %edi,4(%rsp)
5         or %esi,4(%rsp)
6         fldenv (%rsp)
7         stmxcsr (%rsp)
8         and %edi,(%rsp)
9         ldmxcsr (%rsp)
10         add $32,%rsp
11         ret
12
13 .global feclearexcept
14 feclearexcept:  
15         xor %eax,%eax
16         xor %esi,%esi
17         test %edi,%edi
18         jnz 2b
19         ret
20
21 .global feraiseexcept
22 feraiseexcept:  
23         xor %eax,%eax
24         mov %edi,%esi
25         xor %edi,%edi
26         test %esi,%esi
27         jnz 2b
28         ret
29
30 .global fesetround
31 fesetround:
32         xor %eax,%eax
33         sub $32,%rsp
34         fnstenv (%rsp)
35         andb $0xf3,1(%rsp)
36         or %edi,(%rsp)
37         fldenv (%rsp)
38         stmxcsr (%rsp)
39         shl $3,%edi
40         andb $0x9f,1(%rsp)
41         or %edi,(%rsp)
42         ldmxcsr (%rsp)
43         add $32,%rsp
44         ret
45
46 .global fegetround
47 fegetround:
48         push %rax
49         stmxcsr (%rsp)
50         pop %rax
51         shr $3,%eax
52         and $0xc,%ah
53         ret
54
55 .global fegetenv
56 fegetenv:
57         xor %eax,%eax
58         fnstenv (%rdi)
59         stmxcsr 28(%rdi)
60         ret
61
62 .global fesetenv
63 fesetenv:
64         xor %eax,%eax
65         inc %rdi
66         jz 1f
67         fldenv -1(%rdi)
68         ldmxcsr 27(%rdi)
69         ret
70 1:      push %rax
71         push %rax
72         push %rax
73         pushq $0x37f
74         fldenv (%rsp)
75         pushq $0x1f80
76         ldmxcsr (%rsp)
77         add $40,%rsp
78         ret
79
80 .global fetestexcept
81 fetestexcept:
82         push %rax
83         stmxcsr (%rsp)
84         pop %rsi
85         fnstsw %ax
86         or %esi,%eax
87         and %edi,%eax
88         ret