Note that in some cases an address is represented by a Lisp integer, and in other cases it is represented by a real pointer. Pointers are usually used when an object in the current address space is being referred to. The MACH virtual memory manipulation calls must use integers, since in principle the address could be in any process, and Lisp cannot abide random pointers. Because these types are represented differently in Lisp, one must explicitly coerce between these representations.
System Area Pointers (SAPs) provide a mechanism that bypasses the
Alien type system and accesses virtual memory directly. A SAP is a
raw byte pointer into the
lisp process address space. SAPs are
represented with a pointer descriptor, so SAP creation can cause
consing. However, the compiler uses a non-descriptor representation
for SAPs when possible, so the consing overhead is generally minimal.
sap-int is used to generate an integer
corresponding to the system area pointer, suitable for passing to
the kernel interfaces (which want all addresses specified as
integers). The function
int-sap is used to do the opposite
conversion. The integer representation of a SAP is the byte offset
of the SAP from the start of the address space.
This function adds a byte offset to sap, returning a new SAP.
These functions return the 8, 16 or 32 bit unsigned integer at
offset from sap. The offset is always a byte
offset, regardless of the number of bits accessed.
be used with the these functions to deposit values into virtual
These functions are the same as the above unsigned operations, except that they sign-extend, returning a negative number if the high bit is set.