1 /* -----------------------------------------------------------------------
3 sysv.S - Copyright (c) 2012 Alan Hourihane
4 Copyright (c) 1998, 2012 Andreas Schwab
5 Copyright (c) 2008 Red Hat, Inc.
7 m68k 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,
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 DEALINGS IN THE SOFTWARE.
28 ----------------------------------------------------------------------- */
31 #include <fficonfig.h>
34 #ifdef HAVE_AS_CFI_PSEUDO_OP
35 #define CFI_STARTPROC() .cfi_startproc
36 #define CFI_OFFSET(reg,off) .cfi_offset reg,off
37 #define CFI_DEF_CFA(reg,off) .cfi_def_cfa reg,off
38 #define CFI_ENDPROC() .cfi_endproc
40 #define CFI_STARTPROC()
41 #define CFI_OFFSET(reg,off)
42 #define CFI_DEF_CFA(reg,off)
47 #define CALLFUNC(funcname) _ ## funcname
49 #define CALLFUNC(funcname) funcname
54 .globl CALLFUNC(ffi_call_SYSV)
55 .type CALLFUNC(ffi_call_SYSV),@function
58 CALLFUNC(ffi_call_SYSV):
66 | Make room for all of the new args.
73 jsr CALLFUNC(ffi_prep_args)
75 bsr.l CALLFUNC(ffi_prep_args@PLTPC)
79 | Pass pointer to struct value, if any
90 | Remove the space we pushed for the args
93 | Load the pointer to storage for the return value
96 | Load the return type code
99 | If the return value pointer is NULL, assume no return value.
100 | NOTE: On the mc68000, tst on an address register is not supported.
101 #if !defined(__mc68020__) && !defined(__mc68030__) && !defined(__mc68040__) && !defined(__mc68060__) && !defined(__mcoldfire__)
123 #if defined(__MC68881__) || defined(__HAVE_68881__)
133 #if defined(__MC68881__) || defined(__HAVE_68881__)
144 #if defined(__MC68881__) || defined(__HAVE_68881__)
180 .size CALLFUNC(ffi_call_SYSV),.-CALLFUNC(ffi_call_SYSV)
182 .globl CALLFUNC(ffi_closure_SYSV)
183 .type CALLFUNC(ffi_closure_SYSV), @function
186 CALLFUNC(ffi_closure_SYSV):
196 jsr CALLFUNC(ffi_closure_SYSV_inner)
198 bsr.l CALLFUNC(ffi_closure_SYSV_inner@PLTPC)
217 #if defined(__MC68881__) || defined(__HAVE_68881__)
226 jcs .Lcls_ret_ldouble
227 #if defined(__MC68881__) || defined(__HAVE_68881__)
235 #if defined(__MC68881__) || defined(__HAVE_68881__)
245 jne .Lcls_ret_struct2
246 jcs .Lcls_ret_struct1
258 .size CALLFUNC(ffi_closure_SYSV),.-CALLFUNC(ffi_closure_SYSV)
260 .globl CALLFUNC(ffi_closure_struct_SYSV)
261 .type CALLFUNC(ffi_closure_struct_SYSV), @function
264 CALLFUNC(ffi_closure_struct_SYSV):
274 jsr CALLFUNC(ffi_closure_SYSV_inner)
276 bsr.l CALLFUNC(ffi_closure_SYSV_inner@PLTPC)
281 .size CALLFUNC(ffi_closure_struct_SYSV),.-CALLFUNC(ffi_closure_struct_SYSV)
283 #if defined __ELF__ && defined __linux__
284 .section .note.GNU-stack,"",@progbits