50 Commits
Author SHA1 Message Date
Josh Triplett 1f6b5a91f4 Support the WIN64/EFI64 calling convention on all X86_64 platforms
Add a new calling convention FFI_EFI64, alias FFI_WIN64, on all X86_64
platforms.  This allows libffi compiled on a 64-bit x86 platform to call
EFI functions.

Compile in ffiw64.c and win64.S on all X86_64 platforms.  When compiled
for a platform other than X86_WIN64, ffiw64.c suffixes its functions
with _efi64, to avoid conflict with the platform's actual
implementations of those functions.
2015-07-26 17:18:16 -07:00
Josh Triplett 6de51f3e04 src/x86/ffiw64.c: Don't assign a "char *" to an "unsigned char *"
Declare a local variable to match the type of the struct field assigned
to it, rather than adding unsigned to the type.  Fixes a -Wpointer-sign
warning.
2015-07-26 17:18:16 -07:00
Josh Triplett eaa59755fc src/x86/win64.S: Handle name mangling and PIC
Move the macros from unix64.S into a shared header asmnames.h and use
them in win64.S too.
2015-07-26 17:18:16 -07:00
Josh Triplett c8e82d9fbf src/x86/win64.S: Support compiling on non-WIN64 platforms
Non-WIN64 versions of the GNU assembler don't support the .seh_*
directives for structured exception handling, so wrap them in a macro
that compiles to nothing.

Handle the registers used for the non-Windows x86-64 calling convention
when on a non-Windows platform.  Distinguish between cases that should
refer to the native argument registers (defined as arg0, arg1, arg2, and
arg3) and cases that should always refer to the Windows argument
registers.
2015-07-26 16:18:57 -07: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
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
Josh Triplett 03ca880081 README: Note the testsuite changes to respect $CC and $CXX 2014-03-27 08:44:34 -07:00
Josh Triplett d74df8c5d8 README: Update Windows example to set both CC and CXX 2014-03-27 00:44:12 -07:00
Josh Triplett 7d698125b1 Use the proper C++ compiler to run C++ tests
Running the C compiler with -shared-libgcc -lstdc++ does not work on
non-GCC compilers.
2014-03-27 00:40:27 -07:00
Josh Triplett fa5e88f170 .travis.yml: Make the build command more readable by splitting at &&
"script" can contain multiple commands to run in sequence.
2014-03-27 00:38:53 -07:00
Josh Triplett 0c3824702d Always set CC_FOR_TARGET for dejagnu, to make the testsuite respect $CC
This fixes cross-compilation and compilation with CC="gcc -m32".
2014-03-26 23:31:02 -07:00
Josh Triplett 9946a92af3 Stop looking for expect and runtest above top_builddir
Users wishing to test hand-compiled versions of expect and runtest can
easily enough put them in their path or set EXPECT and RUNTEST
themselves.
2014-03-26 20:20:31 -07:00
Josh Triplett acb2023252 Stop setting an empty AM_RUNTESTFLAGS 2014-03-26 20:20:31 -07:00
Josh Triplett f0c8a31577 Compile win32.S on FreeBSD 2014-03-25 10:10:51 -07:00
Josh Triplett b2d610e028 Compile win32.S on 32-bit Darwin as well 2014-03-24 21:45:47 -07: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 e48918ecf8 testsuite: Add ABIs to the test matrix; unify tests across ABIs
This eliminates all the *_win32.c tests in favor of the tests they were
branched from, and expands test coverage to run many more tests on
stdcall, thiscall, and fastcall.

