1 /* -----------------------------------------------------------------------
2 sysv.S - Copyright (c) 1996, 1998, 2001, 2002, 2003, 2005 Red Hat, Inc.
4 X86 Foreign Function Interface
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 ``Software''), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
14 The above copyright notice and this permission notice shall be included
15 in all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 OTHER DEALINGS IN THE SOFTWARE.
24 ----------------------------------------------------------------------- */
29 #include <fficonfig.h>
46 /* Make room for all of the new args. */
52 /* Place all of the ffi_prep_args in position */
58 /* Return stack to previous state and call the function */
63 /* Remove the space we pushed for the args */
67 /* Load %ecx with the return type code */
70 /* If the return value pointer is NULL, assume no return value. */
74 /* Even if there is no space for the return value, we are
75 obliged to handle floating-point values. */
76 cmpl $FFI_TYPE_FLOAT,%ecx
83 cmpl $FFI_TYPE_INT,%ecx
85 /* Load %ecx with the pointer to storage for the return value */
91 cmpl $FFI_TYPE_FLOAT,%ecx
93 /* Load %ecx with the pointer to storage for the return value */
99 cmpl $FFI_TYPE_DOUBLE,%ecx
101 /* Load %ecx with the pointer to storage for the return value */
107 cmpl $FFI_TYPE_LONGDOUBLE,%ecx
109 /* Load %ecx with the pointer to storage for the return value */
115 cmpl $FFI_TYPE_SINT64,%ecx
117 /* Load %ecx with the pointer to storage for the return value */
124 cmpl $FFI_TYPE_SINT8,%ecx
126 /* Load %ecx with the pointer to storage for the return value */
132 cmpl $FFI_TYPE_SINT16,%ecx
134 /* Load %ecx with the pointer to storage for the return value */
140 cmpl $FFI_TYPE_STRUCT,%ecx
157 FFI_HIDDEN (ffi_closure_SYSV)
158 .globl _ffi_closure_SYSV
168 movl %edx, -12(%ebp) /* resp */
170 movl %edx, 4(%esp) /* args = __builtin_dwarf_cfa () */
172 movl %edx, (%esp) /* &resp */
175 call L_ffi_closure_SYSV_inner$stub
178 cmpl $FFI_TYPE_INT, %eax
180 cmpl $FFI_TYPE_FLOAT, %eax
182 cmpl $FFI_TYPE_DOUBLE, %eax
184 cmpl $FFI_TYPE_LONGDOUBLE, %eax
186 cmpl $FFI_TYPE_SINT64, %eax
188 cmpl $FFI_TYPE_SINT8, %eax
190 cmpl $FFI_TYPE_SINT16, %eax
192 cmpl $FFI_TYPE_STRUCT, %eax
229 #define RAW_CLOSURE_CIF_OFFSET ((FFI_TRAMPOLINE_SIZE + 3) & ~3)
230 #define RAW_CLOSURE_FUN_OFFSET (RAW_CLOSURE_CIF_OFFSET + 4)
231 #define RAW_CLOSURE_USER_DATA_OFFSET (RAW_CLOSURE_FUN_OFFSET + 4)
232 #define CIF_FLAGS_OFFSET 20
235 FFI_HIDDEN (ffi_closure_raw_SYSV)
236 .globl _ffi_closure_raw_SYSV
238 _ffi_closure_raw_SYSV:
247 movl RAW_CLOSURE_CIF_OFFSET(%eax), %esi /* closure->cif */
248 movl RAW_CLOSURE_USER_DATA_OFFSET(%eax), %edx /* closure->user_data */
249 movl %edx, 12(%esp) /* user_data */
250 leal 8(%ebp), %edx /* __builtin_dwarf_cfa () */
251 movl %edx, 8(%esp) /* raw_args */
253 movl %edx, 4(%esp) /* &res */
254 movl %esi, (%esp) /* cif */
255 call *RAW_CLOSURE_FUN_OFFSET(%eax) /* closure->fun */
256 movl CIF_FLAGS_OFFSET(%esi), %eax /* rtype */
257 cmpl $FFI_TYPE_INT, %eax
259 cmpl $FFI_TYPE_FLOAT, %eax
261 cmpl $FFI_TYPE_DOUBLE, %eax
263 cmpl $FFI_TYPE_LONGDOUBLE, %eax
265 cmpl $FFI_TYPE_SINT64, %eax
291 .section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5
292 L_ffi_closure_SYSV_inner$stub:
293 .indirect_symbol _ffi_closure_SYSV_inner
294 hlt ; hlt ; hlt ; hlt ; hlt
297 .section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
299 .set L$set$0,LECIE1-LSCIE1
317 .globl _ffi_call_SYSV.eh
320 .set L$set$1,LEFDE1-LASFDE1
323 .long LASFDE1-EH_frame1
325 .set L$set$2,.LFE1-.LFB1
329 .set L$set$3,.LCFI0-.LFB1
336 .set L$set$4,.LCFI1-.LCFI0
342 .globl _ffi_closure_SYSV.eh
343 _ffi_closure_SYSV.eh:
345 .set L$set$5,LEFDE2-LASFDE2
348 .long LASFDE2-EH_frame1
350 .set L$set$6,.LFE2-.LFB2
354 .set L$set$7,.LCFI2-.LFB2
361 .set L$set$8,.LCFI3-.LCFI2
370 .globl _ffi_closure_raw_SYSV.eh
371 _ffi_closure_raw_SYSV.eh:
373 .set L$set$10,LEFDE3-LASFDE3
376 .long LASFDE3-EH_frame1
378 .set L$set$11,.LFE3-.LFB3
382 .set L$set$12,.LCFI4-.LFB3
389 .set L$set$13,.LCFI5-.LCFI4
394 .set L$set$14,.LCFI6-.LCFI5
403 #endif /* ifndef __x86_64__ */