1 Index: libffi/ChangeLog
2 ===================================================================
3 --- libffi.orig/ChangeLog
6 +2012-03-19 Alan Hourihane <alanh@fairlite.co.uk>
8 + * src/m68k/ffi.c: Add MINT support.
9 + * src/m68k/sysv.S: Ditto.
11 2012-03-19 chennam <csit@axway.com>
13 * src/powerpc/ffi_darwin.c (ffi_prep_closure_loc): Fix AIX closure
14 Index: libffi/src/m68k/ffi.c
15 ===================================================================
16 --- libffi.orig/src/m68k/ffi.c
17 +++ libffi/src/m68k/ffi.c
19 /* -----------------------------------------------------------------------
22 - m68k Foreign Function Interface
24 + m68k Foreign Function Interface
25 ----------------------------------------------------------------------- */
29 void rtems_cache_flush_multiple_data_lines( const void *, size_t );
31 #include <sys/syscall.h>
33 +#include <mint/mintbind.h>
34 +#include <mint/ssystem.h>
36 #include <asm/cachectl.h>
40 void ffi_call_SYSV (extended_cif *,
42 @@ -39,8 +44,12 @@ ffi_prep_args (void *stack, extended_cif
46 - if (ecif->cif->rtype->type == FFI_TYPE_STRUCT
47 - && !ecif->cif->flags)
50 + (ecif->cif->rtype->type == FFI_TYPE_LONGDOUBLE) ||
52 + (((ecif->cif->rtype->type == FFI_TYPE_STRUCT)
53 + && !ecif->cif->flags)))
54 struct_value_ptr = ecif->rvalue;
56 struct_value_ptr = NULL;
57 @@ -51,12 +60,12 @@ ffi_prep_args (void *stack, extended_cif
62 + size_t z = (*p_arg)->size;
63 + int type = (*p_arg)->type;
68 - switch ((*p_arg)->type)
72 *(signed int *) argp = (signed int) *(SINT8 *) *p_argv;
73 @@ -75,7 +84,14 @@ ffi_prep_args (void *stack, extended_cif
78 + if (z == 1 || z == 2)
79 + memcpy (argp + 2, *p_argv, z);
81 + memcpy (argp, *p_argv, z);
83 memcpy (argp + sizeof (int) - z, *p_argv, z);
88 @@ -120,17 +136,34 @@ ffi_prep_cif_machdep (ffi_cif *cif)
92 + if (cif->rtype->elements[0]->type == FFI_TYPE_STRUCT &&
93 + cif->rtype->elements[1])
99 switch (cif->rtype->size)
103 + cif->flags = CIF_FLAGS_STRUCT2;
105 cif->flags = CIF_FLAGS_STRUCT1;
109 cif->flags = CIF_FLAGS_STRUCT2;
115 cif->flags = CIF_FLAGS_INT;
121 cif->flags = CIF_FLAGS_DINT;
123 @@ -150,7 +183,11 @@ ffi_prep_cif_machdep (ffi_cif *cif)
125 #if (FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE)
126 case FFI_TYPE_LONGDOUBLE:
130 cif->flags = CIF_FLAGS_LDOUBLE;
135 @@ -218,6 +255,26 @@ ffi_prep_incoming_args_SYSV (char *stack
141 + cif->rtype->type == FFI_TYPE_STRUCT &&
142 + (z == 1 || z == 2))
144 + *p_argv = (void *) (argp + 2);
150 + cif->rtype->type == FFI_TYPE_STRUCT &&
151 + (z == 3 || z == 4))
153 + *p_argv = (void *) (argp);
161 *p_argv = (void *) (argp + 4 - z);
162 @@ -267,14 +324,21 @@ ffi_prep_closure_loc (ffi_closure* closu
163 *(unsigned short *)closure->tramp = 0x207c;
164 *(void **)(closure->tramp + 2) = codeloc;
165 *(unsigned short *)(closure->tramp + 6) = 0x4ef9;
166 - if (cif->rtype->type == FFI_TYPE_STRUCT
171 + (cif->rtype->type == FFI_TYPE_LONGDOUBLE) ||
173 + (((cif->rtype->type == FFI_TYPE_STRUCT)
175 *(void **)(closure->tramp + 8) = ffi_closure_struct_SYSV;
177 *(void **)(closure->tramp + 8) = ffi_closure_SYSV;
180 rtems_cache_flush_multiple_data_lines( codeloc, FFI_TRAMPOLINE_SIZE );
181 +#elif defined(__MINT__)
182 + Ssystem(S_FLUSHCACHE, codeloc, FFI_TRAMPOLINE_SIZE);
184 syscall(SYS_cacheflush, codeloc, FLUSH_SCOPE_LINE,
185 FLUSH_CACHE_BOTH, FFI_TRAMPOLINE_SIZE);
186 @@ -286,4 +350,3 @@ ffi_prep_closure_loc (ffi_closure* closu
191 Index: libffi/src/m68k/sysv.S
192 ===================================================================
193 --- libffi.orig/src/m68k/sysv.S
194 +++ libffi/src/m68k/sysv.S
196 /* -----------------------------------------------------------------------
198 - sysv.S - Copyright (c) 1998, 2012 Andreas Schwab
199 + sysv.S - Copyright (c) 2012 Alan Hourihane
200 + Copyright (c) 1998, 2012 Andreas Schwab
201 Copyright (c) 2008 Red Hat, Inc.
203 m68k Foreign Function Interface
205 #define CFI_ENDPROC()
209 +#define CALLFUNC(funcname) _ ## funcname
211 +#define CALLFUNC(funcname) funcname
216 - .globl ffi_call_SYSV
217 - .type ffi_call_SYSV,@function
218 + .globl CALLFUNC(ffi_call_SYSV)
219 + .type CALLFUNC(ffi_call_SYSV),@function
223 +CALLFUNC(ffi_call_SYSV):
227 @@ -63,14 +70,18 @@ ffi_call_SYSV:
232 + jsr CALLFUNC(ffi_prep_args)
234 - bsr.l ffi_prep_args@PLTPC
235 + bsr.l CALLFUNC(ffi_prep_args@PLTPC)
239 | Pass pointer to struct value, if any
248 @@ -142,7 +153,11 @@ retlongdouble:
260 @@ -162,13 +177,13 @@ epilogue:
264 - .size ffi_call_SYSV,.-ffi_call_SYSV
265 + .size CALLFUNC(ffi_call_SYSV),.-CALLFUNC(ffi_call_SYSV)
267 - .globl ffi_closure_SYSV
268 - .type ffi_closure_SYSV, @function
269 + .globl CALLFUNC(ffi_closure_SYSV)
270 + .type CALLFUNC(ffi_closure_SYSV), @function
274 +CALLFUNC(ffi_closure_SYSV):
278 @@ -178,9 +193,9 @@ ffi_closure_SYSV:
282 - jsr ffi_closure_SYSV_inner
283 + jsr CALLFUNC(ffi_closure_SYSV_inner)
285 - bsr.l ffi_closure_SYSV_inner@PLTPC
286 + bsr.l CALLFUNC(ffi_closure_SYSV_inner@PLTPC)
290 @@ -240,13 +255,13 @@ ffi_closure_SYSV:
294 - .size ffi_closure_SYSV,.-ffi_closure_SYSV
295 + .size CALLFUNC(ffi_closure_SYSV),.-CALLFUNC(ffi_closure_SYSV)
297 - .globl ffi_closure_struct_SYSV
298 - .type ffi_closure_struct_SYSV, @function
299 + .globl CALLFUNC(ffi_closure_struct_SYSV)
300 + .type CALLFUNC(ffi_closure_struct_SYSV), @function
303 -ffi_closure_struct_SYSV:
304 +CALLFUNC(ffi_closure_struct_SYSV):
308 @@ -256,14 +271,14 @@ ffi_closure_struct_SYSV:
312 - jsr ffi_closure_SYSV_inner
313 + jsr CALLFUNC(ffi_closure_SYSV_inner)
315 - bsr.l ffi_closure_SYSV_inner@PLTPC
316 + bsr.l CALLFUNC(ffi_closure_SYSV_inner@PLTPC)
321 - .size ffi_closure_struct_SYSV,.-ffi_closure_struct_SYSV
322 + .size CALLFUNC(ffi_closure_struct_SYSV),.-CALLFUNC(ffi_closure_struct_SYSV)
324 #if defined __ELF__ && defined __linux__
325 .section .note.GNU-stack,"",@progbits
327 ===================================================================
328 --- libffi.orig/README
330 @@ -58,6 +58,7 @@ tested:
338 @@ -150,6 +151,7 @@ See the ChangeLog files for details.
340 Add Amiga newer MacOS support.
341 Add Linux/x32 support.
342 + Add m68k FreeMiNT support.
343 Add thiscall and fastcall support on Windows.
344 Fix Octeon and MC68881 support.
345 Fix code pessimizations.