A portable foreign-function interface library.

Related tags

Scripting libffi
Overview

Status

Build Status Build status

libffi-3.4 was released on TBD. Check the libffi web page for updates: URL:http://sourceware.org/libffi/.

What is libffi?

Compilers for high level languages generate code that follow certain conventions. These conventions are necessary, in part, for separate compilation to work. One such convention is the "calling convention". The "calling convention" is essentially a set of assumptions made by the compiler about where function arguments will be found on entry to a function. A "calling convention" also specifies where the return value for a function is found.

Some programs may not know at the time of compilation what arguments are to be passed to a function. For instance, an interpreter may be told at run-time about the number and types of arguments used to call a given function. Libffi can be used in such programs to provide a bridge from the interpreter program to compiled code.

The libffi library provides a portable, high level programming interface to various calling conventions. This allows a programmer to call any function specified by a call interface description at run time.

FFI stands for Foreign Function Interface. A foreign function interface is the popular name for the interface that allows code written in one language to call code written in another language. The libffi library really only provides the lowest, machine dependent layer of a fully featured foreign function interface. A layer must exist above libffi that handles type conversions for values passed between the two languages.

Supported Platforms

Libffi has been ported to many different platforms.

At the time of release, the following basic configurations have been tested:

Architecture Operating System Compiler
AArch64 (ARM64) iOS Clang
AArch64 Linux GCC
AArch64 Windows MSVC
Alpha Linux GCC
Alpha Tru64 GCC
ARC Linux GCC
ARM Linux GCC
ARM iOS GCC
ARM Windows MSVC
AVR32 Linux GCC
Blackfin uClinux GCC
CSKY Linux GCC
HPPA HPUX GCC
KVX Linux GCC
IA-64 Linux GCC
M68K FreeMiNT GCC
M68K Linux GCC
M68K RTEMS GCC
M88K OpenBSD/mvme88k GCC
Meta Linux GCC
MicroBlaze Linux GCC
MIPS IRIX GCC
MIPS Linux GCC
MIPS RTEMS GCC
MIPS64 Linux GCC
Moxie Bare metal GCC
Nios II Linux GCC
OpenRISC Linux GCC
PowerPC 32-bit AIX IBM XL C
PowerPC 64-bit AIX IBM XL C
PowerPC AMIGA GCC
PowerPC Linux GCC
PowerPC Mac OSX GCC
PowerPC FreeBSD GCC
PowerPC 64-bit FreeBSD GCC
PowerPC 64-bit Linux ELFv1 GCC
PowerPC 64-bit Linux ELFv2 GCC
RISC-V 32-bit Linux GCC
RISC-V 64-bit Linux GCC
S390 Linux GCC
S390X Linux GCC
SPARC Linux GCC
SPARC Solaris GCC
SPARC Solaris Oracle Solaris Studio C
SPARC64 Linux GCC
SPARC64 FreeBSD GCC
SPARC64 Solaris Oracle Solaris Studio C
TILE-Gx/TILEPro Linux GCC
VAX OpenBSD/vax GCC
X86 FreeBSD GCC
X86 GNU HURD GCC
X86 Interix GCC
X86 kFreeBSD GCC
X86 Linux GCC
X86 OpenBSD GCC
X86 OS/2 GCC
X86 Solaris GCC
X86 Solaris Oracle Solaris Studio C
X86 Windows/Cygwin GCC
X86 Windows/MingW GCC
X86-64 FreeBSD GCC
X86-64 Linux GCC
X86-64 Linux/x32 GCC
X86-64 OpenBSD GCC
X86-64 Solaris Oracle Solaris Studio C
X86-64 Windows/Cygwin GCC
X86-64 Windows/MingW GCC
X86-64 Mac OSX GCC
Xtensa Linux GCC

Please send additional platform test results to [email protected].

Installing libffi

First you must configure the distribution for your particular system. Go to the directory you wish to build libffi in and run the "configure" program found in the root directory of the libffi source distribution. Note that building libffi requires a C99 compatible compiler.

If you're building libffi directly from git hosted sources, configure won't exist yet; run ./autogen.sh first. This will require that you install autoconf, automake and libtool.

You may want to tell configure where to install the libffi library and header files. To do that, use the --prefix configure switch. Libffi will install under /usr/local by default.

If you want to enable extra run-time debugging checks use the the --enable-debug configure switch. This is useful when your program dies mysteriously while using libffi.

Another useful configure switch is --enable-purify-safety. Using this will add some extra code which will suppress certain warnings when you are using Purify with libffi. Only use this switch when using Purify, as it will slow down the library.

If you don't want to build documentation, use the --disable-docs configure switch.

It's also possible to build libffi on Windows platforms with Microsoft's Visual C++ compiler. In this case, use the msvcc.sh wrapper script during configuration like so:

path/to/configure CC=path/to/msvcc.sh CXX=path/to/msvcc.sh LD=link CPP="cl -nologo -EP" CPPFLAGS="-DFFI_BUILDING_DLL"

For 64-bit Windows builds, use CC="path/to/msvcc.sh -m64" and CXX="path/to/msvcc.sh -m64". You may also need to specify --build appropriately.

It is also possible to build libffi on Windows platforms with the LLVM project's clang-cl compiler, like below:

path/to/configure CC="path/to/msvcc.sh -clang-cl" CXX="path/to/msvcc.sh -clang-cl" LD=link CPP="clang-cl -EP" 

When building with MSVC under a MingW environment, you may need to remove the line in configure that sets 'fix_srcfile_path' to a 'cygpath' command. ('cygpath' is not present in MingW, and is not required when using MingW-style paths.)

