X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=doc%2Finternals%2Fforeign-linkage.texinfo;h=5e8491d78a57228d23d730b4123a1488bcd929e7;hb=bc80839e6c4fc80a7452a44d974e796c25d10646;hp=d08d77b5b364b066c15a10e1b02c404cfd1eed93;hpb=927001993f81c25f387e124cb17ebd7db4b7cb37;p=sbcl.git diff --git a/doc/internals/foreign-linkage.texinfo b/doc/internals/foreign-linkage.texinfo index d08d77b..5e8491d 100644 --- a/doc/internals/foreign-linkage.texinfo +++ b/doc/internals/foreign-linkage.texinfo @@ -17,7 +17,7 @@ also utilized to allow references to as-of-yet unknown aliens. @xref{Lazy Alien Resolution}. The SBCL implementation is somewhat simplified from the CMUCL one by -Timothy Moore, but the basic idea and mechanism remains identical: +Timothy Moore, but the basic idea and mechanism remain identical: instead of having addresses from @code{dlsym(3)} in the core, we have addresses to an mmapped memory area (@code{LINKAGE_TABLE_SPACE}) that is initialized at startup to contain jumps & references to the correct @@ -52,26 +52,27 @@ When a foreign symbol is referred to, it is first looked for in the corresponding entry in @code{*LINKAGE-INFO*}, creating one and writing the appropriate entry in the linkage table if necessary. -@code{FOREIGN-SYMBOL-ADDRESS} and -@code{FOREIGN-SYMBOL-ADDRESS-AS-INTEGER} take an optional datap -argument, used to indicate that the symbol refers to a variable. In -similar fashion there is a new kind of fixup and a new VOP: -@code{:FOREIGN-DATAREF} and @code{FOREIGN-SYMBOL-DATAREF-ADDRESS}. The -@code{DATAP} argument is automagically provided by the alien interface -for normal definitions, but is really needed only for dynamic foreign -variables. For those it indicates the need for the indirection either -within a conditional branch in @code{FOREIGN-SYMBOL-ADDRESS}, or via -@code{:FOREIGN-DATAREF} fixup and -@code{FOREIGN-SYMBOL-DATAREF-ADDRESS} VOP: "this address holds the +@code{FOREIGN-SYMBOL-ADDRESS} and @code{FOREIGN-SYMBOL-SAP} take an +optional datap argument, used to indicate that the symbol refers to a +variable. In similar fashion there is a new kind of fixup and a new +VOP: @code{:FOREIGN-DATAREF} and @code{FOREIGN-SYMBOL-DATAREF-SAP}. + +The @code{DATAP} argument is automagically provided by the alien +interface for normal definitions, but is really needed only for +dynamic foreign variables. For those it indicates the need for the +indirection either within a conditional branch in +@code{FOREIGN-SYMBOL-SAP}, or via @code{:FOREIGN-DATAREF} fixup and +@code{FOREIGN-SYMBOL-DATAREF-SAP} VOP: "this address holds the address of the foreign variable, not the variable itself". Within SBCL itself (in the fixups manifest in various VOPs) this fixup type is never used, as all foreign symbols used internally are static. -One thing worth noting is that @code{FOREIGN-SYMBOL-ADDRESS} and -friends now have the potential side-effect of entering information in -@code{*LINKAGE-INFO*} and the linkage-table proper: hence it's important to -use the correct datap argument even if calling these just to "check if -it's there" (like SB-POSIX does). +One thing worth noting is that @code{FOREIGN-SYMBOL-SAP} and friends +now have the potential side-effect of entering information in +@code{*LINKAGE-INFO*} and the linkage-table proper. If the usage case +is about checking if the symbol is available use +@code{FIND-FOREIGN-SYMBOL-ADDRESS}, which is side-effect free. (This +is used by SB-POSIX.) @subsection Porting @@ -102,7 +103,7 @@ aliens -- which is to say, compile and load code referring to aliens before the shared object containing the alien in question has been loaded. -This is handled by @code{GET-DYNAMIC-FOREIGN-SYMBOL-ADDRESS}, which +This is handled by @code{ENSURE-DYNAMIC-FOREIGN-SYMBOL-ADDRESS}, which first tries to resolve the address in the loaded shared objects, but failing that records the alien as undefined and returns the address of a read/write/execute protected guard page for variables, and address