Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(10)

Delta Between Two Patch Sets: Modules/_ctypes/libffi_msvc/win32.S

Issue 3871: cross and native build of python for mingw32 with distutils
Left Patch Set: Created 9 years, 8 months ago
Right Patch Set: Created 7 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « Modules/_ctypes/_ctypes.c ('k') | Modules/_cursesmodule.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 /* -----------------------------------------------------------------------
2 win32.S - Copyright (c) 1996, 1998, 2001, 2002 Red Hat, Inc.
3 Copyright (c) 2001 John Beniton
4 Copyright (c) 2002 Ranjit Mathew
5
6
7 X86 Foreign Function Interface
8
9 Permission is hereby granted, free of charge, to any person obtaining
10 a copy of this software and associated documentation files (the
11 ``Software''), to deal in the Software without restriction, including
12 without limitation the rights to use, copy, modify, merge, publish,
13 distribute, sublicense, and/or sell copies of the Software, and to
14 permit persons to whom the Software is furnished to do so, subject to
15 the following conditions:
16
17 The above copyright notice and this permission notice shall be included
18 in all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 OTHER DEALINGS IN THE SOFTWARE.
27 ----------------------------------------------------------------------- */
28
29 #define LIBFFI_ASM
30 #include <fficonfig.h>
31 #include <ffi.h>
32
33 .text
34
35 .globl ffi_prep_args
36
37 # This assumes we are using gas.
38 .balign 16
39 .globl _ffi_call_x86
40
41 _ffi_call_x86:
42 pushl %ebp
43 movl %esp,%ebp
44
45 #THe: save previous %esi, and store the current stack pointer in %esi
46 pushl %esi
47 movl %esp,%esi
48
49 # Make room for all of the new args.
50 movl 16(%ebp),%ecx
51 subl %ecx,%esp
52
53 movl %esp,%eax
54
55 # Place all of the ffi_prep_args in position
56 pushl 12(%ebp)
57 pushl %eax
58 call *8(%ebp)
59
60 # Return stack to previous state and call the function
61 addl $8,%esp
62
63 # FIXME: Align the stack to a 128-bit boundary to avoid
64 # potential performance hits.
65
66 call *28(%ebp)
67
68 # Load ecif->cif->abi
69 #masm# mov ecx, [ebp + 12]
70 movl 12(%ebp),%ecx
71 #masm# mov ecx, [ecx]ecif.cif
72 movl (%ecx),%ecx
73 #masm# mov ecx, [ecx]ecif.cif.abi
74 movl (%ecx),%ecx
75 #masm# cmp ecx, FFI_STDCALL
76 cmpl $2,%ecx
77 je noclean
78
79 # STDCALL: Remove the space we pushed for the args
80 movl 16(%ebp),%ecx
81 addl %ecx,%esp
82
83 # CDECL: Caller has already cleaned the stack
84 noclean:
85 # Check that esp has the same value as before!
86 sub %esp,%esi # calculate stack pointer difference
87
88 # Load %ecx with the return type code
89 movl 20(%ebp),%ecx
90
91 # If the return value pointer is NULL, assume no return value.
92 cmpl $0,24(%ebp)
93 jne retint
94
95 # Even if there is no space for the return value, we are
96 # obliged to handle floating-point values.
97 cmpl $FFI_TYPE_FLOAT,%ecx
98 jne noretval
99 fstp %st(0)
100
101 jmp epilogue
102
103 retint:
104 cmpl $FFI_TYPE_INT,%ecx
105 jne retfloat
106 # Load %ecx with the pointer to storage for the return value
107 movl 24(%ebp),%ecx
108 movl %eax,0(%ecx)
109 jmp epilogue
110
111 retfloat:
112 cmpl $FFI_TYPE_FLOAT,%ecx
113 jne retdouble
114 # Load %ecx with the pointer to storage for the return value
115 movl 24(%ebp),%ecx
116 fstps (%ecx)
117 jmp epilogue
118
119 retdouble:
120 cmpl $FFI_TYPE_DOUBLE,%ecx
121 jne retlongdouble
122 # Load %ecx with the pointer to storage for the return value
123 movl 24(%ebp),%ecx
124 fstpl (%ecx)
125 jmp epilogue
126
127 retlongdouble:
128 cmpl $FFI_TYPE_LONGDOUBLE,%ecx
129 jne retint64
130 # Load %ecx with the pointer to storage for the return value
131 movl 24(%ebp),%ecx
132 fstpt (%ecx)
133 jmp epilogue
134
135 retint64:
136 cmpl $FFI_TYPE_SINT64,%ecx
137 jne retstruct
138 # Load %ecx with the pointer to storage for the return value
139 movl 24(%ebp),%ecx
140 movl %eax,0(%ecx)
141 movl %edx,4(%ecx)
142
143 retstruct:
144 # Nothing to do!
145
146 noretval:
147 epilogue:
148 movl %esi,%eax # return the stack pointer detlta in %eax
149 popl %esi # restore previous %esi
150 movl %ebp,%esp
151 popl %ebp
152 ret
153
154 .ffi_call_x86_end:
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+