To build static library for ARM64 with MSVC using visual studio solution, msvc_build folder have aarch64/Ffi_staticLib.sln required header files in aarch64/aarch64_include/

SPARC Solaris builds require the use of the GNU assembler and linker. Point AS and LD environment variables at those tool prior to configuration.

For iOS builds, the libffi.xcodeproj Xcode project is available.

Configure has many other options. Use configure --help to see them all.

Once configure has finished, type "make". Note that you must be using GNU make. You can ftp GNU make from ftp.gnu.org:/pub/gnu/make .

To ensure that libffi is working as advertised, type "make check". This will require that you have DejaGNU installed.

To install the library and header files, type make install.

History

See the git log for details at http://github.com/libffi/libffi.

3.4 TBD
	Add support for Alibaba's CSKY architecture.
    Add support for Intel Control-flow Enforcement Technology (CET).
Add support for ARM Pointer Authentication (PA).
Fix 32-bit PPC regression.
Fix MIPS soft-float problem.

3.3 Nov-23-19
    Add RISC-V support.
    New API in support of GO closures.
    Add IEEE754 binary128 long double support for 64-bit Power
    Default to Microsoft's 64 bit long double ABI with Visual C++.
    GNU compiler uses 80 bits (128 in memory) FFI_GNUW64 ABI.
    Add Windows on ARM64 (WOA) support.
    Add Windows 32-bit ARM support.
    Raw java (gcj) API deprecated.
    Add pre-built PDF documentation to source distribution.
    Many new test cases and bug fixes.
    
3.2.1 Nov-12-14
    Build fix for non-iOS AArch64 targets.

3.2 Nov-11-14
    Add C99 Complex Type support (currently only supported on
      s390).
    Add support for PASCAL and REGISTER calling conventions on x86
      Windows/Linux.
    Add OpenRISC and Cygwin-64 support.
    Bug fixes.

3.1 May-19-14
    Add AArch64 (ARM64) iOS support.
    Add Nios II support.
    Add m88k and DEC VAX support.
    Add support for stdcall, thiscall, and fastcall on non-Windows
      32-bit x86 targets such as Linux.
    Various Android, MIPS N32, x86, FreeBSD and UltraSPARC IIi
      fixes.
    Make the testsuite more robust: eliminate several spurious
      failures, and respect the $CC and $CXX environment variables.
    Archive off the manually maintained ChangeLog in favor of git
      log.

3.0.13 Mar-17-13
    Add Meta support.
    Add missing Moxie bits.
    Fix stack alignment bug on 32-bit x86.
    Build fix for m68000 targets.
    Build fix for soft-float Power targets.
    Fix the install dir location for some platforms when building
      with GCC (OS X, Solaris).
    Fix Cygwin regression.

3.0.12 Feb-11-13
    Add Moxie support.
    Add AArch64 support.
    Add Blackfin support.
    Add TILE-Gx/TILEPro support.
    Add MicroBlaze support.
    Add Xtensa support.
    Add support for PaX enabled kernels with MPROTECT.
    Add support for native vendor compilers on
      Solaris and AIX.
    Work around LLVM/GCC interoperability issue on x86_64.

3.0.11 Apr-11-12
    Lots of build fixes.
    Add support for variadic functions (ffi_prep_cif_var).
    Add Linux/x32 support.
    Add thiscall, fastcall and MSVC cdecl support on Windows.
    Add Amiga and newer MacOS support.
    Add m68k FreeMiNT support.
    Integration with iOS' xcode build tools.
    Fix Octeon and MC68881 support.
    Fix code pessimizations.

3.0.10 Aug-23-11
    Add support for Apple's iOS.
    Add support for ARM VFP ABI.
    Add RTEMS support for MIPS and M68K.
    Fix instruction cache clearing problems on
      ARM and SPARC.
    Fix the N64 build on mips-sgi-irix6.5.
    Enable builds with Microsoft's compiler.
    Enable x86 builds with Oracle's Solaris compiler.
    Fix support for calling code compiled with Oracle's Sparc
      Solaris compiler.
    Testsuite fixes for Tru64 Unix.
    Additional platform support.

3.0.9 Dec-31-09
    Add AVR32 and win64 ports.  Add ARM softfp support.
    Many fixes for AIX, Solaris, HP-UX, *BSD.
    Several PowerPC and x86-64 bug fixes.
    Build DLL for windows.

3.0.8 Dec-19-08
    Add *BSD, BeOS, and PA-Linux support.

3.0.7 Nov-11-08
    Fix for ppc FreeBSD.
    (thanks to Andreas Tobler)

3.0.6 Jul-17-08
    Fix for closures on sh.
    Mark the sh/sh64 stack as non-executable.
    (both thanks to Kaz Kojima)

3.0.5 Apr-3-08
    Fix libffi.pc file.
    Fix #define ARM for IcedTea users.
    Fix x86 closure bug.

3.0.4 Feb-24-08
    Fix x86 OpenBSD configury.

3.0.3 Feb-22-08
    Enable x86 OpenBSD thanks to Thomas Heller, and
      x86-64 FreeBSD thanks to Björn König and Andreas Tobler.
    Clean up test instruction in README.

3.0.2 Feb-21-08
    Improved x86 FreeBSD support.
    Thanks to Björn König.

3.0.1 Feb-15-08
    Fix instruction cache flushing bug on MIPS.
    Thanks to David Daney.

3.0.0 Feb-15-08
    Many changes, mostly thanks to the GCC project.
    Cygnus Solutions is now Red Hat.

  [10 years go by...]

1.20 Oct-5-98
    Raffaele Sena produces ARM port.

1.19 Oct-5-98
    Fixed x86 long double and long long return support.
    m68k bug fixes from Andreas Schwab.
    Patch for DU assembler compatibility for the Alpha from Richard
      Henderson.

