Documentation ¶
Overview ¶
Package fpu provides basic floating point helpers.
Index ¶
- type ErrLoadingState
- type State
- func (s *State) AfterLoad()
- func (s *State) BytePointer() *byte
- func (s *State) Fork() State
- func (s *State) PtraceGetFPRegs(dst io.Writer, maxlen int) (int, error)
- func (s *State) PtraceGetXstateRegs(dst io.Writer, maxlen int, featureSet cpuid.FeatureSet) (int, error)
- func (s *State) PtraceSetFPRegs(src io.Reader, maxlen int) (int, error)
- func (s *State) PtraceSetXstateRegs(src io.Reader, maxlen int, featureSet cpuid.FeatureSet) (int, error)
- func (s *State) Reset()
- func (s *State) SanitizeUser(featureSet cpuid.FeatureSet)
- func (s *State) SetMXCSR(mxcsr uint32)
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 ¶
BytePointer returns a pointer to the first byte of the state.
func (*State) PtraceGetFPRegs ¶
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 ¶
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) SanitizeUser ¶
func (s *State) SanitizeUser(featureSet cpuid.FeatureSet)
SanitizeUser mutates s to ensure that restoring it is safe.