| 1 | This directory contains the libffi package, which is not part of GCC but
|
|---|
| 2 | shipped with GCC as convenience.
|
|---|
| 3 |
|
|---|
| 4 | Status
|
|---|
| 5 | ======
|
|---|
| 6 |
|
|---|
| 7 | libffi-2.00 has not been released yet! This is a development snapshot!
|
|---|
| 8 |
|
|---|
| 9 | libffi-1.20 was released on October 5, 1998. Check the libffi web
|
|---|
| 10 | page for updates: <URL:http://sources.redhat.com/libffi/>.
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 | What is libffi?
|
|---|
| 14 | ===============
|
|---|
| 15 |
|
|---|
| 16 | Compilers for high level languages generate code that follow certain
|
|---|
| 17 | conventions. These conventions are necessary, in part, for separate
|
|---|
| 18 | compilation to work. One such convention is the "calling
|
|---|
| 19 | convention". The "calling convention" is essentially a set of
|
|---|
| 20 | assumptions made by the compiler about where function arguments will
|
|---|
| 21 | be found on entry to a function. A "calling convention" also specifies
|
|---|
| 22 | where the return value for a function is found.
|
|---|
| 23 |
|
|---|
| 24 | Some programs may not know at the time of compilation what arguments
|
|---|
| 25 | are to be passed to a function. For instance, an interpreter may be
|
|---|
| 26 | told at run-time about the number and types of arguments used to call
|
|---|
| 27 | a given function. Libffi can be used in such programs to provide a
|
|---|
| 28 | bridge from the interpreter program to compiled code.
|
|---|
| 29 |
|
|---|
| 30 | The libffi library provides a portable, high level programming
|
|---|
| 31 | interface to various calling conventions. This allows a programmer to
|
|---|
| 32 | call any function specified by a call interface description at run
|
|---|
| 33 | time.
|
|---|
| 34 |
|
|---|
| 35 | Ffi stands for Foreign Function Interface. A foreign function
|
|---|
| 36 | interface is the popular name for the interface that allows code
|
|---|
| 37 | written in one language to call code written in another language. The
|
|---|
| 38 | libffi library really only provides the lowest, machine dependent
|
|---|
| 39 | layer of a fully featured foreign function interface. A layer must
|
|---|
| 40 | exist above libffi that handles type conversions for values passed
|
|---|
| 41 | between the two languages.
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 | Supported Platforms and Prerequisites
|
|---|
| 45 | =====================================
|
|---|
| 46 |
|
|---|
| 47 | Libffi has been ported to:
|
|---|
| 48 |
|
|---|
| 49 | SunOS 4.1.3 & Solaris 2.x (Sparc v8)
|
|---|
| 50 |
|
|---|
| 51 | Irix 5.3 & 6.2 (System V/o32 & n32)
|
|---|
| 52 |
|
|---|
| 53 | Intel x86 - Linux (System V ABI)
|
|---|
| 54 |
|
|---|
| 55 | Alpha - Linux and OSF/1
|
|---|
| 56 |
|
|---|
| 57 | m68k - Linux (System V ABI)
|
|---|
| 58 |
|
|---|
| 59 | PowerPC - Linux (System V ABI, Darwin, AIX)
|
|---|
| 60 |
|
|---|
| 61 | ARM - Linux (System V ABI)
|
|---|
| 62 |
|
|---|
| 63 | Libffi has been tested with the egcs 1.0.2 gcc compiler. Chances are
|
|---|
| 64 | that other versions will work. Libffi has also been built and tested
|
|---|
| 65 | with the SGI compiler tools.
|
|---|
| 66 |
|
|---|
| 67 | On PowerPC, the tests failed (see the note below).
|
|---|
| 68 |
|
|---|
| 69 | You must use GNU make to build libffi. SGI's make will not work.
|
|---|
| 70 | Sun's probably won't either.
|
|---|
| 71 |
|
|---|
| 72 | If you port libffi to another platform, please let me know! I assume
|
|---|
| 73 | that some will be easy (x86 NetBSD), and others will be more difficult
|
|---|
| 74 | (HP).
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 | Installing libffi
|
|---|
| 78 | =================
|
|---|
| 79 |
|
|---|
| 80 | [Note: before actually performing any of these installation steps,
|
|---|
| 81 | you may wish to read the "Platform Specific Notes" below.]
|
|---|
| 82 |
|
|---|
| 83 | First you must configure the distribution for your particular
|
|---|
| 84 | system. Go to the directory you wish to build libffi in and run the
|
|---|
| 85 | "configure" program found in the root directory of the libffi source
|
|---|
| 86 | distribution.
|
|---|
| 87 |
|
|---|
| 88 | You may want to tell configure where to install the libffi library and
|
|---|
| 89 | header files. To do that, use the --prefix configure switch. Libffi
|
|---|
| 90 | will install under /usr/local by default.
|
|---|
| 91 |
|
|---|
| 92 | If you want to enable extra run-time debugging checks use the the
|
|---|
| 93 | --enable-debug configure switch. This is useful when your program dies
|
|---|
| 94 | mysteriously while using libffi.
|
|---|
| 95 |
|
|---|
| 96 | Another useful configure switch is --enable-purify-safety. Using this
|
|---|
| 97 | will add some extra code which will suppress certain warnings when you
|
|---|
| 98 | are using Purify with libffi. Only use this switch when using
|
|---|
| 99 | Purify, as it will slow down the library.
|
|---|
| 100 |
|
|---|
| 101 | Configure has many other options. Use "configure --help" to see them all.
|
|---|
| 102 |
|
|---|
| 103 | Once configure has finished, type "make". Note that you must be using
|
|---|
| 104 | GNU make. SGI's make will not work. Sun's probably won't either.
|
|---|
| 105 | You can ftp GNU make from prep.ai.mit.edu:/pub/gnu.
|
|---|
| 106 |
|
|---|
| 107 | To ensure that libffi is working as advertised, type "make test".
|
|---|
| 108 |
|
|---|
| 109 | To install the library and header files, type "make install".
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 | Using libffi
|
|---|
| 113 | ============
|
|---|
| 114 |
|
|---|
| 115 | The Basics
|
|---|
|
|---|