This library provides facilities for extracting and compiling C header information to generate architecture-specific binary layout information. This is particularly useful for writing code that interacts with the PLT Scheme foreign library—see The Racket Foreign Interface.
Specifically, the foreign library’s pointer-manipulation procedures such as ptr-ref and ptr-set! can be used to read and write to arbitrary addresses, which can be computed using layout information.
make-program-reader: undefined;
cannot reference an identifier before its definition
in module: top-level
Using the Scribble @-reader, the latter example could be rewritten with embedded C syntax as:
struct tm {int tm_sec;int tm_min;int tm_hour;int tm_mday;int tm_mon;int tm_year;int tm_wday;int tm_yday;int tm_isdst;};}))
procedure
( compile-header headercompiler)→abi?
header:header?
A header compiler must recognize the following types of queries.
struct
type:any
struct
expr:any
procedure
#:includeincludeexe])
procedure
x:layout?
procedure
( ref-layout? x)→boolean?
x:layout?
procedure
( struct-layout? x)→boolean?
x:layout?
procedure
( union-layout? x)→boolean?
x:layout?
procedure
( array-layout? x)→boolean?
x:layout?
procedure
( pointer-layout? x)→boolean?
x:layout?
procedure
( enum-layout? x)→boolean?
x:layout?
procedure
( layout-size x)→uint
x:layout?
procedure
( layout-offset xpath)→uint
procedure
( struct-layout-lookup xname)→layout?
name:symbol?
procedure
( union-layout-lookup xname)→layout?
name:symbol?
procedure
( deref-layout x)→layout?
x:layout?
An Application Binary Interface (ABI) provides information about the binary representation of C datatypes on a particular architecture.
As a convenience, ABI structures can be used as procedures, which is equivalent to calling abi-lookup with the ABI structure as the first argument.
procedure
( abi-lookup abiname)→layout?
abi:abi?name:symbol?
procedure
( abi-lookup-typedef abiname)→layout?
abi:abi?name:symbol?
procedure
( abi-lookup-tag abiname)→layout?
abi:abi?name:symbol?
procedure
( serialize-abi abi)→sexp?
abi:abi?
procedure
( deserialize-abi input)→abi?
input:sexp?
abi:abi?