fpu

package
v0.0.0-...-9ec6d29 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: Apache-2.0, MIT Imports: 8 Imported by: 0

Documentation

Overview

Package fpu provides basic floating point helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrLoadingState

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

ErrLoadingState indicates a failed restore due to unusable floating point state.

func (ErrLoadingState) Error

func (e ErrLoadingState) Error() string

Error returns a sensible description of the restore error.

type State

type State []byte

State represents floating point state.

This is a simple byte slice, but may have architecture-specific methods attached to it.

func NewState

func NewState() State

NewState returns an initialized floating point state.

The returned state is large enough to store all floating point state supported by host, even if the app won't use much of it due to a restricted FeatureSet. Since they may still be able to see state not advertised by CPUID we must ensure it does not contain any sentry state.

func (*State) AfterLoad

func (s *State) AfterLoad()

AfterLoad converts the loaded state to the format that compatible with the current processor.

func (*State) BytePointer

func (s *State) BytePointer() *byte

BytePointer returns a pointer to the first byte of the state.

func (*State) Fork

func (s *State) Fork() State

Fork creates and returns an identical copy of the x86 floating point state.

func (*State) PtraceGetFPRegs

func (s *State) PtraceGetFPRegs(dst io.Writer, maxlen int) (int, error)

PtraceGetFPRegs implements Context.PtraceGetFPRegs.

func (*State) PtraceGetXstateRegs

func (s *State) PtraceGetXstateRegs(dst io.Writer, maxlen int, featureSet cpuid.FeatureSet) (int, error)

PtraceGetXstateRegs implements ptrace(PTRACE_GETREGS, NT_X86_XSTATE) by writing the floating point registers from this state to dst and returning the number of bytes written, which must be less than or equal to maxlen.

func (*State) PtraceSetFPRegs

func (s *State) PtraceSetFPRegs(src io.Reader, maxlen int) (int, error)

PtraceSetFPRegs implements Context.PtraceSetFPRegs.

func (*State) PtraceSetXstateRegs

func (s *State) PtraceSetXstateRegs(src io.Reader, maxlen int, featureSet cpuid.FeatureSet) (int, error)

PtraceSetXstateRegs implements ptrace(PTRACE_SETREGS, NT_X86_XSTATE) by reading floating point registers from src and returning the number of bytes read, which must be less than or equal to maxlen.

func (*State) Reset

func (s *State) Reset()

Reset resets s to its initial state.

func (*State) SanitizeUser

func (s *State) SanitizeUser(featureSet cpuid.FeatureSet)

SanitizeUser mutates s to ensure that restoring it is safe.

func (*State) SetMXCSR

func (s *State) SetMXCSR(mxcsr uint32)

SetMXCSR sets the MXCSR control/status register in the state.

Jump to

Keyboard shortcuts

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