LEFT | RIGHT |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 /* | 5 /* |
6 * Apple still insists on underscore prefixes for C function names. | 6 * Apple still insists on underscore prefixes for C function names. |
7 */ | 7 */ |
8 #ifdef __APPLE__ | 8 #if defined(__APPLE__) || defined(__MINGW32__) |
9 #define EXT(s) _##s | 9 #define EXT(s) _##s |
10 #else | 10 #else |
11 #define EXT(s) s | 11 #define EXT(s) s |
12 #endif | 12 #endif |
13 | 13 |
14 /* | 14 /* |
15 * void crosscall_386(void (*fn)(void)) | 15 * void crosscall_386(void (*fn)(void)) |
16 * | 16 * |
17 * Calling into the 8c tool chain, where all registers are caller save. | 17 * Calling into the 8c tool chain, where all registers are caller save. |
18 * Called from standard x86 ABI, where %ebp, %ebx, %esi, | 18 * Called from standard x86 ABI, where %ebp, %ebx, %esi, |
(...skipping 10 matching lines...) Expand all Loading... |
29 movl 8(%ebp), %eax /* fn */ | 29 movl 8(%ebp), %eax /* fn */ |
30 call *%eax | 30 call *%eax |
31 | 31 |
32 popl %edi | 32 popl %edi |
33 popl %esi | 33 popl %esi |
34 popl %ebx | 34 popl %ebx |
35 popl %ebp | 35 popl %ebp |
36 ret | 36 ret |
37 | 37 |
38 /* | 38 /* |
39 * void crosscall2(void (*fn)(void *, int32), void*, int32) | 39 * void crosscall2(void (*fn)(void*, int32), void*, int32) |
40 * | 40 * |
41 * Save registers and call fn with two arguments. | 41 * Save registers and call fn with two arguments. |
42 */ | 42 */ |
43 .globl EXT(crosscall2) | 43 .globl EXT(crosscall2) |
44 EXT(crosscall2): | 44 EXT(crosscall2): |
45 pushl %ebp | 45 pushl %ebp |
46 movl %esp, %ebp | 46 movl %esp, %ebp |
47 pushl %ebx | 47 pushl %ebx |
48 pushl %esi | 48 pushl %esi |
49 pushl %edi | 49 pushl %edi |
50 | 50 |
51 pushl 16(%ebp) | 51 pushl 16(%ebp) |
52 pushl 12(%ebp) | 52 pushl 12(%ebp) |
53 mov 8(%ebp), %eax | 53 mov 8(%ebp), %eax |
54 call *%eax | 54 call *%eax |
55 addl $8,%esp | 55 addl $8,%esp |
56 | 56 |
57 popl %edi | 57 popl %edi |
58 popl %esi | 58 popl %esi |
59 popl %ebx | 59 popl %ebx |
60 popl %ebp | 60 popl %ebp |
61 ret | 61 ret |
LEFT | RIGHT |