mmap

package module
v0.0.0-...-24ae22d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 28, 2024 License: MIT Imports: 4 Imported by: 1

README

mmap

Go Report Card GoDoc GitHub license

mmap syscall function exposes the mapped memory as array of bytes

MIT License

Licensed under the MIT License. See LICENSE for the full license text.

Documentation

Index

Constants

View Source
const (
	// RDONLY maps the memory read-only.
	// Attempts to write to the MMap object will result in undefined behavior.
	RDONLY = 0
	// RDWR maps the memory as read-write. Writes to the MMap object will update the
	// underlying file.
	RDWR = 1 << iota
	// COPY maps the memory as copy-on-write. Writes to the MMap object will affect
	// memory, but the underlying file will remain unchanged.
	COPY
	// If EXEC is set, the mapped memory is marked as executable.
	EXEC
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MMap

type MMap struct {
	// contains filtered or unexported fields
}

MMap represents a file mapped into memory.

func Map

func Map(f *os.File, prot int) (*MMap, error)

Map maps an entire file into memory.

func MapRegion

func MapRegion(f *os.File, prot int, offset, length int) (*MMap, error)

MapRegion maps part of a file into memory. The offset parameter must be a multiple of the system's page size.

func (*MMap) At

func (m *MMap) At(i int) byte

At returns the byte at index i.

func (*MMap) Close

func (m *MMap) Close() error

Close implements the io.Closer interface.

func (*MMap) Data

func (m *MMap) Data() []byte

Data returns mapped memory.

func (MMap) Flush

func (m MMap) Flush() error

Flush synchronizes the mapping's contents to the file's contents on disk.

func (*MMap) Len

func (m *MMap) Len() int

Len returns the length of the underlying mapped memory.

func (MMap) Lock

func (m MMap) Lock() error

Lock keeps the mapped region in physical memory.

func (*MMap) ReadAt

func (m *MMap) ReadAt(dest []byte, offset int64) (int, error)

ReadAt implements the io.ReaderAt interface.

func (MMap) Unlock

func (m MMap) Unlock() error

Unlock reverses the effect of Lock.

func (*MMap) WriteAt

func (m *MMap) WriteAt(src []byte, offset int64) (int, error)

WriteAt implements the io.WriterAt interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL