Call a function in a shared library: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→{{header|Perl 6}}: Update to work with 64 bit IDs (fix segfault)) |
(Add Jsish) |
||
Line 1,039: | Line 1,039: | ||
} |
} |
||
}</lang> |
}</lang> |
||
=={{header|Jsish}}== |
|||
Jsish includes a '''load('library.so');''' function, which calls a specially crafted management function in the library, |
|||
'''JsiInitmoduleName''', where the moduleName part of the exported symbol is the name of the library loaded. |
|||
Normally, this function would register commands to the shell, but this is just a DISPLAY statement on load, and then again on unload as jsish runs down. Note the name used, "Jsi_Initbyjsi", from "byjsi.so". |
|||
<lang javascript>#!/usr/local/bin/jsish |
|||
load('byjsi.so');</lang> |
|||
For example, a COBOL library generated from |
|||
<lang COBOL> identification division. |
|||
program-id. sample as "Jsi_Initbyjsi". |
|||
environment division. |
|||
configuration section. |
|||
special-names. |
|||
call-convention 0 is extern. |
|||
repository. |
|||
function all intrinsic. |
|||
data division. |
|||
linkage section. |
|||
01 jsi-interp usage pointer. |
|||
01 rel usage binary-long. |
|||
procedure division using by value jsi-interp rel. |
|||
sample-main. |
|||
if rel equal zero then |
|||
display "GnuCOBOL from jsish load of " module-source() |
|||
" and cobc -m -fimplicit-init" upon syserr |
|||
goback |
|||
end-if |
|||
display "Called again with: " jsi-interp ", " rel upon syserr |
|||
goback. |
|||
end program sample.</lang> |
|||
{{out}} |
|||
<pre>prompt$ cobc -m -debug -fimplicit-init byjsi.cob |
|||
prompt$ ./callcob.jsi |
|||
GnuCOBOL from jsish load of byjsi.cob and cobc -m -fimplicit-init |
|||
Called again with: 0x00000000013a9260, +0000000002 |
|||
prompt$</pre> |
|||
=={{header|Julia}}== |
=={{header|Julia}}== |