This same mechanism also supports testing any other target that has
multiple ABIs.
2014-03-16 20:39:12 -07:00
Josh Triplett 4d4d368e5a testsuite: Replace ffitestcxx.h with ffitest.h
ffitest.h contains a superset of the functionality of ffitestcxx.h;
make the C++ tests include ffitest.h instead, and remove ffitestcxx.h.
2014-03-16 20:39:06 -07:00
Josh Triplett 3f97cf3413 testsuite: Unify the C and C++ testsuites
These two testsuites differ only in the source file glob and a couple of
additional compiler options; unify the remaining bits.
2014-03-16 20:34:46 -07:00
Josh Triplett 0d9cce8edb testsuite: ffitest.h: Parenthesize the CHECK macro 2014-03-16 20:34:46 -07:00
Josh Triplett 5695ec1444 testsuite: Factor out a function to run a matrix of tests
This commons up code from libffi.call/call.exp and
libffi.special/special.exp, unifies the optimization option matrix
between the two, and makes it easier to add more axes to the matrix
in the future.
2014-03-16 20:34:46 -07:00
Josh Triplett dfdb02cc86 testsuite: Introduce a __THISCALL__ compiler-specific macro 2014-03-16 20:34:41 -07:00
Josh Triplett 06ff924215 .gitignore: Ignore more generated files
The build process generates doc/libffi.info and fficonfig.h.in, so add
them to .gitignore.
2014-03-16 16:19:46 -07:00
Josh Triplett bad8948346 testsuite: Introduce a __STDCALL__ compiler-specific macro
Several tests want to use stdcall, which differs in syntax by compiler,
so introduce a macro for it in ffitest.h.
2014-03-16 15:27:07 -07:00
Josh Triplett 98a793fa36 testsuite: Common up the ifdef blocks for compiler-specific macros 2014-03-16 15:21:57 -07:00
Josh Triplett a86bd318e2 Merge configure.host into configure.ac
configure.host only has a single entry, and shows no signs of needing
more added.
2014-03-16 07:05:28 -07:00
Josh Triplett eef2e02a13 doc: Remove autogenerated info file and stamp 2014-03-16 06:26:03 -07:00
Josh Triplett 9fb403d3c5 fficonfig.h.in: Remove, configure generates it 2014-03-16 06:25:52 -07:00
Josh Triplett 1c68c07217 Generate ChangeLog from git in make dist
Archive the existing ChangeLog to ChangeLog.libffi-3.1
2014-03-16 06:16:20 -07:00
Josh Triplett c65ed55e65 ChangeLog.v1: Fix typo in explanatory header. 2014-03-16 06:14:56 -07:00
Josh Triplett e892e581d1 README: Update news for 3.0.14 2014-03-16 05:39:23 -07:00
Josh Triplett 45a6c21efa .travis.yml: Test "make dist" too. 2014-03-16 05:29:08 -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
Josh Triplett 9531d05f64 prep_cif.c: Remove unnecessary ifdef for X86_WIN32
ffi_prep_cif_core had a special case for X86_WIN32, checking for
FFI_THISCALL in addition to the FFI_FIRST_ABI-to-FFI_LAST_ABI range
before returning FFI_BAD_ABI.  However, on X86_WIN32, FFI_THISCALL
already falls in that range, making the special case unnecessary.
Remove it.
2014-03-16 04:56:57 -07:00
Josh Triplett b3a5da068a .travis.yml: Test on both 32-bit and 64-bit 2014-03-16 04:53:41 -07:00
Josh Triplett f6dd184543 ChangeLog: Document testsuite changes to remove fragile stack pointer checks 2014-03-16 04:49:36 -07:00
Josh Triplett 9c279328ee testsuite: Remove fragile stack pointer checks
testsuite/libffi.call/closure_stdcall.c and
testsuite/libffi.call/closure_thiscall.c include inline assembly to save
the stack pointer before and after the call, and compare the values.
However, compilers can and do leave the stack in different states for
these two pieces of inline assembly, such as by saving a temporary value
on the stack across the call; observed with gcc -Os, and verified as
spurious through careful inspection of disassembly.
2014-03-16 04:45:37 -07:00
Josh Triplett 82f8cb24a1 ChangeLog: Document many.c and many_win32.c changes to avoid spurious failures 2014-03-16 04:40:45 -07:00
Josh Triplett 88d562a8b5 testsuite/libffi.call/many_win32.c: Avoid spurious failure due to excess precision
The test case testsuite/libffi.call/many_win32.c can spuriously fail due
to excess floating-point precision.  Instrumenting it with some printf
calls shows differences well above FLT_EPSILON.  (Note when
instrumenting it that multiple computations of the difference, such as
one in a print and another in the conditional, may produce different
results.)

Rather than complicating the test suite with architecture-specific flags
to avoid excess precision, just simplify the floating-point computation
to avoid a dependency on potential excess precision.
2014-03-16 04:39:37 -07:00
Josh Triplett c00a49ecd1 testsuite/libffi.call/many.c: Avoid spurious failure due to excess precision
The test case testsuite/libffi.call/many.c can spuriously fail due to
excess floating-point precision.  Instrumenting it with some printf
calls shows differences well above FLT_EPSILON.  (Note when
instrumenting it that multiple computations of the difference, such as
one in a print and another in the conditional, may produce different
results.)

Rather than complicating the test suite with architecture-specific flags
to avoid excess precision, just simplify the floating-point computation
to avoid a dependency on potential excess precision.
2014-03-16 04:39:37 -07:00
Josh Triplett 2f44952c95 Re-add libtool-ldflags 2014-03-16 04:35:12 -07:00
Josh Triplett 35634dbcea Remove autogenerated files from the repository
Add an autogen.sh to regenerate them.
2014-03-16 04:24:12 -07: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