fix i386 fegetround and make fesetround faster
[musl] / src / fenv / i386 / fenv.s
1 2:      not %ecx
2         sub $32,%esp
3         fnstenv (%esp)
4         and %ecx,4(%esp)
5         or %edx,4(%esp)
6         fldenv (%esp)
7         add $32,%esp
8         ret
9
10 .global feclearexcept
11 .type feclearexcept,@function
12 feclearexcept:  
13         xor %eax,%eax
14         mov 4(%esp),%ecx
15         xor %edx,%edx
16         test %ecx,%ecx
17         jnz 2b
18         ret
19
20 .global feraiseexcept
21 .type feraiseexcept,@function
22 feraiseexcept:  
23         xor %eax,%eax
24         mov 4(%esp),%edx
25         xor %ecx,%ecx
26         test %edx,%edx
27         jnz 2b
28         ret
29
30 .global fesetround
31 .type fesetround,@function
32 fesetround:
33         mov 4(%esp),%ecx
34         xor %eax,%eax
35         sub $4,%esp
36         fnstcw (%esp)
37         andb $0xf3,1(%esp)
38         or %cx,(%esp)
39         fldcw (%esp)
40         add $4,%esp
41         ret
42
43 .global fegetround
44 .type fegetround,@function
45 fegetround:
46         sub $4,%esp
47         fnstcw (%esp)
48         mov (%esp),%ax
49         add $4,%esp
50         and $0xc00,%eax
51         ret
52
53 .global fegetenv
54 .type fegetenv,@function
55 fegetenv:
56         mov 4(%esp),%ecx
57         xor %eax,%eax
58         fnstenv (%ecx)
59         ret
60
61 .global fesetenv
62 .type fesetenv,@function
63 fesetenv:
64         mov 4(%esp),%ecx
65         xor %eax,%eax
66         test %ecx,%ecx
67         jz 1f
68         fldenv (%ecx)
69         ret
70 1:      push %eax
71         push %eax
72         push %eax
73         push %eax
74         push %eax
75         push %eax
76         pushl $0x37f
77         fldenv (%esp)
78         add $28,%esp
79         ret
80
81 .global fetestexcept
82 .type fetestexcept,@function
83 fetestexcept:
84         mov 4(%esp),%ecx
85         fnstsw %ax
86         and %ecx,%eax
87         ret