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
7 X86 Foreign Function Interface
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:
17 The above copyright notice and this permission notice shall be included
18 in all copies or substantial portions of the Software.
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 ----------------------------------------------------------------------- */
30 #include <fficonfig.h>
37 # This assumes we are using gas.
45 # Make room for all of the new args.
51 # Place all of the ffi_prep_args in position
56 # Return stack to previous state and call the function
59 # FIXME: Align the stack to a 128-bit boundary to avoid
60 # potential performance hits.
64 # Remove the space we pushed for the args
68 # Load %ecx with the return type code
71 # If the return value pointer is NULL, assume no return value.
75 # Even if there is no space for the return value, we are
76 # obliged to handle floating-point values.
77 cmpl $FFI_TYPE_FLOAT,%ecx
84 cmpl $FFI_TYPE_INT,%ecx
86 # Load %ecx with the pointer to storage for the return value
92 cmpl $FFI_TYPE_FLOAT,%ecx
94 # Load %ecx with the pointer to storage for the return value
100 cmpl $FFI_TYPE_DOUBLE,%ecx
102 # Load %ecx with the pointer to storage for the return value
108 cmpl $FFI_TYPE_LONGDOUBLE,%ecx
110 # Load %ecx with the pointer to storage for the return value
116 cmpl $FFI_TYPE_SINT64,%ecx
118 # Load %ecx with the pointer to storage for the return value
134 # This assumes we are using gas.
136 .globl _ffi_call_STDCALL
142 # Make room for all of the new args.
148 # Place all of the ffi_prep_args in position
153 # Return stack to previous state and call the function
156 # FIXME: Align the stack to a 128-bit boundary to avoid
157 # potential performance hits.
161 # stdcall functions pop arguments off the stack themselves
163 # Load %ecx with the return type code
166 # If the return value pointer is NULL, assume no return value.
170 # Even if there is no space for the return value, we are
171 # obliged to handle floating-point values.
172 cmpl $FFI_TYPE_FLOAT,%ecx
179 cmpl $FFI_TYPE_INT,%ecx
181 # Load %ecx with the pointer to storage for the return value
187 cmpl $FFI_TYPE_FLOAT,%ecx
189 # Load %ecx with the pointer to storage for the return value
195 cmpl $FFI_TYPE_DOUBLE,%ecx
197 # Load %ecx with the pointer to storage for the return value
203 cmpl $FFI_TYPE_LONGDOUBLE,%ecx
205 # Load %ecx with the pointer to storage for the return value
211 cmpl $FFI_TYPE_SINT64,%ecx
213 # Load %ecx with the pointer to storage for the return value
227 .ffi_call_STDCALL_end: