X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=inline;f=doc%2Fmanual%2Fffi.texinfo;h=80e6a593dc4470ea706595555fc80f3f43409337;hb=f4450bdf225af39172d05881069e65fb61a7fd84;hp=5f365d99fc5b69ffb1e3df0a55ddd3cb19c6f9c7;hpb=01b53542be411ba6ede003da5e7292e16602ab6e;p=sbcl.git diff --git a/doc/manual/ffi.texinfo b/doc/manual/ffi.texinfo index 5f365d9..80e6a59 100644 --- a/doc/manual/ffi.texinfo +++ b/doc/manual/ffi.texinfo @@ -1,3 +1,7 @@ +@node Foreign Function Interface +@comment node-name, next, previous, up +@chapter Foreign Function Interface + This chapter describes SBCL's interface to C programs and libraries (and, since C interfaces are a sort of @emph{ingua franca} of the Unix world, to other programs and libraries in @@ -20,7 +24,7 @@ notably in the name of the @code{SB-ALIEN} package. * Operations On Foreign Values:: * Foreign Variables:: * Foreign Data Structure Examples:: -* Loading Unix Object Files:: +* Loading Shared Object Files:: * Foreign Function Calls:: * Step-By-Step Example of the Foreign Function Interface:: @end menu @@ -707,33 +711,14 @@ which can be manipulated in Lisp like this: (setq my-struct (slot my-struct 'n)) @end lisp -@node Loading Unix Object Files +@node Loading Shared Object Files @comment node-name, next, previous, up -@section Loading Unix Object Files +@section Loading Shared Object Files Foreign object files can be loaded into the running Lisp process by calling @code{load-shared-object}. -The @code{sb-alien:load-shared-object} loads a single object file into -the currently running Lisp. The external symbols defining routines and -variables are made available for future external references (e.g. by -@code{extern-alien}). Forward references to foreign symbols aren't -supported: @code{load-shared-object} must be run before any of the -defined symbols are referenced. - -@quotation -Note: As of SBCL 0.7.5, all foreign code (code loaded with -@code{load-shared-object}) is lost when a Lisp -core is saved with @code{sb-ext:save-lisp-and-die}, and no attempt is -made to restore it when the core is loaded. Historically this has been -an annoyance both for SBCL users and for CMUCL users. It's hard to -solve this problem completely cleanly, but some generally-reliable -partial solution might be useful. Once someone in either camp gets -sufficiently annoyed to create it, SBCL is likely to adopt some -mechanism for automatically restoring foreign code when a saved core -is loaded. -@end quotation - +@include fun-sb-alien-load-shared-object.texinfo @node Foreign Function Calls @comment node-name, next, previous, up @@ -1134,7 +1119,7 @@ struct c_struct *c_function (i, s, r, a) printf("s = %s\n", s); printf("r->x = %d\n", r->x); printf("r->s = %s\n", r->s); - for (j = 0; j < 10; j++) printf("a[%d] = %d.\n", j, a[j]); + for (j = 0; j < 10; j++) printf("a[%d] = %d.\n", j, a[j]); r2 = (struct c_struct *) malloc (sizeof(struct c_struct)); r2->x = i + 5; r2->s = "a C string"; @@ -1205,8 +1190,7 @@ separately. You don't have to recompile every time.) @samp{(compile-file "test.lisp")} Within Lisp, load the foreign object file to define the necessary -symbols: @samp{(load-shared-object "test.so")}. This must be done -before loading any code that refers to these symbols. +symbols: @samp{(load-shared-object "test.so")}. Now you can load the compiled Lisp (``fasl'') file into Lisp: @samp{(load "test.fasl")}