for executing init array functions, use function type with prototype
[musl] / src / fenv / sh / fenv.S
1 #if __SH_FPU_ANY__ || __SH4__
2
3 .global fegetround
4 .type   fegetround, @function
5 fegetround:
6         sts fpscr, r0
7         rts
8          and #3, r0
9
10 .global __fesetround
11 .type   __fesetround, @function
12 __fesetround:
13         sts fpscr, r0
14         or  r4, r0
15         lds r0, fpscr
16         rts
17          mov #0, r0
18
19 .global fetestexcept
20 .type   fetestexcept, @function
21 fetestexcept:
22         sts fpscr, r0
23         and r4, r0
24         rts
25          and #0x7c, r0
26
27 .global feclearexcept
28 .type   feclearexcept, @function
29 feclearexcept:
30         mov r4, r0
31         and #0x7c, r0
32         not r0, r4
33         sts fpscr, r0
34         and r4, r0
35         lds r0, fpscr
36         rts
37          mov #0, r0
38
39 .global feraiseexcept
40 .type   feraiseexcept, @function
41 feraiseexcept:
42         mov r4, r0
43         and #0x7c, r0
44         sts fpscr, r4
45         or  r4, r0
46         lds r0, fpscr
47         rts
48          mov #0, r0
49
50 .global fegetenv
51 .type   fegetenv, @function
52 fegetenv:
53         sts fpscr, r0
54         mov.l r0, @r4
55         rts
56          mov #0, r0
57
58 .global fesetenv
59 .type   fesetenv, @function
60 fesetenv:
61         mov r4, r0
62         cmp/eq #-1, r0
63         bf 1f
64
65         ! the default environment is complicated by the fact that we need to
66         ! preserve the current precision bit, which we do not know a priori
67         sts fpscr, r0
68         mov #8, r1
69         swap.w r1, r1
70         bra 2f
71          and r1, r0
72
73 1:      mov.l @r4, r0      ! non-default environment
74 2:      lds r0, fpscr
75         rts
76          mov #0, r0
77
78 #endif