mmap

package
v0.0.0-...-3441017 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: GPL-3.0 Imports: 9 Imported by: 3

Documentation

Overview

Package mmap provides a way to memory-map a file.

Index

Constants

View Source
const (
	PROT_READ  = syscall.PROT_READ
	PROT_WRITE = syscall.PROT_WRITE
	PROT_EXEC  = syscall.PROT_EXEC

	MAP_SHARED  = syscall.MAP_SHARED
	MAP_PRIVATE = syscall.MAP_PRIVATE
	MAP_COPY    = MAP_PRIVATE
)

Variables

View Source
var (
	// ErrUnmappedMemory is returned when a function is called on unmapped memory.
	ErrUnmappedMemory = errors.New("unmapped memory")
	// ErrIndexOutOfBound is returned when given offset lies beyond the mapped region.
	ErrIndexOutOfBound = errors.New("offset out of mapped region")
)

Functions

func Offset

func Offset(offset int64) int64

Offset returns the valid offset.

func ProtFlags

func ProtFlags(p Prot) (prot int, flags int)

Types

type File

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

func NewMmap

func NewMmap(f string, flag int, size int64) (*File, error)

func (*File) Close

func (m *File) Close() error

func (*File) Flush

func (m *File) Flush() error

func (*File) ReadAt

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

func (*File) ReadStringAt

func (m *File) ReadStringAt(dest *strings.Builder, offset int64) (int, error)

func (*File) ReadUint64At

func (m *File) ReadUint64At(offset int64) (uint64, error)

ReadUint64At reads uint64 from offset.

func (*File) WriteAt

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

func (*File) WriteStringAt

func (m *File) WriteStringAt(src string, offset int64) (int, error)

func (*File) WriteUint64At

func (m *File) WriteUint64At(num uint64, offset int64) error

WriteUint64At writes num at offset.

type Prot

type Prot int

Prot is the protection flag.

const (
	// READ represents the read prot
	READ Prot = 1 << iota
	// WRITE represents the write prot
	WRITE
	// COPY represents the copy prot
	COPY
	// EXEC represents the exec prot
	EXEC
)

Jump to

Keyboard shortcuts

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