Skip to content

Commit 2fac25c

Browse files
committed
Add support for -mfastcall
1 parent 0a65990 commit 2fac25c

24 files changed

+663
-448
lines changed

include/sys/gmon.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ extern struct gmonparam _gmonparam;
173173
__BEGIN_DECLS
174174

175175
/* Set up data structures and start profiling. */
176-
extern void monstartup (u_long __lowpc, u_long __highpc) __THROW;
177-
extern void __monstartup (u_long __lowpc, u_long __highpc) __THROW;
176+
extern void monstartup (void *__lowpc, void *__highpc) __THROW;
178177

179178
/* Clean up profiling and write out gmon.out. */
180179
extern void _mcleanup (void) __THROW;

mintlib/_normdf.S

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
| mjr: not needed _normdf for -__M68881__ or the sfp004
1+
| mjr: not needed _normdf for -__HAVE_68881__ or the sfp004
22

33
|#######################################################################
44

@@ -55,7 +55,7 @@
5555
.even
5656
.globl C_SYMBOL_NAME(_infinitydf)
5757

58-
#if !defined (__M68881__) && !defined (sfp004)
58+
#if !defined (__HAVE_68881__) && !defined (sfp004)
5959
.globl C_SYMBOL_NAME(__normdf)
6060
.globl C_SYMBOL_NAME(__norm_df)
6161
#include "errbase.h"
@@ -68,6 +68,7 @@ LC0:
6868
| C entry, for procs dealing with the internal representation :
6969
| double __normdf(long long mant, int exp, int sign, int rbits);
7070
C_SYMBOL_NAME(__normdf):
71+
/* note: long long value is passed on stack, even for -mfastcall */
7172
lea %sp@(4),%a0 | parameter pointer
7273
#ifdef __mcoldfire__
7374
lea %sp@(-24),%sp
@@ -80,17 +81,37 @@ C_SYMBOL_NAME(__normdf):
8081
#endif
8182

8283
# ifdef __MSHORT__
84+
#ifdef __FASTCALL__
85+
#ifdef __mcoldfire__
86+
movel %d2,%d3
87+
movel %d1,%d2
88+
movel %d3,%d1
89+
#else
90+
exg %d1,%d2
91+
#endif
92+
#else
8393
movew %a0@+,%d0 | get exponent
8494
movew %a0@+,%d2 | get sign
8595
movew %a0@+,%d1 | rounding information
96+
#endif
8697
# else
98+
#ifdef __FASTCALL__
99+
#ifdef __mcoldfire__
100+
movel %d2,%d3
101+
movel %d1,%d2
102+
movel %d3,%d1
103+
#else
104+
exg %d1,%d2
105+
#endif
106+
#else
87107
movel %a0@+,%d0 | get exponent
88108
movel %a0@+,%d2 | get sign
109+
movel %a0@+,%d1 | rounding information
110+
#endif
111+
tstl %d2
89112
jpl 0f | or bit 31 to bit 15 for later tests
90113
bset #15,%d2
91-
0: movel %a0@+,%d1 | rounding information
92-
93-
movel #0x7fff,%d3
114+
0: movel #0x7fff,%d3
94115
cmpl %d3,%d0 | test exponent
95116
jgt oflow
96117
notl %d3 | #-0x8000 -> d3
@@ -202,18 +223,18 @@ C_SYMBOL_NAME(__norm_df):
202223
#ifdef __mcoldfire__
203224
cmpb #0x80,%d1
204225
jne 7f | round up
205-
movew %d5,%d1 | tie case - round to even
206-
| dont need rounding bits any more
207-
andl #1,%d1 | check if even
226+
movew %d5,%d1 | tie case - round to even
227+
| dont need rounding bits any more
228+
andl #1,%d1 | check if even
208229
#else
209230
negb %d1
210231
jvc 7f | round up
211-
movew %d5,%d1 | tie case - round to even
212-
| dont need rounding bits any more
213-
andw #1,%d1 | check if even
232+
movew %d5,%d1 | tie case - round to even
233+
| dont need rounding bits any more
234+
andw #1,%d1 | check if even
214235
#endif
215-
jeq 8f | mantissa is even - no action necessary
216-
| fall through
236+
jeq 8f | mantissa is even - no action necessary
237+
| fall through
217238
7:
218239
clrl %d1 | zero rounding bits
219240
addl #1,%d5
@@ -276,21 +297,27 @@ retzok:
276297
movw %d2,%d0
277298
swap %d0
278299
andil #0x80000000,%d0
279-
0: moveml %sp@,%d2-%d7
300+
moveml %sp@,%d2-%d7
280301
lea %sp@(24),%sp
281302
#else
282303
lslw #1,%d2 | set value of extension
283304
roxrl #1,%d0 | and move it to hight bit of d0
284-
0: moveml %sp@+,%d2-%d7
305+
moveml %sp@+,%d2-%d7
285306
#endif
286307
rts
287308

