Richard Henderson
198f469e91
x86: Add support for Complex
2014-11-12 09:16:02 +01:00
Richard Henderson
b21ec1ce78
x86: Rewrite closures
...
Move everything into sysv.S, removing win32.S and freebsd.S.
Handle all abis with a single ffi_closure_inner function.
Move complexity of the raw THISCALL trampoline into assembly
instead of the trampoline itself.
Only push the context for the REGISTER abi; let the rest
receive it in a register.
2014-11-12 09:15:54 +01:00
Richard Henderson
b9ac94f3af
x86: Rewrite ffi_call
...
Decouple the assembly from FFI_TYPE_*. Merge prep_args with ffi_call,
passing the frame and the stack to the assembly.
Note that this patch isn't really standalone, as this breaks closures.
2014-11-12 09:15:35 +01:00
Richard Henderson
159d3788eb
x86: Convert to gas generated unwind info
2014-11-12 09:15:35 +01:00
Richard Henderson
e7b0056d60
x86: Force FFI_TYPE_LONGDOUBLE different from FFI_TYPE_DOUBLE
...
There are few abis that set double = long double. Eliminate the
conditional compilation and let this code simply be unused there.
2014-11-12 09:15:35 +01:00
Richard Henderson
4b2fad8fd5
x86: Remove some conditional compilation
...
Removal of ifdefs made possible to due to ffi_abi unification.
2014-11-12 09:15:35 +01:00
Richard Henderson
ef76205647
x86: Tidy ffi_abi
...
The x86_64 unix port only handles one ABI; don't define all of the
other symbols. The UNIX64 symbol retains the same value.
The i386 ports ought to have the same symbols, even if we can't yet
unify the values without incrementing the libffi soname.
2014-11-12 09:15:35 +01:00
Richard Henderson
610c90bf71
x86_64: Add support for complex types
2014-11-12 09:15:35 +01:00
Richard Henderson
32c5683163
x86_64: Decouple return types from FFI_TYPE constants
...
We can better support structure returns, and as prep for
complex types.
2014-11-12 09:15:35 +01:00
Richard Henderson
2e9dc16556
x86_64: Fixups for x32
2014-11-12 09:15:35 +01:00
Richard Henderson
ebd82769de
win64: Remove support from ffi.c
2014-11-12 09:15:35 +01:00
Richard Henderson
99db4d42ac
win64: Rewrite
...
It's way too different from the 32-bit ABIs with which it is
currently associated. As seen from all of the existing XFAILs.
2014-11-12 09:15:35 +01:00
Richard Henderson
6b62fb4a26
x86-64: Support go closures
...
Dumps all of the hand-coded unwind info for gas generated. Move jump
table data into .rodata. Adjust ffi_call_unix64 to load the static
chain. Split out sse portions of ffi_closure_unix64 to
ffi_closure_unix64_sse rather than test cif->flags at runtime.
2014-11-12 09:15:35 +01:00
Anthony Green
a0bdc5250c
Fix typo
2014-11-11 09:43:01 -05:00
Anthony Green
6695983d2f
Add complex type support. Mostly broken right now
2014-09-20 07:44:37 -04:00
Bernd Edlinger
bfcbf329c5
2014-05-11 Bernd Edlinger <bernd.edlinger@hotmail.de>
...
Fix current cygwin-64 build problems.
* src/java_raw_api.c: Remove if !defined(FFI_NO_RAW_API).
* src/x86/ffi.c: Add if defined(__CYGWIN__).
* src/x86/win64.S (ffi_closure_win64, ffi_call_win64): Added
handling for FFI_TYPE_UINT64, FFI_TYPE_POINTER and FFI_TYPE_INT.
Added SEH information. Fixed formatting.
2014-09-20 06:51:45 -04:00
Dominik Vogt
6e8a446083
2014-07-22 Dominik Vogt <vogt@linux.vnet.ibm.com>
...
* src/types.c (FFI_TYPEDEF, FFI_NONCONST_TYPEDEF): Merge the macros by
adding another argument that controls whether the result is const or not
(FFI_LDBL_CONST): Temporary macro to reduce ifdef confusion
* src/prep_cif.c (ffi_prep_cif_core): Replace list of systems with new
macro FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
* src/pa/ffitarget.h (FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION):
Define.
* src/s390/ffitarget.h (FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION):
Define.
* src/x86/ffitarget.h (FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION):
Define.
2014-07-22 Dominik Vogt <vogt@linux.vnet.ibm.com >
* doc/libffi.texi (Primitive Types): Document ffi_type_complex_float,
ffi_type_complex_double and ffi_type_complex_longdouble
(Complex Types): New subsection.
(Complex Type Example): Ditto.
* testsuite/libffi.call/cls_align_complex_double.c: New
FFI_TYPE_COMPLEX test.
* testsuite/libffi.call/cls_align_complex_float.c: Ditto.
* testsuite/libffi.call/cls_align_complex_longdouble.c: Ditto.
* testsuite/libffi.call/cls_complex_double.c: Ditto.
* testsuite/libffi.call/cls_complex_float.c: Ditto.
* testsuite/libffi.call/cls_complex_longdouble.c: Ditto.
* testsuite/libffi.call/cls_complex_struct_double.c: Ditto.
* testsuite/libffi.call/cls_complex_struct_float.c: Ditto.
* testsuite/libffi.call/cls_complex_struct_longdouble.c: Ditto.
* testsuite/libffi.call/cls_complex_va_double.c: Ditto.
* testsuite/libffi.call/cls_complex_va_float.c: Ditto.
* testsuite/libffi.call/cls_complex_va_longdouble.c: Ditto.
* testsuite/libffi.call/complex_double.c: Ditto.
* testsuite/libffi.call/complex_defs_double.c: Ditto.
* testsuite/libffi.call/complex_float.c: Ditto.
* testsuite/libffi.call/complex_defs_float.c: Ditto.
* testsuite/libffi.call/complex_longdouble.c: Ditto.
* testsuite/libffi.call/complex_defs_longdouble.c: Ditto.
* testsuite/libffi.call/complex_int.c: Ditto.
* testsuite/libffi.call/many_complex_double.c: Ditto.
* testsuite/libffi.call/many_complex_float.c: Ditto.
* testsuite/libffi.call/many_complex_longdouble.c: Ditto.
* testsuite/libffi.call/return_complex1_double.c: Ditto.
* testsuite/libffi.call/return_complex1_float.c: Ditto.
* testsuite/libffi.call/return_complex1_longdouble.c: Ditto.
* testsuite/libffi.call/return_complex2_double.c: Ditto.
* testsuite/libffi.call/return_complex2_float.c: Ditto.
* testsuite/libffi.call/return_complex2_longdouble.c: Ditto.
* testsuite/libffi.call/return_complex_double.c: Ditto.
* testsuite/libffi.call/return_complex_float.c: Ditto.
* testsuite/libffi.call/return_complex_longdouble.c: Ditto.
* src/raw_api.c (ffi_raw_to_ptrarray): Handle FFI_TYPE_COMPLEX
(ffi_ptrarray_to_raw): Ditto.
* src/prep_cif.c (ffi_prep_cif_core): Abort if FFI_TYPE_COMPLEX is not
implemented in libffi for the target.
* src/java_raw_api.c (ffi_java_raw_size): FFI_TYPE_COMPLEX not supported
yet (abort).
(ffi_java_raw_to_ptrarray): Ditto.
(ffi_java_rvalue_to_raw): Ditto.
(ffi_java_raw_to_rvalue): Ditto.
* src/debug.c (ffi_type_test): Add debug tests for complex types.
* include/ffi.h.in (FFI_TYPE_COMPLEX): Add new FFI_TYPE_COMPLEX.
(FFI_TYPE_LAST): Bump.
(ffi_type_complex_float): Add new ffi_type_....
(ffi_type_complex_double): Ditto.
(ffi_type_complex_longdouble): Ditto.
2014-07-22 Dominik Vogt <vogt@linux.vnet.ibm.com >
* src/s390/ffitarget.h (FFI_TARGET_HAS_COMPLEX_TYPE): Define to provide
FFI_TYPE_COMPLEX support.
* src/s390/ffi.c (ffi_check_struct_type): Implement FFI_TYPE_COMPLEX
(ffi_prep_args): Ditto.
(ffi_prep_cif_machdep): Ditto.
(ffi_closure_helper_SYSV): Ditto.
2014-09-20 06:24:41 -04:00
nielsAD
5d6340ef2c
Determine whether register arguments (THISCALL/FASTCALL/REGISTER) are really passed via register to closures. Use stack if not.
2014-08-25 17:42:07 +02:00
nielsAD
6e346487b8
Fixed THISCALL/FASTCALL closures and added basic support for PASCAL/REGISTER closures.
2014-08-25 12:23:29 +02:00
nielsAD
098dca6b31
Support for calling functions with PASCAL and REGISTER calling conventions on x86 Windows/Linux.
...
Also changed indentation to be more consistent throughout the (adjusted) files.
2014-08-24 14:29:38 +02:00
Samuli Suominen
978c954015
Add missing GNU stack markings in win32.S
2014-05-31 08:53:10 -04:00
Josh Triplett
99909eb618
src/x86/win32.S: Define ffi_closure_FASTCALL in the MASM section, too
2014-04-22 21:17:52 -07:00
Josh Triplett
d36952273d
Support fastcall closures
...
libffi on 32-bit x86 now supports closures for all supported ABIs.
Thus, rewrite the last remaining duplicated-by-ABI test (closure_stdcall
and closure_thiscall) to use the generic ABI_NUM/ABI_ATTR mechanism.
2014-04-20 17:08:37 -07:00
Ole André Vadla Ravnås
3e2b84d295
Fix Windows regression
...
Introduced by b5fed60194 .
2014-04-12 01:06:09 +02:00
Josh Triplett
b5fed60194
Fix ABI on 32-bit non-Windows x86: go back to trampoline size 10
...
The trampoline size is part of the ABI, so it cannot change. Move the
logic from the stdcall and thiscall trampolines to the functions they
call, to reduce them both to 10 bytes.
This drops the previously added support for raw THISCALL closures on
non-Windows. (Non-raw THISCALL closures still work.)
2014-04-05 17:33:42 -07:00
Anthony Green
afee53738a
Merge pull request #106 from joshtriplett/darwin-award
...
[3.1 blocker] Update OS X build system to include win32.S on 32-bit
2014-03-25 16:12:35 -04:00
Anthony Green
7d2478568e
Merge pull request #110 from joshtriplett/w64
...
Fix 64-bit Windows support
2014-03-25 16:12:17 -04:00
Josh Triplett
be50b87a49
Always use configure to detect whether global symbols need underscores
...
64-bit Windows already used this check; make it universal, and use it in
place of an ifdef on X86_WIN32, to handle non-Windows platforms that use
the underscore, such as Darwin.
2014-03-24 21:45:47 -07:00
Josh Triplett
56be47f876
Fix a warning on 64-bit Windows
...
When sizeof(size_t) != sizeof(unsigned), adding a size_t to cif->bytes
produces a "possible loss of data" warning. However, the size_t in
question refers to the size of a single parameter. Use a cast to avoid
the warning.
2014-03-24 21:24:53 -07:00
Josh Triplett
48a8eda74a
Avoid referencing undefined ABIs on 64-bit Windows builds
...
64-bit Windows does not have FFI_STDCALL, FFI_THISCALL, or FFI_FASTCALL.
2014-03-24 21:21:12 -07:00
Josh Triplett
f0f4138f90
win32.S: Add handling for position-independent code on Darwin
...
Newer versions of Darwin generate the necessary stub functions
automatically and just need a call instruction, but accomodating older
versions as well requires adding the stub.
2014-03-22 10:04:11 -07:00
Josh Triplett
ef5890ebaf
win32.S: Use shifting for multiplication rather than repeated addition
...
The jump table code added a register to itself twice to multiply by 4;
shift the register left by 2 instead.
2014-03-21 11:02:50 -07:00
Josh Triplett
4fca48901e
win32.S: Make the jump tables position-independent
...
Now that non-Windows platforms include win32.S, it needs to support
building as position-independent code. This fixes build failures on
target platforms that do not allow text relocations.
2014-03-21 11:00:41 -07:00
Josh Triplett
2087dcf736
win32.S: Make calls to ffi_closure_SYSV_inner position-independent
...
Now that non-Windows platforms include win32.S, it needs to support
building as position-independent code. This fixes one source of build
failures on target platforms that do not allow text relocations.
2014-03-21 10:57:06 -07:00
Josh Triplett
e1911f78df
Add support for stdcall, thiscall, and fastcall on non-Windows x86-32
...
Linux supports the stdcall calling convention, either via functions
explicitly declared with the stdcall attribute, or via code compiled
with -mrtd which effectively makes stdcall the default.
This introduces FFI_STDCALL, FFI_THISCALL, and FFI_FASTCALL on
non-Windows x86-32 platforms, as non-default calling conventions.
2014-03-16 05:05:06 -07:00
Anthony Green
edf29c5169
Merge pull request #75 from joshtriplett/longdouble
...
Fix build error on x86 without distinct long double
2014-02-28 00:50:25 -05:00
Josh Triplett
3998d2604b
Fix build error on x86 without distinct long double
...
src/x86/ffi64.c: In function 'classify_argument':
src/x86/ffi64.c:205:5: error: duplicate case value
case FFI_TYPE_LONGDOUBLE:
^
src/x86/ffi64.c:202:5: error: previously used here
case FFI_TYPE_DOUBLE:
^
2014-02-17 11:20:33 -08:00
Zachary Waldowski
9da28b4427
Darwin/x86_64: Fix 64-bit type shortening warnings
2014-02-05 14:28:58 -05:00
Zachary Waldowski
1367534158
Darwin/i386: Inhibit Clang previous prototype warnings
2014-02-05 14:28:53 -05:00
Anthony Green
3dc3f32c35
Undo iOS ARM64 changes.
2013-12-05 16:23:25 -05:00
Zachary Waldowski
33c46ce568
Darwin/Mac: Fix 64/32 shortening warnings
2013-11-30 04:14:10 -05:00
Zachary Waldowski
16ba1b8002
Darwin: Silence Clang warnings.
2013-11-30 03:47:58 -05:00
Mark Kettenis
becd754434
Align the stack pointer to 16-bytes.
2013-11-06 06:43:49 -05:00
Konstantin Belousov
05c3109340
Mark executable as not requiring executable stack.
2013-11-06 06:40:58 -05:00
Vitaly Budovski
6aa15900ac
Don't use 16 byte aligned stack for WIN32
...
This fixes a crash when accessing __stdcall functions in Python ctypes.
2013-09-05 12:05:06 +10:00
Jens Timmerman
b8a91d81be
added include for xmmintrin.h
2013-07-02 10:57:37 +02:00
Alex Gaynor
ee18766b16
Fix for a crasher due to misaligned stack on x86-32.
...
Full information on reproduction (using Python's ctypes available here: http://bugs.python.org/issue17423 )
2013-03-14 15:00:33 -07:00
Anthony Green
fd07c9e404
Add cache flushing routine for sun compiler on sparc solaris 2.8
2013-02-07 18:00:36 -05:00
Anthony Green
6a79012942
Work around LLVM ABI problem on x86-64
2013-02-06 17:37:15 -05:00
Anthony Green
8bf987d4df
Fix for sunpro compiler on Solaris
2013-01-10 17:24:51 -05:00