2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
6 #include <aros/libcall.h>
7 #include <exec/types.h>
8 #include <proto/mathieeedoubbas.h>
11 #include "mathieeedoubbas_intern.h"
16 Problem (ONLY on Linux/M68K with binary compatibility turned on):
17 In order to get binary compatibility with the original Amiga OS
18 we have to return the value in D0/D1. This is NOT automatically
19 done by the compiler. The result would be returned in one of the
20 FPU registers instead. So we're using the trick with the QUADs.
27 The functions in the *.arch file (integer-emulation of double
28 operations) return QUADs. The protos however say that these functions
29 are returning doubles. Unfortunately doubles are not returned like
32 //#define UseRegisterArgs 1
34 #define RETURN_TYPE QUAD /* For Linux/M68k & AmigaOS w/ bin. compat. */
36 #define RETURN_TYPE double /* for the rest */
39 AROS_LHQUAD1(LONG
, FPU_IEEEDPFix
,
40 AROS_LHAQUAD(double, y
, D0
, D1
),
41 struct MathIeeeDoubBasBase
*, MathIeeeDoubBasBase
, 5, MathIeeeDoubBas
49 AROS_LHQUAD1(RETURN_TYPE
, FPU_IEEEDPFlt
,
50 AROS_LHAQUAD(LONG
, y
, D0
, D1
),
51 struct MathIeeeDoubBasBase
*, MathIeeeDoubBasBase
, 6, MathIeeeDoubBas
57 QUAD
* Res
= (QUAD
*)&d
; /* this forces the returned value to be in D0/D1 */
66 AROS_LHQUAD2(LONG
, FPU_IEEEDPCmp
,
67 AROS_LHAQUAD(double, y
, D0
, D1
),
68 AROS_LHAQUAD(double, z
, D2
, D3
),
69 struct MathIeeeDoubBasBase
*, MathIeeeDoubBasBase
, 7, MathIeeeDoubBas
81 AROS_LHQUAD1(LONG
, FPU_IEEEDPTst
,
82 AROS_LHAQUAD(double, y
, D0
, D1
),
83 struct MathIeeeDoubBasBase
*, MathIeeeDoubBasBase
, 8, MathIeeeDoubBas
88 if (0.0 == y
) return 0;
95 AROS_LHQUAD1(RETURN_TYPE
, FPU_IEEEDPAbs
,
96 AROS_LHAQUAD(double, y
, D0
, D1
),
97 struct MathIeeeDoubBasBase
*, MathIeeeDoubBasBase
, 9, MathIeeeDoubBas
103 QUAD
* Res
= (QUAD
*)&y
; /* this forces the returned value to be in D0/D1 */
111 } /* FPU_IEEEDPAbs */
113 AROS_LHQUAD1(RETURN_TYPE
, FPU_IEEEDPNeg
,
114 AROS_LHAQUAD(double, y
, D0
, D1
),
115 struct MathIeeeDoubBasBase
*, MathIeeeDoubBasBase
, 10, MathIeeeDoubBas
)
119 QUAD
* Res
= (QUAD
*)&y
; /* this forces the returned value to be in D0/D1 */
126 } /* FPU_IEEEDPNeg */
128 AROS_LHQUAD2(RETURN_TYPE
, FPU_IEEEDPAdd
,
129 AROS_LHAQUAD(double, y
, D0
, D1
),
130 AROS_LHAQUAD(double, z
, D2
, D3
),
131 struct MathIeeeDoubBasBase
*, MathIeeeDoubBasBase
, 11, MathIeeeDoubBas
136 QUAD
* Res
= (QUAD
*)&y
; /* this forces the returned value to be in D0/D1 */
143 } /* FPU_IEEEDPAdd */
145 AROS_LHQUAD2(RETURN_TYPE
, FPU_IEEEDPSub
,
146 AROS_LHAQUAD(double, y
, D0
, D1
),
147 AROS_LHAQUAD(double, z
, D2
, D3
),
148 struct MathIeeeDoubBasBase
*, MathIeeeDoubBasBase
, 12, MathIeeeDoubBas
)
152 QUAD
* Res
= (QUAD
*)&y
; /* this forces the returned value to be in D0/D1 */
159 } /* FPU_IEEEDPSub */
161 AROS_LHQUAD2(RETURN_TYPE
, FPU_IEEEDPMul
,
162 AROS_LHAQUAD(double, y
, D0
, D1
),
163 AROS_LHAQUAD(double, z
, D2
, D3
),
164 struct MathIeeeDoubBasBase
*, MathIeeeDoubBasBase
, 13, MathIeeeDoubBas
169 QUAD
* Res
= (QUAD
*)&y
; /* this forces the returned value to be in D0/D1 */
176 } /* FPU_IEEEDPMul */
178 AROS_LHQUAD2(RETURN_TYPE
, FPU_IEEEDPDiv
,
179 AROS_LHAQUAD(double, y
, D0
, D1
),
180 AROS_LHAQUAD(double, z
, D2
, D3
),
181 struct MathIeeeDoubBasBase
*, MathIeeeDoubBasBase
, 14, MathIeeeDoubBas
186 QUAD
* Res
= (QUAD
*)&y
; /* this forces the returned value to be in D0/D1 */
193 } /* FPU_IEEEDPDiv */
195 AROS_LHQUAD1(RETURN_TYPE
, FPU_IEEEDPFloor
,
196 AROS_LHAQUAD(double, y
, D0
, D1
),
197 struct MathIeeeDoubBasBase
*, MathIeeeDoubBasBase
, 15, MathIeeeDoubBas
201 /* return floor(y); */
204 } /* FPU_IEEEDPFloor */
206 AROS_LHQUAD1(RETURN_TYPE
, FPU_IEEEDPCeil
,
207 AROS_LHAQUAD(double, y
, D0
, D1
),
208 struct MathIeeeDoubBasBase
*, MathIeeeDoubBasBase
, 16, MathIeeeDoubBas
212 /* return ceil(y); */
215 } /* FPU_IEEEDPCeil */