288309
oflow:
289310
#ifdef ERROR_CHECK
311+
#ifdef __FASTCALL__
312+
lea %pc@(LC0),%a1
313+
movel Stderr,%a0
314+
jbsr C_SYMBOL_NAME(fprintf) |
315+
#else
290316
pea %pc@(LC0)
291317
movel Stderr,%sp@-
292318
jbsr C_SYMBOL_NAME(fprintf) |
293-
addql #8,%%sp |
319+
addql #8,%sp |
320+
#endif
294321
moveq #Erange,%d0
295322
Emove %d0,Errno
296323
#endif /* ERROR_CHECK */
@@ -314,4 +341,4 @@ oflow:
314341
#endif
315342
rts
316343

317-
#endif /* __M68881__ */
344+
#endif /* __HAVE_68881__ */

mintlib/checkcpu.S

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,19 @@
2626

2727
.globl C_SYMBOL_NAME(_checkcpu)
2828
C_SYMBOL_NAME(_checkcpu):
29-
#ifdef __M68020__
29+
#if defined(__mc68020__) || defined(__mc68030__) || defined(__mc68040__) || defined(__mc68060__)
3030
subql #4,%sp | Local variable for cookie value
3131

32+
#ifdef __FASTCALL__
33+
movl %sp,%a0
34+
movl #0x5f435055,%d0 | "_CPU"
35+
jsr C_SYMBOL_NAME(Getcookie)
36+
#else
3237
pea %sp@
3338
movl #0x5f435055,%sp@- | "_CPU"
3439
jsr C_SYMBOL_NAME(Getcookie)
3540
addql #8,%sp
41+
#endif
3642

3743
movel %sp@+,%d1 | Cookie value
3844

@@ -43,7 +49,7 @@ C_SYMBOL_NAME(_checkcpu):
4349
bhss .ok020 | CPU >= 68020
4450

4551
.bad020:
46-
pea .err020 | Error message
52+
pea .err020(%pc) | Error message
4753
bra .printexit
4854

4955
.err020:
@@ -57,17 +63,23 @@ C_SYMBOL_NAME(_checkcpu):
5763
#ifdef __mcoldfire__
5864
subql #4,%sp | Local variable for cookie value
5965

66+
#ifdef __FASTCALL__
67+
movl %sp,%a0
68+
movl #0x5f43465f,%d0 | "_CF_"
69+
jsr C_SYMBOL_NAME(Getcookie)
70+
#else
6071
pea %sp@
6172
movl #0x5f43465f,%sp@- | "_CF_"
6273
jsr C_SYMBOL_NAME(Getcookie)
6374
addql #8,%sp
75+
#endif
6476

6577
movel %sp@+,%d1 | Cookie value
6678

6779
tstl %d0
6880
beqs .okv4e | _CF_ cookie found
6981

70-
pea .errv4e | Error message
82+
pea .errv4e(%pc) | Error message
7183
bra .printexit
7284

7385
.errv4e:
@@ -78,13 +90,19 @@ C_SYMBOL_NAME(_checkcpu):
7890
.okv4e:
7991
#endif
8092

81-
#ifdef __M68881__
93+
#ifdef __HAVE_68881__
8294
subql #4,%sp | Local variable for cookie value
8395

96+
#ifdef __FASTCALL__
97+
movl %sp,%a0
98+
movl #0x5f465055,%d0 | "_FPU"
99+
jsr C_SYMBOL_NAME(Getcookie)
100+
#else
84101
pea %sp@
85102
movl #0x5f465055,%sp@- | "_FPU"
86103
jsr C_SYMBOL_NAME(Getcookie)
87104
addql #8,%sp
105+
#endif
88106

89107
movel %sp@+,%d1 | Cookie value
90108

@@ -95,7 +113,7 @@ C_SYMBOL_NAME(_checkcpu):
95113
bnes .ok881 | FPU present
96114

97115
.bad881:
98-
pea .err881 | Error message
116+
pea .err881(%pc) | Error message
99117
bra .printexit
100118

101119
.err881:
@@ -107,6 +125,7 @@ C_SYMBOL_NAME(_checkcpu):
107125
#endif
108126
rts | All requirements passed
109127

128+
#if defined(__mc68020__) || defined(__mc68030__) || defined(__mc68040__) || defined(__mc68060__) || defined(__mcoldfire__) || defined(__HAVE_68881__)
110129
| Print a message then exit.
111130
| The message must have been pushed on the stack.
112131
.printexit:
@@ -117,3 +136,4 @@ C_SYMBOL_NAME(_checkcpu):
117136
movew #-1,%sp@- | Failure
118137
movew #0x4c,%sp@- | Pterm()
119138
trap #1
139+
#endif

0 commit comments

Comments
 (0)