mmap

2024-10-12

Portable mmap (file memory mapping) utility library.

Upstream URL

github.com/Shinmera/mmap

Author

Yukari Hafner <shinmera@tymoon.eu>

Maintainer

Yukari Hafner <shinmera@tymoon.eu>

License

zlib
README

About MMAP

This is a utility library providing access to the mmap family of functions in a portable way. It should work on Posix and Windows systems. mmap allows you to directly map a file into the address space of your process without having to manually read it into memory sequentially. Typically this is much more efficient for files that are larger than a few Kb.

Supported operations

The library offers access to the following functions:

  • mmap
  • munmap
  • msync
  • mprotect

It also provides a convenience macro called with-mmap to perform safe, local mappings of files.

(mmap:with-mmap (addr fd size #p"/etc/lsb-release")
  (with-output-to-string (out)
    (loop for i from 0 below size
          for char = (code-char (cffi:mem-aref addr :char i))
          do (write-char char out))))

If you're on a system where mmap is supported, :mmap will be in *features*.

Dependencies (5)

  • alexandria
  • cffi
  • documentation-utils
  • parachute
  • trivial-features
  • GitHub
  • Quicklisp