Skip to content

Interface for mmap syscall to provide safe and efficient access to memory

License

Notifications You must be signed in to change notification settings

grandecola/mmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mmap Build Status Go Report Card MIT license PkgGoDev codecov

Interface for mmap syscall to provide safe and efficient access to memory. *mmap.File satisfies both io.ReaderAt and io.WriterAt interfaces.

Only works for darwin OS, Linux and Little Endian 64 bit architectures.

Safety & Efficiency

Golang mmap syscall function exposes the mapped memory as array of bytes. If the array is referenced even after the memory region is unmapped, this can lead to segmentation fault. mmap package provides safe access to the array of bytes by providing ReadAt and WriteAt functions.

WriteAt function copies a slice into the memory mapped region whereas ReadAt function copies data from memory mapped region to a given slice, therefore, avoiding exposing the array of bytes referring to mapped memory. This also avoids any extra data copy providing efficient access to the memory mapped region.

We have also added functions such as WriteUint64At, ReadUint64At that can directly typecast the mmaped memory to Uint64 and avoids an extra copy. We will add more functions in the library based on our use cases. If you need support for a particular function, let us know or better, raise a pull request.

Similar Packages

  • golang.org/x/exp/mmap
  • github.com/riobard/go-mmap
  • launchpad.net/gommap
  • github.com/edsrzf/mmap-go

About

Interface for mmap syscall to provide safe and efficient access to memory

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages