libffi

A Portable Foreign Function Interface Library
libffi-3.0.13 was released on March 17, 2013. You can ftp it from sourceware.org:/pub/libffi/libffi-3.0.13.tar.gz.

libffi is free software. It has a very liberal license.

What is libffi?

Compilers for high level languages generate code that follows certain conventions. These conventions are necessary, in part, for separate compilation to work. One such convention is the "calling convention". The "calling convention" is 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.

Who uses it?

The libffi library is useful to anyone trying to build a bridge between interpreted and natively compiled code. Some notable users include:

Supported Platforms

Libffi has been ported to many different platforms. For specific configuration details and testing status, please refer to the wiki page here:
http://www.moxielogic.org/wiki/index.php?title=Libffi_3.0.13

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

ArchitectureOperating System
Alpha Linux
AArch64 Linux
Alpha Linux
Alpha Tru64
ARM Linux
ARM iOS
AVR32 Linux
Blackfin uClinux
HPPA HPUX
IA-64 Linux
M68K FreeMiNT
M68K Linux
M68K RTEMS
Meta Linux
MicroBlaze Linux
MIPS IRIX
MIPS Linux
MIPS RTEMS
MIPS64 Linux
PowerPC 32-bit AIX
PowerPC 64-bit AIX
PowerPC AMIGA
PowerPC 32-bit Linux
PowerPC 64-bit Linux
PowerPC Mac OSX
PowerPC 32-bit FreeBSD
PowerPC 64-bit FreeBSD
S390 Linux
S390X Linux
SPARC Linux
SPARC Solaris
SPARC64 Linux
SPARC64 FreeBSD
SPARC64 Solaris
TILE-Gx/TILEPro Linux
X86 FreeBSD
X86 GNU HURD
X86 Interix
X86 kFreeBSD
X86 Linux
X86 Mac OSX
X86 OpenBSD
X86 OS/2
X86 Solaris
X86 Windows/Cygwin
X86 Windows/MingW
X86-64 FreeBSD
X86-64 Linux
X86-64 Linux/x32
X86-64 OpenBSD
X86-64 Solaris
X86-64 Windows/MingW
Xtensa Linux

Please send additional platform test results to libffi-discuss@sourceware.org and feel free to update the wiki page above.

How to get it

You can download the latest version from sourceware.org:/pub/libffi/.

You can also check out the very latest version from the development git repository at http://github.com/atgreen/libffi. Here's how:

  git clone git://github.com/atgreen/libffi.git
You can also browse the sources at http://github.com/atgreen/libffi.

Mailing lists

For such a small piece of software, there are plenty of mailing lists available.

To subscribe to the libffi-announce mailing list, enter your e-mail address:


To subscribe to the libffi-discuss mailing list, enter your e-mail address:

Authors and Credits

libffi was originally written by Anthony Green

The developers of the GNU Compiler Collection project have made innumerable valuable contributions. See this ChangeLog files in the source distribution 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
arm		Raffaele Sena
blackfin        Alexandre Keunecke I. de Mendonca
cris		Simon Posnjak, Hans-Peter Nilsson
frv		Anthony Green
ia64		Hans Boehm
m32r		Kazuhiro Inaoka
m68k		Andreas Schwab
microblaze	Nathan Rossi
mips		Anthony Green, Casey Marshall
mips64		David Daney
moxie		Anthony Green
pa		Randolph Chung, Dave Anglin, Andreas Tobler
powerpc		Geoffrey Keating, Andreas Tobler, 
			 David Edelsohn, John Hornkvist
powerpc64	Jakub Jelinek
s390		Gerhard Tonn, Ulrich Weigand
sh		Kaz Kojima
sh64		Kaz Kojima
sparc		Anthony Green, Gordon Irlam
tile-gx/tilepro Walter Lee
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 libffi-discuss@sourceware.org or to me directly (green@moxielogic.com).