1.18 Apr-17-98
    Bug fixes and MIPS configuration changes.

1.17 Feb-24-98
    Bug fixes and m68k port from Andreas Schwab. PowerPC port from
    Geoffrey Keating. Various bug x86, Sparc and MIPS bug fixes.

1.16 Feb-11-98
    Richard Henderson produces Alpha port.

1.15 Dec-4-97
    Fixed an n32 ABI bug. New libtool, auto* support.

1.14 May-13-97
    libtool is now used to generate shared and static libraries.
    Fixed a minor portability problem reported by Russ McManus
    <[email protected]>.

1.13 Dec-2-96
    Added --enable-purify-safety to keep Purify from complaining
      about certain low level code.
    Sparc fix for calling functions with < 6 args.
    Linux x86 a.out fix.

1.12 Nov-22-96
    Added missing ffi_type_void, needed for supporting void return 
      types. Fixed test case for non MIPS machines. Cygnus Support 
      is now Cygnus Solutions. 

1.11 Oct-30-96
    Added notes about GNU make.

1.10 Oct-29-96
    Added configuration fix for non GNU compilers.

1.09 Oct-29-96
    Added --enable-debug configure switch. Clean-ups based on LCLint 
    feedback. ffi_mips.h is always installed. Many configuration 
    fixes. Fixed ffitest.c for sparc builds.

1.08 Oct-15-96
    Fixed n32 problem. Many clean-ups.

1.07 Oct-14-96
    Gordon Irlam rewrites v8.S again. Bug fixes.

1.06 Oct-14-96
    Gordon Irlam improved the sparc port. 

1.05 Oct-14-96
    Interface changes based on feedback.

1.04 Oct-11-96
    Sparc port complete (modulo struct passing bug).

1.03 Oct-10-96
    Passing struct args, and returning struct values works for
    all architectures/calling conventions. Expanded tests.

1.02 Oct-9-96
    Added SGI n32 support. Fixed bugs in both o32 and Linux support.
    Added "make test".

1.01 Oct-8-96
    Fixed float passing bug in mips version. Restructured some
    of the code. Builds cleanly with SGI tools.

1.00 Oct-7-96
    First release. No public announcement.

Authors & Credits

libffi was originally written by Anthony Green [email protected].

The developers of the GNU Compiler Collection project have made innumerable valuable contributions. See the ChangeLog file for details.

Some of the ideas behind libffi were inspired by Gianni Mariani's free gencall library for Silicon Graphics machines.

The closure mechanism was designed and implemented by Kresten Krab Thorup.

Major processor architecture ports were contributed by the following developers:

aarch64             Marcus Shawcroft, James Greenhalgh
alpha               Richard Henderson
arc                 Hackers at Synopsis
arm                 Raffaele Sena
avr32               Bradley Smith
blackfin            Alexandre Keunecke I. de Mendonca
cris                Simon Posnjak, Hans-Peter Nilsson
csky		Ma Jun, Zhang Wenmeng
frv                 Anthony Green
ia64                Hans Boehm
m32r                Kazuhiro Inaoka
m68k                Andreas Schwab
m88k                Miod Vallat
metag               Hackers at Imagination Technologies
microblaze          Nathan Rossi
mips                Anthony Green, Casey Marshall
mips64              David Daney
moxie               Anthony Green
nios ii             Sandra Loosemore
openrisc            Sebastian Macke
pa                  Randolph Chung, Dave Anglin, Andreas Tobler
powerpc             Geoffrey Keating, Andreas Tobler,
                    David Edelsohn, John Hornkvist
powerpc64           Jakub Jelinek
riscv               Michael Knyszek, Andrew Waterman, Stef O'Rear
s390                Gerhard Tonn, Ulrich Weigand
sh                  Kaz Kojima
sh64                Kaz Kojima
sparc               Anthony Green, Gordon Irlam
tile-gx/tilepro     Walter Lee
vax                 Miod Vallat
x86                 Anthony Green, Jon Beniston
x86-64              Bo Thorsen
xtensa              Chris Zankel

Jesper Skov and Andrew Haley both did more than their fair share of stepping through the code and tracking down bugs.

Thanks also to Tom Tromey for bug fixes, documentation and configuration help.

Thanks to Jim Blandy, who provided some useful feedback on the libffi interface.

Andreas Tobler has done a tremendous amount of work on the testsuite.

Alex Oliva solved the executable page problem for SElinux.

The list above is almost certainly incomplete and inaccurate. I'm happy to make corrections or additions upon request.

If you have a problem, or have found a bug, please send a note to the author at [email protected], or the project mailing list at [email protected].

