Macintosh Allegro Common LISP Foreign Function Interface
Macintosh Allegro Common LISP Foreign Function Interface
Macintosh · PDF
| Filename | Macintosh_Allegro_Common_LISP_Foreign_Function_Interface.pdf |
|---|---|
| Size | 1.44 MB |
| Subsection | developer / Macintosh_Allegro_Common_LISP |
| Downloads | 1 |
Enjoying MacTrove?
Anonymous downloads are free and unlimited.
Create a free account to track favorites,
contribute metadata corrections, and join the
community chat.
Reader
Loading…
OCR / Text contents
é Macintosh?
Allegro Common LISP
Foreign Function
Interface
Overview
The Foreign Function Interface (FFI) lets Allegro CL call functions written in C, Pascal,
Assembler, and other languages (such functions are called foreign functions). Foreign
functions can, in turn, make calls back to Lisp.
To take advantage of the high-level functions described below, the foreign function code must
be compiled into Macintosh Programer’s Workshop (MPW™) object file format. Any
compiler which produces object files of the MPW format may be used. Machine code
produced by other compilers or assemblers can only be accessed using the low-level function
ff-call.
The Foreign Function Interface provides two interface syntaxes. The primary syntax is
designed specifically for use with Allegro CL on the Macintosh; this is the syntax described
by the major portion of this document. The secondary syntax (Franz syntax) was
implemented for compatibility with versions of Allegro CL running on other computers; this
syntax is described in Franz Inc’s Allegro CL User Guide, with supplemental notes provided
at the end of this document.
Using foreign functions from Allegro CL involves the following steps:
* Write and compile the foreign functions using a compiler which produces MPW
object Files.
¢ Run Allegro CL and load the Foreign Function Interface fas! files.
¢ Load the MPW object files with the function f£-1load.
* Define an interface for each foreign function you wish to call. (This is done with
defffun.)
Call the foreign functions from Lisp using Lisp syntax.
A call from Lisp to a foreign function looks exactly like a call to another Lisp function. The
Lisp function which makes the call (and, for that matter, the programmer) doesn’t even need to
Allegro Foreign Function Interface
know that the function called was written in a different language.
Installation
The files required to use the foreign function interface are found in the folder
"Foreign Function Folder." You may wish to move the files "££.fasi" and
"defforeign.fas1" into a directory included in your *module-search-path*. To
use the foreign function interface, run Allegro CL and load the file "££.fasl". If you
wish to use Franz syntax, you must also load the file "defforeign.fasl".
Foreign Function Interface Operations
£f£-load files &key :entry-names :libraries [Function]
:library-entry-names :ffenv-name
:replace
loads the MPW object files specified by files, and returns a foreign function environment.
The foreign function environment returned consists of code segments, a jump table, a static
data area, and a collection of active entry point names. Dead code removal is performed so that
only code and data reachable from the active entry points will be included in the environment.
files should be a filename, pathname or a list of filenames and
pathnames of MPW object files.
:entry-names a list of strings naming all the entry points in files which
should be active. If :ent ry-names is not specif…
Showing first 3,000 characters of 22,104 total. Open the full document →