Loads the library with the given name and looks up the procedure procName with signature procSignature in it and results in an FFI for it.
Note that procName should be a Str and procSignature should be a Symbol.
Example:
#!/usr/bin/λ -i let puts! := requireSharedLibrary "/lib/x86_64-linux-gnu/libc.so.6" 'Cis "puts" in puts! "Hello world"
See the 5D Programming Manual for more details.
Packs the given list using the given format, resulting in a Box (or Str). Note that the result can be reused later by the system. If you want to detach it, use duplicateRecord! on the result.
Possible format specifiers in the Format Str:
Character | Meaning |
---|---|
b | signed byte |
B | unsigned byte |
h | short |
H | unsigned short |
i | int |
I | unsigned int |
l | long |
L | unsigned long |
f | float |
d | double |
g | long double |
p | pointer |
P | pointer or nil |
x | padding byte (no input needed) |
[ | array of the following |
The format string can contain endian control characters. The tail of the format string starting at the endian control character will be encoded using the given endianness.
These are:
Character | Meaning |
---|---|
= | use machine native endian (will also align primitive fields) |
> | use big endian (without alignment) |
< | use little endian (without alignment) |
Example:
packRecord "ii" [1 2] => "\x01\x00\x00\x00\x02\x00\x00\x00"
Unpacks the given box using the given format, resulting in a List. See packRecord for details.
Example:
unpackRecord "ii" "\x01\x00\x00\x00\x02\x00\x00\x00" => [1 2]
Given a world, allocates an empty record with the given format, resulting in a Box (or Str) and a new World.
Example:
allocateRecord! "ii" ;\r liftIO! r
Given a world, duplicates the record in box, resulting in the new Box and a new World.
Example:
duplicateRecord! (packRecord "ii" [1 2]) ;\r liftIO! r
Results in the size (in bytes) a record with the given format would have.
Note that this doesn't work with record formats like [p] which have dynamic size. Just use packRecord for them.
Example:
recordSize "i" => 4