Next: , Previous: , Up: UNIX Interface   [Contents][Index]

6.5 System Area Pointers

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. See non-descriptor.

Function: system:sap-int sap
Function: system:int-sap int

The function 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.

Function: system:sap+ sap offset

This function adds a byte offset to sap, returning a new SAP.

Function: system:sap-ref-8 sap offset
Function: system:sap-ref-16 sap offset
Function: system:sap-ref-32 sap offset

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. setf may be used with the these functions to deposit values into virtual memory.

Function: system:signed-sap-ref-8 sap offset
Function: system:signed-sap-ref-16 sap offset
Function: system:signed-sap-ref-32 sap offset

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.

Next: , Previous: , Up: UNIX Interface   [Contents][Index]