Common Lisp Package: UK.CO.DEOXYBYTE-UNIX

The deoxybyte-unix package provides a Lisp style interface to the low level FFI in the :deoxybyte-unix-ffi package. Some, but not all, Lisp implementations provide a POSIX or Unix package. While deoxybyte-unix treads some well-worn ground in that respect, it should be portable to all Unix platforms supported by CFFI.

README:

FUNCTION

Public

FILE-DESCRIPTOR (STREAM &OPTIONAL DIRECTION)

Returns the Unix file descriptor associated with STREAM.

LENGTH (SEQUENCE)

Return an integer that is the length of SEQUENCE.

MAYBE-STANDARD-STREAM (DESIGNATOR)

Returns a standard stream (*standard-input* *standard-output* or *error-output*) if DESIGNATOR is a string that is STRING-EQUAL to one of "stdin", "stdout" or "stderr", otherwise returns DESIGNATOR. (Also works for "/dev/stdin" etc.) This function is useful where one of these strings may be given on a command line to indicate a system stream, rather than a file-stream is to be used.

MMAP (FILESPEC &KEY (LENGTH 0) (FOREIGN-TYPE CHAR) (PROTECTION '(SHARED)))

Maps a file into memory. Arguments: - filespec (pathname designator): The file to be mmapped. Key: - length (fixnum): The length of the Lisp vector created when the file is mmapped. - foreign-type (symbol): The foreign type of the elements to be stored in the vector. - protection (list symbol): The memory protection keyword flags used in the mmap operation. Returns: - A pointer.

MMAP-AREA-FD (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MMAP-AREA-LIVE-P (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MMAP-AREA-PTR (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MMAP-AREA-SIZE (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

MMAP-AREA-TYPE (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

Undocumented

SETFMMAP-AREA-FD (NEW-VALUE INSTANCE)

SETFMMAP-AREA-LIVE-P (NEW-VALUE INSTANCE)

SETFMMAP-AREA-PTR (NEW-VALUE INSTANCE)

SETFMMAP-AREA-SIZE (NEW-VALUE INSTANCE)

SETFMMAP-AREA-TYPE (NEW-VALUE INSTANCE)

Private

%VECTOR-BOUNDS-CHECK (VECTOR INDEX)

Performs a bounds check on INDEX with respect to LENGTH. Returns T if 0 <= INDEX < LENGTH, or raises an error otherwise.

ENLARGE-FILE (FD FSIZE)

Enlarges the open file designated by Unix file descriptor FD to FSIZE bytes.

UNIX-TMPFILE-TEMPLATE

Returns a new temporary file template string suitable for the C mkstemp function. The template is merged with *default-tmpfile-defaults* to supply the directory component.

Undocumented

COPY-MMAP-AREA (INSTANCE)

MAKE-MMAP-AREA (&KEY ((FD DUM0) 0) ((TYPE DUM1) CHAR) ((SIZE DUM2) 0) ((PTR DUM3) NIL) ((LIVE-P DUM4) NIL))

MMAP-AREA-P (OBJECT)

MACRO

Public

DEFINE-MAPPED-VECTOR (NAME FOREIGN-TYPE &OPTIONAL DOCSTRING)

Defines a mapped vector class NAME, with accompanying accessor methods ( {defmethod mref} ), specialized to store elements of FOREIGN-TYPE.

WITH-MAPPED-VECTOR ((VAR CLASS &REST INITARGS) &BODY BODY)

Executes BODY in the context of a newly instantiated {defclass mapped-vector} object of CLASS bound to VAR. The vector is safely munmapped after use.

GENERIC-FUNCTION

Public

FREE-MAPPED-VECTOR (MAPPED-VECTOR)

Frees the mapped memory used by MAPPED-VECTOR.

IN-MEMORY-P (MAPPED-FILE)

Returns T if MAPPED-FILE is mapped into memory, or NIL otherwise.

MREF (MAPPED-VECTOR INDEX)

Returns the value at INDEX in MAPPED-VECTOR.

SETFMREF (VALUE MAPPED-VECTOR INDEX)

Sets VALUE at INDEX in MAPPED-VECTOR.

MUNMAP (MAPPED-FILE)

Frees the mapped memory used by MAPPED-FILE and closes the underlying file descriptor.

Private

Undocumented

INDEX-OF (CONDITION)

MAPPED-FILE-OF (CONDITION)

SLOT-ACCESSOR

Public

DELETE-POLICY-OF (OBJECT)

A flag to indicate whether the file designated in the FILESPEC slot is to be deleted automatically when the mmapped file is freed. If an automatically generated tmp is to be used, the value of this slot is set to T.

FILESPEC-OF (OBJECT)

A user-supplied pathname designator for the file to be mmapped, or NIL an automatically generated tmp file is to be used.

LENGTH-OF (OBJECT)

The length of the Lisp vector created when the file is mmapped.

CLASS

Public

MAPPED-VECTOR

A vector backed by a mapped file.

MAPPED-VECTOR-CHAR

A mapped vector of CHAR.

MAPPED-VECTOR-DOUBLE

A mapped vector of DOUBLE.

MAPPED-VECTOR-FLOAT

A mapped vector of FLOAT.

MAPPED-VECTOR-INT

A mapped vector of INT.

MAPPED-VECTOR-INT16

A mapped vector of INT16.

MAPPED-VECTOR-INT32

A mapped vector of INT32.

MAPPED-VECTOR-SHORT

A mapped vector of SHORT.

MAPPED-VECTOR-UCHAR

A mapped vector of UNSIGNED-CHAR.

MAPPED-VECTOR-UINT

A mapped vector of UNSIGNED-INT.

MAPPED-VECTOR-UINT16

A mapped vector of UINT16.

MAPPED-VECTOR-UINT32

A mapped vector of UINT32.

MAPPED-VECTOR-USHORT

A mapped vector of UNSIGNED-SHORT.

MMAP-AREA

An aggregate of data used to describe an mmap operation. - fr: The mmap file descriptor. - type: The foreign type in the file being mmapped. - size: The size in bytes of the region mmapped. - ptr: The CFFI pointer returned by the mmap foreign function. - livep: A boolean value which is T if the file is currently mmapped, or NIL otherwise.

Undocumented

MAPPED-FILE

CONDITION

Public

MAPPED-FILE-ERROR

An error that is raised during an operation on a mmapped file.

MAPPED-INDEX-ERROR

An error that is raised during an index operation on a mmapped file.