Issues
  • Support loongarch64

    Support loongarch64

    opened by zhangwenlong8911 23
  • New Release Version?

    New Release Version?

    Given that the latest libffi release can't be compiled with llvm for armv7 due to the unified assembly syntax, it would be interesting to know what the remaining open tasks are to get a 4.0 release out the door. Especially for projects that depend on libffi, but do not want to use some unofficial release this would be nice.

    opened by angerman 21
  • x86: fix double/long double handling on Win64

    x86: fix double/long double handling on Win64

    On Windows 64-bit double == long double. Ensure that we guard the long double case properly and explicitly list float and double types in the switch. Fixes FFI of long double types.

    opened by compnerd 20
  • New RISC-V port

    New RISC-V port

    This patch adds support for RISC-V. I sent it to the ML earlier but was requested to create a PR instead.

    I did not write the code in this patch; it is a cleaned up and rebased version of a port by Michael Knyszek et al of UC Berkeley.

    RISC-V is a free and open standard instruction set architecture originally developed at UC Berkeley and now seeing significant interest from independent hardware vendors, with interoperable prototypes from several independent groups. Alex Bradbury's recent RFC to the LLVM community has a much better explanation of what RISC-V is and why you should care about it.

    While the privileged architecture is still in some flux, the architecture which is visible to user space and the C calling convention have been unchanged in nearly two years and are now considered frozen, so ports like this one are very likely to remain valid.

    I am interested in being the responsible party to get this code into a mergable condition. I am familiar with the RISC-V ISA and calling convention and with libffi's broad principles of operation, but not with the details of libffi internals.

    How shall we proceed?


    RISC-V instruction set reference, including C calling convention and encoding details


    I've run the full testsuite on qemu system and user emulation. The user emulation is the easiest way to follow along, although it's still a bit touchy. Follow the instructions on https://hub.docker.com/r/sorear/fedora-riscv-wip/ to set up an emulated RISC-V user environment (assuming you have an amd64 Linux host).

    Next, build the latest qemu-user from https://github.com/arsv/riscv-qemu for an important bugfix. Build it with --enable-static --target-list=riscv64-linux-user, and copy the generated static binary riscv64-linux-user/qemu-riscv64 into the container root.

    Next, install the following packages in the container:

    autoconf-2.69-22.fc24.noarch
    automake-1.15-7.fc25.noarch
    dejagnu-1.6-1.fc25.noarch
    expect-5.45-22.fc24.riscv64
    tcl-8.6.6-1.fc24.riscv64
    libtool-ltdl-2.4.6-11.fc24.riscv64
    libtool-ltdl-devel-2.4.6-11.fc24.riscv64
    tcl-devel-8.6.6-1.fc24.riscv64
    expect-devel-5.45-22.fc24.riscv64
    expectk-5.45-22.fc24.riscv64
    libtool-2.4.6-11.fc24.riscv64
    bash-4.3.43-1.fc24.riscv64
    bash-doc-4.3.43-1.fc24.riscv64
    make-devel-4.1-5.fc24.riscv64
    make-4.1-5.fc24.riscv64
    texinfo-6.1-3.fc24.riscv64
    perl-5.24.0-377.fc25.riscv64
    perl-libintl-1.24-3.fc24.riscv64
    perl-core-5.24.0-377.fc25.riscv64
    perl-libs-5.24.0-377.fc25.riscv64
    perl-Encode-2.86-1.fc25.riscv64
    perl-Storable-2.56-366.fc25.riscv64
    perl-Unicode-Normalize-1.25-365.fc25.riscv64
    perl-Unicode-EastAsianWidth-1.33-8.fc25.noarch
    perl-Text-Unidecode-1.27-3.fc25.noarch
    perl-IO-1.36-377.fc25.riscv64
    

    Source noarch packages from koji, riscv64 packages from https://github.com/rwmjones/fedora-riscv.

    Once the environment is set up, it is possible to check out the code, (you may need to hack config.guess to return the correct result), sh autogen.sh, ./configure --host=riscv64-unknown-linux-gnu --build=riscv64-unknown-linux-gnu, make check.

    config.sub has supported RISC-V for cross compilation purposes for some time, and is already updated in libffi; config.guess does not.

    opened by sorear 15
  • fix ios builds

    fix ios builds

    This patch updates generate-darwin-source-and-headers.py and the libffi.xcodeproj to include all currently relevant source files.

    #include <mach/vm_param.h> was changed to #include <mach/machine/vm_param.h> as the former is failing with an undefined mnemonic, not sure why though.

    Some Xcode compiler configuration is updated as well.

    The Xcode buid rule is adapted, so that autoconf is called as well and a sourceregeneration is only done when necessary.

    opened by ksjogo 15
  • libffi doesn't build in Xcode 5.1

    libffi doesn't build in Xcode 5.1

    I am getting the following error in ffi_common.h: Unknown type name ffi_status Unknown type name ffi_cif

    These types are clearly being defined in the main ffi_arm.h and ffi_i386.h

    opened by ghost 15
  • Error: unknown pseudo-op: `.private_extern' in src/arm/sysv.S

    Error: unknown pseudo-op: `.private_extern' in src/arm/sysv.S

    System Details

    OS Fedora 27

    armv7l-unknown-linux-gnueabihf

    binutils-2.29-13.fc27.armv7hl gcc-7.3.1-5.fc27.armv7hl

    Problems Description

    After commit 1d704051b2 build fails with

    libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -I. -I../include -Iinclude -I../src -I. -I../include -Iinclude -I../src -MT src/arm/sysv.lo -MD -MP -MF src/arm/.deps/sysv.Tpo -c ../src/arm/sysv.S  -fPIC -DPIC -o src/arm/.libs/sysv.o
    ../src/arm/sysv.S: Assembler messages:
    ../src/arm/sysv.S:126: Error: unknown pseudo-op: `.private_extern'
    ../src/arm/sysv.S:142: Error: unknown pseudo-op: `.private_extern'
    ../src/arm/sysv.S:216: Error: unknown pseudo-op: `.private_extern'
    ../src/arm/sysv.S:227: Error: unknown pseudo-op: `.private_extern'
    ../src/arm/sysv.S:263: Error: unknown pseudo-op: `.private_extern'
    ../src/arm/sysv.S:274: Error: unknown pseudo-op: `.private_extern'
    ../src/arm/sysv.S:374: Error: unknown pseudo-op: `.private_extern'
    make[3]: *** [Makefile:1190: src/arm/sysv.lo] Error 1
    

    Are newer binutils required?

    opened by sharkcz 14
  • iOS Xcode support

    iOS Xcode support

    Added Xcode project that builds libffi like a normal iOS library

    This allows a user to add libffi as a subproject and should make integrating (and building) it much easier

    generate-ios-source-and-headers.py creates a shadow copy of the source tree and ifdefs files based on their architecture so your an compile everything for both targets and easily make a universal binary

    opened by mikelikespie 12
  • Build with MSVC

    Build with MSVC

    Last version I can build with MSVC is 3.1 but to do this I also have to add CXXCPP variable to configure like.

    configure CC=msvcc.sh CXX=msvcc.sh LD=link CPP="cl -nologo -EP" CXXCPP="cl -nologo -EP"
    

    When I try install 3.2 I get errors.

    1. About complex type
    cl -MD -nologo -W3 -DHAVE_CONFIG_H -I. -I.. -I. -I../include -Iinclude -I../src -O2 -c -showIncludes ../src/types.c -DDLL_EXPORT -DPIC -Fosrc/.libs/types.obj -Fdsrc/.libs/types -Fpsrc/.libs/types -Fasrc/.libs/types -link -OPT:REF -OPT:ICF -INCREMENTAL:NO types.c
    ../src/types.c(101) : error C2061: syntax error : identifier '_Complex'
    ../src/types.c(101) : error C2059: syntax error : '}'
    ../src/types.c(101) : error C2065: '_Complex' : undeclared identifier
    ../src/types.c(101) : error C2143: syntax error : missing ')' before 'type'
    ../src/types.c(101) : error C2059: syntax error : ')'
    ../src/types.c(102) : error C2061: syntax error : identifier '_Complex'
    ../src/types.c(102) : error C2059: syntax error : '}'
    ../src/types.c(102) : error C2065: '_Complex' : undeclared identifier
    ../src/types.c(102) : error C2143: syntax error : missing ')' before 'type'
    ../src/types.c(102) : error C2059: syntax error : ')'
    

    So I comment defenition of FFI_TARGET_HAS_COMPLEX_TYPE in ffitarget.h

    1. After that I got errors about type defenition if ffi.c file
    cl -MD -nologo -W3 -DHAVE_CONFIG_H -I. -I.. -I. -I../include -Iinclude -I../src -O2 -c -showIncludes ../src/x86/ffi.c -DDLL_EXPORT -DPIC -Fosrc/x86/.libs/ffi.obj -Fdsrc/x86/.libs/ffi -Fpsrc/x86/.libs/ffi -Fasrc/x86/.libs/ffi -link -OPT:REF -OPT:ICF -INCREMENTAL:NO ffi.c
    ../src/x86/ffi.c(106) : error C2275: 'size_t' : illegal use of this type as an expression
            c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(29) : see declaration of 'size_t'
    ../src/x86/ffi.c(106) : error C2146: syntax error : missing ';' before identifier 'z'
    ../src/x86/ffi.c(106) : error C2065: 'z' : undeclared identifier
    ../src/x86/ffi.c(126) : error C2065: 'z' : undeclared identifier
    ../src/x86/ffi.c(128) : error C2065: 'z' : undeclared identifier
    ../src/x86/ffi.c(165) : error C2065: 'z' : undeclared identifier
    ../src/x86/ffi.c(172) : error C2065: 'z' : undeclared identifier
    ../src/x86/ffi.c(196) : error C2065: 'z' : undeclared identifier
    ../src/x86/ffi.c(213) : error C2143: syntax error : missing ';' before 'type'
    ../src/x86/ffi.c(576) : error C2143: syntax error : missing ';' before 'type'
    ../src/x86/ffi.c(577) : error C2065: 'sz' : undeclared identifier
    ../src/x86/ffi.c(577) : error C2065: 'sz' : undeclared identifier
    ../src/x86/ffi.c(606) : error C2275: 'size_t' : illegal use of this type as an expression
            c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(29) : see declaration of 'size_t'
    ../src/x86/ffi.c(606) : error C2146: syntax error : missing ';' before identifier 'z'
    ../src/x86/ffi.c(606) : error C2065: 'z' : undeclared identifier
    ../src/x86/ffi.c(623) : error C2065: 'z' : undeclared identifier
    ../src/x86/ffi.c(641) : error C2065: 'z' : undeclared identifier
    ../src/x86/ffi.c(862) : error C2143: syntax error : missing ';' before 'type'
    ../src/x86/ffi.c(863) : error C2065: 'sz' : undeclared identifier
    ../src/x86/ffi.c(863) : error C2065: 'sz' : undeclared identifier
    

    This just need move all variable declarations to begining of blocks

    1. Also dynamic library (libffi-6.dll) does not export any function
    opened by moteus 11
  • Support closures on ARM64 iOS

    Support closures on ARM64 iOS

    This patch copies the arm implementation of the iOS-friendly trampoline table closures to aarch64. While functional, there are two things I don't like about it:

    1. There is a lot of copy/pasta in ffi.c based on arm/ffi.c. Ideally I'd like to refactor it and keep the code in a shared location for the two targets but I'm unsure as to what's a good home for it. Perhaps closures.c?
    2. The actual trampoline table page code in sysv.S is the product of a single evening spent with the ARM instruction set reference manual - I don't like how bloated it is compared to the arm trampoline but I don't know if it can be implemented in a better way. I'd like to ask someone more proficient in aarch64 for a shove in the right direction.

    I want to make this patch better and then upstream it, but I need some help on the above issues.

    opened by fealebenpae 11
  • configure.ac: add --disable-exec-static-tramp flag

    configure.ac: add --disable-exec-static-tramp flag

    Some projects like GHC (Glasgow Haskell Compiler) and gobject-introspection use ffi_closure_alloc() as a way to allocate executable memory. exec static tramp interferes with it (unclear how exactly yet).

    GHC symptom: ffi closure freeing cimplains about unexpected trampoline (GHC manually fills one):

    $ ghci
    GHCi, version 8.10.5: https://www.haskell.org/ghc/  :? for help
    ghc: freeHaskellFunctionPtr: not for me, guv! 0x7f0417a1efe8
    ghc: freeHaskellFunctionPtr: not for me, guv! 0x7f0417a1efc8
    

    gobject-introspection symptom:

    $ meld
    Segmentation fault (core dumped)
    
    $ gdb --args /usr/bin/python3.9 /usr/bin/meld
    (gdb) run
    ...
    Thread 1 "python3.9" received signal SIGSEGV, Segmentation fault.
    0x00007fffe9ac1ae8 in g_callable_info_free_closure (
      callable_info=0x555555d45990, closure=0x7fffe9e70c20)
        at ../gobject-introspection-1.68.0/girepository/girffi.c:428
    428       g_free (wrapper->ffi_closure.cif->arg_types);
    (gdb) bt
      callable_info=0x555555d45990, closure=0x7fffe9e70c20)
        at ../gobject-introspection-1.68.0/girepository/girffi.c:428
      data=0x555555d252d0)
        at ../pygobject-3.40.1/gi/pygi-closure.c:635
    ...
    

    To ease downstreams narrowing down the actual problem let's provide a knob to disable exec static trampolines.

    The change for not affect current default.

    opened by trofi 10
  • Move FFI_TYPE definitions above <ffitarget.h> include

    Move FFI_TYPE definitions above include

    For powerpc at least, these definitions are referenced in the target-specific ffitarget.h. Discovered in the jffi project. Should close https://github.com/libffi/libffi/issues/637. Downstream jffi bug https://github.com/jnr/jffi/issues/107. Downstream distro bug https://bugs.gentoo.org/827215.

    Testing - both libffi and jffi test suites pass with this patch applied, at least on ppc64le linux. I did not see any warnings about redefinitions.

    Tested versions - libffi 3.4.2, jffi 1.3.6 and 1.3.9.

    opened by matoro 0
  • BUILD FAILS WSL2 using cross compilers from ffmpeg-windows-build-helpers

    BUILD FAILS WSL2 using cross compilers from ffmpeg-windows-build-helpers

    System Details

    x86_64-pc-linux-gnu - WSL2 the toolchain is a cross compiler used to compile ffmpeg and the toolchain (or helper script rather) is located at - ffmpeg-windows-build-helpers

    I was able to cross compile the win32 version great it looks like. but when it enters the win64/libffi_git directory it fails with this output:

    configuring libffi-3.4.2 (/mnt/c/users/james/documents/projects/discord/bot/ffmpeg-windows-build-helpers/sandbox/win32/libffi-3.4.2) as $ PKG_CONFIG_PATH=/mnt/c/users/james/documents/projects/discord/bot/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-i686/i686-w64-mingw32/lib/pkgconfig PATH=/mnt/c/users/james/documents/projects/discord/bot/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-i686/bin:$PATH ./configure --host=i686-w64-mingw32 --prefix=/mnt/c/users/james/documents/projects/discord/bot/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-i686/i686-w64-mingw32 --disable-shared --enable-static
    all touch files already_configured* touchname= already_configured_6a81debdb9b023e0487357066e70f9a7-
    config options --host=i686-w64-mingw32 --prefix=/mnt/c/users/james/documents/projects/discord/bot/ffmpeg-windows-build-helpers/sandbox/cross_compilers/mingw-w64-i686/i686-w64-mingw32 --disable-shared --enable-static ./configure
    checking build system type... x86_64-pc-linux-gnu
    checking host system type... i686-w64-mingw32
    checking target system type... i686-w64-mingw32
    continue configure in default builddir "./i686-w64-mingw32"
    ....exec /bin/bash .././configure "--srcdir=.." "--enable-builddir=i686-w64-mingw32" "mingw32"
    .././configure: line 2315: config.log: No such file or directory
    .././configure: line 2325: config.log: No such file or directory
    cat: standard output: No such file or directory
    failed configure libffi-3.4.2
    

    i dont think it is a configure problem because i cross compiled (so far) a plethora of other libs, but here is the config.log: config.log

    if i need to provide any additional information please just let me know. my build is dead in its tracks at the moment so please let me know what i can do to continue. ive already changed the configure script to test -f $srcdir/config.log && cp $srcdir/config.log . as well and still get this error so i do not think it is a terminal behavioral issue like mentioned in other issues related to this problem in the repo. could i simply comment that line out? nany way to just curcumvent it and compile it with my cross compiling tool chain?

    also, for anyone reading, is my toolchain using a 32 bit compiler to comipile 64 bit versions of this? or am i totally just confused? im barely intermediate when it comes to compiling which is why i use this ffmpeg-windows-build-helpers script. but either way, thanks in advance!

    opened by james28909 6
  • Tests fail on riscv64-linux (visionfive hardware)

    Tests fail on riscv64-linux (visionfive hardware)

    System Details

    NixOS on RISC-V 64 bit, StarFive VisionFive

    GCC 11.3.0

    Problems Description

    Tests fail on hardware.

    https://gist.github.com/Madouura/949d61a944a1857898abb68807e0f1b3

    opened by Madouura 1
  • Improve README.md + remove dead statement from test

    Improve README.md + remove dead statement from test

    • Change README.md to ensure that someone searching test will discover the relevant part of the readme.

    • README.md now indicates where test output is written. Relevant issue.

    • Remove dead statement from test negint.c

    opened by MaxBarraclough 0
  • Add optional FFI_MAX_CLOSURE_ARGS to specification?

    Add optional FFI_MAX_CLOSURE_ARGS to specification?

    It would be helpful if libffi add an extra optional constant FFI_MAX_CLOSURE_ARGS to the specification. Implementations that are limited in the number of arguments they can use in closures could use this. For instance, on my libffi Emscripten port I can define in ffitarget.h

    #define FFI_MAX_CLOSURE_ARGS 122
    

    This could then be consumed by ctypes: they currently have:

    #define CTYPES_MAX_ARGCOUNT 1024
    

    https://github.com/python/cpython/blob/main/Modules/_ctypes/ctypes.h but it would be nice to replace this with:

    #ifdef FFI_MAX_CLOSURE_ARGS
    #define CTYPES_MAX_ARGCOUNT FFI_MAX_CLOSURE_ARGS
    #else
    #define CTYPES_MAX_ARGCOUNT 1024
    #endif
    

    and then we could fix Python's ctypes test test_callback_too_many_args in Emscripten, which tries to call a function with CTYPES_MAX_ARGCOUNT aguments.

    opened by hoodmane 0
Releases(v3.4.2)
  • v3.4.2(Jun 29, 2021)

    3.4.2 Jun-28-21
        Add static trampoline support for Linux on x86_64 and ARM64.
        Add support for Alibaba's CSKY architecture.
        Add support for Kalray's KVX architecture.
        Add support for Intel Control-flow Enforcement Technology (CET).
        Add support for ARM Pointer Authentication (PA).
        Fix 32-bit PPC regression.
        Fix MIPS soft-float problem.
        Enable tmpdir override with the $LIBFFI_TMPDIR environment variable.
        Enable compatibility with MSVC runtime stack checking.
        Reject float and small integer argument in ffi_prep_cif_var().
          Callers must promote these types themselves.
    
    Source code(tar.gz)
    Source code(zip)
    libffi-3.4.2.tar.gz(1.28 MB)
  • v3.4.0-rc2(Jun 28, 2021)

  • v3.4-rc1(Jun 26, 2021)

  • v3.3(Nov 23, 2019)

    3.3 Nov-23-19
        Add RISC-V support.
        New API in support of GO closures.
        Add IEEE754 binary128 long double support for 64-bit Power
        Default to Microsoft's 64-bit long double ABI with Visual C++.
        GNU compiler uses 80 bits (128 in memory) FFI_GNUW64 ABI.
        Add Windows on ARM64 (WOA) support.
        Add Windows 32-bit ARM support.
        Raw java (gcj) API deprecated.
        Add pre-built PDF documentation to source distribution.
        Many new test cases and bug fixes.
    
    Source code(tar.gz)
    Source code(zip)
    libffi-3.3.tar.gz(1.24 MB)
  • v3.3-rc2(Nov 2, 2019)

    This is a TEST RELEASE of the coming libffi 3.3 release.

    Please test this release. Problems should be reported at https://github.com/libffi/libffi/issues .

    Test results for posting at https://github.com/libffi/libffi/wiki can also be filed as issues on the issue tracker.

    Thanks!

    Source code(tar.gz)
    Source code(zip)
    libffi-3.3-rc2.tar.gz(1.07 MB)
  • v3.3-rc1(Oct 24, 2019)

    This is a TEST RELEASE of the coming libffi 3.3 release.

    Please test this release. Problems should be reported at https://github.com/libffi/libffi/issues .

    Test results for posting at https://github.com/libffi/libffi/wiki can also be filed as issues on the issue tracker.

    Thanks!

    Source code(tar.gz)
    Source code(zip)
    libffi-3.3-rc1.tar.gz(1.07 MB)
  • v3.3-rc0(Apr 2, 2018)

    This is a TEST RELEASE of the coming libffi 3.3 release.

    Please test this release. Problems should be reported at https://github.com/libffi/libffi/issues .

    Test results for posting at https://github.com/libffi/libffi/wiki can also be filed as issues on the issue tracker.

    Thanks!

    Source code(tar.gz)
    Source code(zip)
    libffi-3.3-rc0.tar.gz(1.03 MB)
A tool for generating cross-language type declarations and interface bindings.

Djinni Djinni is a tool for generating cross-language type declarations and interface bindings. It's designed to connect C++ with either Java or Objec

Dropbox 2.8k Jun 21, 2022
Erlang interface to eBPF

ebpf Erlang eBPF library Overview ebpf facilitates basic interaction with the Linux eBPF system from Erlang.

null 47 Jun 2, 2022
A lightweight, dependency-free library for binding Lua to C++

LuaBridge 2.6 LuaBridge is a lightweight and dependency-free library for mapping data, functions, and classes back and forth between C++ and Lua (a po

Vinnie Falco 1.3k Jun 21, 2022
:sparkles: Magical headers that make your C++ library accessible from JavaScript :rocket:

Quick start | Requirements | Features | User guide | Contributing | License nbind is a set of headers that make your C++11 library accessible from Jav

charto 1.9k Jun 20, 2022
Library to build PHP extensions with C++

PHP-CPP The PHP-CPP library is a C++ library for developing PHP extensions. It offers a collection of well documented and easy-to-use classes that can

Copernica 1.3k Jun 18, 2022
Structy is an irresponsibly dumb and simple struct serialization/deserialization library for C, Python, and vanilla JavaScript.

Structy Structy is an irresponsibly dumb and simple struct serialization/deserialization library for C, Python, and vanilla JavaScript. You can think

Stargirl Flowers 47 Jun 19, 2022
A foreign function interface for bash.

ctypes.sh This is ctypes.sh, a foreign function interface for bash. ctypes.sh is a bash plugin that provides a foreign function interface directly in

Tavis Ormandy 1.7k Jun 19, 2022
The DSiLanguagePatcher increases accessibility to foreign region DSi consoles by providing a mean to change the user interface language.

DSi Language Patcher The DSi Language patcher is a small tool, which runs on your DSi (homebrew execution required) and create a copy of your original

null 19 May 13, 2022
LibreSSL Portable itself. This includes the build scaffold and compatibility layer that builds portable LibreSSL from the OpenBSD source code.

LibreSSL Portable itself. This includes the build scaffold and compatibility layer that builds portable LibreSSL from the OpenBSD source code.

OpenBSD LibreSSL Portable 1.1k Jun 20, 2022
Collection of DLL function export forwards for DLL export function proxying

dll-exports Collection of DLL function export forwards for DLL export function proxying. Typical usecase is for backdooring applications for persisten

Magnus Stubman 34 Jun 26, 2022
C-function for traversing files/directories effectively and calling a given function with each encountered file and a void-pointer as parameters

C-function for traversing files/directories effectively and calling a given function with each encountered file and a void-pointer as parameters

null 1 Jun 27, 2022
Legion Low Level Rendering Interface provides a graphics API agnostic rendering interface with minimal CPU overhead and low level access to verbose GPU operations.

Legion-LLRI Legion-LLRI, or “Legion Low Level Rendering Interface” is a rendering API that aims to provide a graphics API agnostic approach to graphic

Rythe Interactive 25 Mar 8, 2022
F Graphics Library (FGL) is a small graphics C++ portable library for LCD displays on embedded systems

F Graphics Library (FGL) Full documentation: fgl.docsforge.com (By Filipe Chagas) F Graphics Library is a C++ library that I created for use in embedd

Filipe Chagas 8 Dec 14, 2021
A modern, portable, easy to use crypto library.

Sodium is a new, easy-to-use software library for encryption, decryption, signatures, password hashing and more. It is a portable, cross-compilable, i

Frank Denis 10.2k Jun 25, 2022
An open source, portable, easy to use, readable and flexible SSL library

README for Mbed TLS Mbed TLS is a C library that implements cryptographic primitives, X.509 certificate manipulation and the SSL/TLS and DTLS protocol

Arm Mbed 3.6k Jun 30, 2022
Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.

libui: a portable GUI library for C This README is being written. Status It has come to my attention that I have not been particularly clear about how

Pietro Gagliardi 10.3k Jun 30, 2022
Portable, simple and extensible C++ logging library

Plog - portable, simple and extensible C++ logging library Pretty powerful logging library in about 1000 lines of code Introduction Hello log! Feature

Sergey Podobry 1.4k Jun 20, 2022
Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Dask, Flink and DataFlow

eXtreme Gradient Boosting Community | Documentation | Resources | Contributors | Release Notes XGBoost is an optimized distributed gradient boosting l

Distributed (Deep) Machine Learning Community 22.9k Jun 21, 2022
LibTomMath is a free open source portable number theoretic multiple-precision integer library written entirely in C.

libtommath This is the git repository for LibTomMath, a free open source portable number theoretic multiple-precision integer (MPI) library written en

libtom 520 Jun 25, 2022
A portable, simple zip library written in C

A portable (OSX/Linux/Windows), simple zip library written in C This is done by hacking awesome miniz library and layering functions on top of the min

Kuba Podgórski 925 Jun 28, 2022
A small and portable INI file library with read/write support

minIni minIni is a portable and configurable library for reading and writing ".INI" files. At just below 900 lines of commented source code, minIni tr

Thiadmer Riemersma 257 Jun 20, 2022
Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Dask, Flink and DataFlow

eXtreme Gradient Boosting Community | Documentation | Resources | Contributors | Release Notes XGBoost is an optimized distributed gradient boosting l

Distributed (Deep) Machine Learning Community 22.9k Jun 24, 2022
PortAudio is a portable audio I/O library designed for cross-platform support of audio

PortAudio is a cross-platform, open-source C language library for real-time audio input and output.

PortAudio 633 Jun 19, 2022
Portable header-only C++ low level SIMD library

libsimdpp libsimdpp is a portable header-only zero-overhead C++ low level SIMD library. The library presents a single interface over SIMD instruction

Povilas Kanapickas 1k Jun 20, 2022
Feature-rich C99 library for memory scanning purposes, designed for Windows running machines, meant to work on both 32-bit and 64-bit portable executables. Has a modern C++ wrapper.

memscan Feature-rich C99 library for memory scanning purposes, designed for Windows running machines, meant to work on both 32-bit and 64-bit portable

cristei 11 Apr 21, 2022
Flexible, portable, high-performance bit fields C++ library. unsigned a:13 becomes F<13> a;

C-plus-plus-library-bit-fields Flexible, portible, high-performance bit fields C++ library. The bit fields are specified with a dummy structure where

Walt Karas 25 Feb 27, 2022
Pangolin: a lightweight portable rapid development library for managing OpenGL display / interaction and abstracting video input.

What is Pangolin Pangolin is a lightweight portable rapid development library for managing OpenGL display / interaction and abstracting video input. A

Yee 1 Dec 25, 2021
Mbedcrypto - a portable, small, easy to use and fast c++14 library for cryptography.

mbedcrypto mbedcrypto is a portable, small, easy to use, feature rich and fast c++14 library for cryptography based on fantastic and clean mbedtlsnote

amir zamani 37 Jun 16, 2022
logog is a portable C++ library to facilitate logging of real-time events in performance-oriented applications

logog is a portable C++ library to facilitate logging of real-time events in performance-oriented applications, such as games. It is especially appropriate for projects that have constrained memory and constrained CPU requirements.

John Byrd 46 Oct 21, 2020