source: trunk/gcc/libffi/src/x86/sysv.S

Last change on this file was 1392, checked in by bird, 21 years ago

This commit was generated by cvs2svn to compensate for changes in r1391,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 3.9 KB
Line 
1/* -----------------------------------------------------------------------
2 sysv.S - Copyright (c) 1996, 1998, 2001, 2002 Cygnus Solutions
3
4 X86 Foreign Function Interface
5
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:
13
14 The above copyright notice and this permission notice shall be included
15 in all copies or substantial portions of the Software.
16
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 ----------------------------------------------------------------------- */
25
26#ifndef __x86_64__
27
28#define LIBFFI_ASM
29#include <ffi.h>
30
31.text
32
33.globl ffi_prep_args
34
35 .align 4
36.globl ffi_call_SYSV
37 .type ffi_call_SYSV,@function
38
39ffi_call_SYSV:
40.LFB1:
41 pushl %ebp
42.LCFI0:
43 movl %esp,%ebp
44.LCFI1:
45 /* Make room for all of the new args. */
46 movl 16(%ebp),%ecx
47 subl %ecx,%esp
48
49 movl %esp,%eax
50
51 /* Place all of the ffi_prep_args in position */
52 pushl 12(%ebp)
53 pushl %eax
54 call *8(%ebp)
55
56 /* Return stack to previous state and call the function */
57 addl $8,%esp
58
59 call *28(%ebp)
60
61 /* Remove the space we pushed for the args */
62 movl 16(%ebp),%ecx
63 addl %ecx,%esp
64
65 /* Load %ecx with the return type code */
66 movl 20(%ebp),%ecx
67
68 /* If the return value pointer is NULL, assume no return value. */
69 cmpl $0,24(%ebp)
70 jne retint
71
72 /* Even if there is no space for the return value, we are
73 obliged to handle floating-point values. */
74 cmpl $FFI_TYPE_FLOAT,%ecx
75 jne noretval
76 fstp %st(0)
77
78 jmp epilogue
79
80retint:
81 cmpl $FFI_TYPE_INT,%ecx
82 jne retfloat
83 /* Load %ecx with the pointer to storage for the return value */
84 movl 24(%ebp),%ecx
85 movl %eax,0(%ecx)
86 jmp epilogue
87
88retfloat:
89 cmpl $FFI_TYPE_FLOAT,%ecx
90 jne retdouble
91 /* Load %ecx with the pointer to storage for the return value */
92 movl 24(%ebp),%ecx
93 fstps (%ecx)
94 jmp epilogue
95
96retdouble:
97 cmpl $FFI_TYPE_DOUBLE,%ecx
98 jne retlongdouble
99 /* Load %ecx with the pointer to storage for the return value */
100 movl 24(%ebp),%ecx
101 fstpl (%ecx)
102 jmp epilogue
103
104retlongdouble:
105 cmpl $FFI_TYPE_LONGDOUBLE,%ecx
106 jne retint64
107 /* Load %ecx with the pointer to storage for the return value */
108 movl 24(%ebp),%ecx
109 fstpt (%ecx)
110 jmp epilogue
111
112retint64:
113 cmpl $FFI_TYPE_SINT64,%ecx
114 jne retstruct
115 /* Load %ecx with the pointer to storage for the return value */
116 movl 24(%ebp),%ecx
117 movl %eax,0(%ecx)
118 movl %edx,4(%ecx)
119
120retstruct:
121 /* Nothing to do! */
122
123noretval:
124epilogue:
125 movl %ebp,%esp
126 popl %ebp
127 ret
128.LFE1:
129.ffi_call_SYSV_end:
130 .size ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV
131
132.section .eh_frame,"aw",@progbits
133__FRAME_BEGIN__:
134 .4byte .LLCIE1
135.LSCIE1:
136 .4byte 0x0
137 .byte 0x1
138 .byte 0x0
139 .byte 0x1
140 .byte 0x7c
141 .byte 0x8
142 .byte 0xc
143 .byte 0x4
144 .byte 0x4
145 .byte 0x88
146 .byte 0x1
147 .align 4
148.LECIE1:
149 .set .LLCIE1,.LECIE1-.LSCIE1
150 .4byte .LLFDE1
151.LSFDE1:
152 .4byte .LSFDE1-__FRAME_BEGIN__
153 .4byte .LFB1
154 .4byte .LFE1-.LFB1
155 .byte 0x4
156 .4byte .LCFI0-.LFB1
157 .byte 0xe
158 .byte 0x8
159 .byte 0x85
160 .byte 0x2
161 .byte 0x4
162 .4byte .LCFI1-.LCFI0
163 .byte 0xd
164 .byte 0x5
165 .align 4
166.LEFDE1:
167 .set .LLFDE1,.LEFDE1-.LSFDE1
168
169#endif /* ifndef __x86_64__ */
Note: See TracBrowser for help on using the repository browser.