Skip to content

Commit 0cd232d

Browse files
committed
fix calling convention on win64, mostly passing the numerical tests
1 parent bb082ac commit 0cd232d

16 files changed

Lines changed: 107 additions & 18 deletions

amd64/e_remainderl.S

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,23 @@
99
//__FBSDID("$FreeBSD: src/lib/msun/amd64/e_remainderl.S,v 1.2 2011/01/07 16:13:12 kib Exp $")
1010

1111
ENTRY(remainderl)
12+
#ifndef _WIN64
1213
fldt 24(%rsp)
1314
fldt 8(%rsp)
15+
#else
16+
fldt (%r8)
17+
fldt (%rdx)
18+
#endif
1419
1: fprem1
1520
fstsw %ax
1621
testw $0x400,%ax
1722
jne 1b
1823
fstp %st(1)
24+
#ifdef _WIN64
25+
mov %rcx,%rax
26+
movq $0x0,0x8(%rcx)
27+
fstpt (%rcx)
28+
#endif
1929
ret
2030

2131

amd64/e_sqrtl.S

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,15 @@
2828
//__FBSDID("$FreeBSD: src/lib/msun/amd64/e_sqrtl.S,v 1.2 2011/01/07 16:13:12 kib Exp $")
2929

3030
ENTRY(sqrtl)
31+
#ifndef _WIN64
3132
fldt 8(%rsp)
3233
fsqrt
34+
#else
35+
fldt (%rdx)
36+
fsqrt
37+
mov %rcx,%rax
38+
movq $0x0,0x8(%rcx)
39+
fstpt (%rcx)
40+
#endif
3341
ret
3442

35-

amd64/s_llrint.S

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include <amd64/bsd_asm.h>
22
//__FBSDID("$FreeBSD: src/lib/msun/amd64/s_llrint.S,v 1.3 2011/02/04 21:54:06 kib Exp $")
33

4-
/* sizeof(long) == sizeof(long long) */
5-
#define fn llrint
6-
#include "s_lrint.S"
4+
ENTRY(llrint)
5+
cvtsd2si %xmm0, %rax
6+
ret
7+
END(llrint)
8+

amd64/s_llrintf.S

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include <amd64/bsd_asm.h>
22
//__FBSDID("$FreeBSD: src/lib/msun/amd64/s_llrintf.S,v 1.3 2011/02/04 21:54:06 kib Exp $")
33

4-
/* sizeof(long) == sizeof(long long) */
5-
#define fn llrintf
6-
#include "s_lrintf.S"
4+
ENTRY(llrintf)
5+
cvtss2si %xmm0, %rax
6+
ret
7+
END(llrintf)
8+

amd64/s_llrintl.S

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@
2828
//__FBSDID("$FreeBSD: src/lib/msun/amd64/s_llrintl.S,v 1.2 2011/01/07 16:13:12 kib Exp $");
2929

3030
ENTRY(llrintl)
31+
#ifndef _WIN64
3132
fldt 8(%rsp)
33+
#else
34+
fldt (%rcx)
35+
#endif
3236
subq $8,%rsp
3337
fistpll (%rsp)
3438
popq %rax
3539
ret
3640

37-
41+

amd64/s_logbl.S

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,18 @@
88
//__FBSDID("$FreeBSD: src/lib/msun/amd64/s_logbl.S,v 1.4 2011/01/07 16:13:12 kib Exp $")
99

1010
ENTRY(logbl)
11+
#ifndef _WIN64
1112
fldt 8(%rsp)
13+
#else
14+
fldt (%rdx)
15+
#endif
1216
fxtract
1317
fstp %st
18+
#ifdef _WIN64
19+
mov %rcx,%rax
20+
movq $0x0,0x8(%rcx)
21+
fstpt (%rcx)
22+
#endif
1423
ret
1524

1625

amd64/s_lrint.S

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@
2626

2727
#include <amd64/bsd_asm.h>
2828

29-
#ifndef fn
3029
//__FBSDID("$FreeBSD: src/lib/msun/amd64/s_lrint.S,v 1.3 2011/01/07 16:13:12 kib Exp $")
31-
#define fn lrint
32-
#endif
3330

34-
ENTRY(fn)
31+
ENTRY(lrint)
32+
#ifndef _WIN64
3533
cvtsd2si %xmm0, %rax
34+
#else
35+
cvtsd2si %xmm0, %eax
36+
#endif
3637
ret
37-
END(fn)
38+
END(lrint)
3839

3940

amd64/s_lrintf.S

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@
2626

2727
#include <amd64/bsd_asm.h>
2828

29-
#ifndef fn
3029
//__FBSDID("$FreeBSD: src/lib/msun/amd64/s_lrintf.S,v 1.3 2011/01/07 16:13:12 kib Exp $")
31-
#define fn lrintf
32-
#endif
3330

34-
ENTRY(fn)
31+
ENTRY(lrintf)
32+
#ifndef _WIN64
3533
cvtss2si %xmm0, %rax
34+
#else
35+
cvtss2si %xmm0, %eax
36+
#endif
3637
ret
37-
END(fn)
38+
END(lrintf)
3839

3940

amd64/s_lrintl.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@
2828
//__FBSDID("$FreeBSD: src/lib/msun/amd64/s_lrintl.S,v 1.2 2011/01/07 16:13:12 kib Exp $");
2929

3030
ENTRY(lrintl)
31+
#ifndef _WIN64
3132
fldt 8(%rsp)
33+
#else
34+
fldt (%rcx)
35+
#endif
3236
subq $8,%rsp
3337
fistpll (%rsp)
3438
popq %rax

amd64/s_remquo.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ ENTRY(remquo)
5959
andl $1,%ecx
6060
addl %ecx,%eax
6161
/* Store the quotient and return. */
62+
#ifndef _WIN64
6263
movl %eax,(%rdi)
64+
#else
65+
movl %eax,(%r8)
66+
#endif
6367
fstpl -8(%rsp)
6468
movsd -8(%rsp),%xmm0
6569
ret

0 commit comments

Comments
 (0)