// automatically generated by stateify.

package lock

import (
	"context"

	"gvisor.dev/gvisor/pkg/state"
)

func (o *OwnerInfo) StateTypeName() string {
	return "pkg/sentry/fsimpl/lock.OwnerInfo"
}

func (o *OwnerInfo) StateFields() []string {
	return []string{
		"PID",
		"OFD",
	}
}

func (o *OwnerInfo) beforeSave() {}

// +checklocksignore
func (o *OwnerInfo) StateSave(stateSinkObject state.Sink) {
	o.beforeSave()
	stateSinkObject.Save(0, &o.PID)
	stateSinkObject.Save(1, &o.OFD)
}

func (o *OwnerInfo) afterLoad(context.Context) {}

// +checklocksignore
func (o *OwnerInfo) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &o.PID)
	stateSourceObject.Load(1, &o.OFD)
}

func (l *Lock) StateTypeName() string {
	return "pkg/sentry/fsimpl/lock.Lock"
}

func (l *Lock) StateFields() []string {
	return []string{
		"Readers",
		"Writer",
		"WriterInfo",
	}
}

func (l *Lock) beforeSave() {}

// +checklocksignore
func (l *Lock) StateSave(stateSinkObject state.Sink) {
	l.beforeSave()
	stateSinkObject.Save(0, &l.Readers)
	stateSinkObject.Save(1, &l.Writer)
	stateSinkObject.Save(2, &l.WriterInfo)
}

func (l *Lock) afterLoad(context.Context) {}

// +checklocksignore
func (l *Lock) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &l.Readers)
	stateSourceObject.Load(1, &l.Writer)
	stateSourceObject.Load(2, &l.WriterInfo)
}

func (l *Locks) StateTypeName() string {
	return "pkg/sentry/fsimpl/lock.Locks"
}

func (l *Locks) StateFields() []string {
	return []string{
		"locks",
		"blockedQueue",
	}
}

func (l *Locks) beforeSave() {}

// +checklocksignore
func (l *Locks) StateSave(stateSinkObject state.Sink) {
	l.beforeSave()
	stateSinkObject.Save(0, &l.locks)
	stateSinkObject.Save(1, &l.blockedQueue)
}

func (l *Locks) afterLoad(context.Context) {}

// +checklocksignore
func (l *Locks) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &l.locks)
	stateSourceObject.Load(1, &l.blockedQueue)
}

func (r *LockRange) StateTypeName() string {
	return "pkg/sentry/fsimpl/lock.LockRange"
}

func (r *LockRange) StateFields() []string {
	return []string{
		"Start",
		"End",
	}
}

func (r *LockRange) beforeSave() {}

// +checklocksignore
func (r *LockRange) StateSave(stateSinkObject state.Sink) {
	r.beforeSave()
	stateSinkObject.Save(0, &r.Start)
	stateSinkObject.Save(1, &r.End)
}

func (r *LockRange) afterLoad(context.Context) {}

// +checklocksignore
func (r *LockRange) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &r.Start)
	stateSourceObject.Load(1, &r.End)
}

func (s *LockSet) StateTypeName() string {
	return "pkg/sentry/fsimpl/lock.LockSet"
}

func (s *LockSet) StateFields() []string {
	return []string{
		"root",
	}
}

func (s *LockSet) beforeSave() {}

// +checklocksignore
func (s *LockSet) StateSave(stateSinkObject state.Sink) {
	s.beforeSave()
	var rootValue []LockFlatSegment
	rootValue = s.saveRoot()
	stateSinkObject.SaveValue(0, rootValue)
}

func (s *LockSet) afterLoad(context.Context) {}

// +checklocksignore
func (s *LockSet) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.LoadValue(0, new([]LockFlatSegment), func(y any) { s.loadRoot(ctx, y.([]LockFlatSegment)) })
}

func (n *Locknode) StateTypeName() string {
	return "pkg/sentry/fsimpl/lock.Locknode"
}

func (n *Locknode) StateFields() []string {
	return []string{
		"nrSegments",
		"parent",
		"parentIndex",
		"hasChildren",
		"maxGap",
		"keys",
		"values",
		"children",
	}
}

func (n *Locknode) beforeSave() {}

// +checklocksignore
func (n *Locknode) StateSave(stateSinkObject state.Sink) {
	n.beforeSave()
	stateSinkObject.Save(0, &n.nrSegments)
	stateSinkObject.Save(1, &n.parent)
	stateSinkObject.Save(2, &n.parentIndex)
	stateSinkObject.Save(3, &n.hasChildren)
	stateSinkObject.Save(4, &n.maxGap)
	stateSinkObject.Save(5, &n.keys)
	stateSinkObject.Save(6, &n.values)
	stateSinkObject.Save(7, &n.children)
}

func (n *Locknode) afterLoad(context.Context) {}

// +checklocksignore
func (n *Locknode) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &n.nrSegments)
	stateSourceObject.Load(1, &n.parent)
	stateSourceObject.Load(2, &n.parentIndex)
	stateSourceObject.Load(3, &n.hasChildren)
	stateSourceObject.Load(4, &n.maxGap)
	stateSourceObject.Load(5, &n.keys)
	stateSourceObject.Load(6, &n.values)
	stateSourceObject.Load(7, &n.children)
}

func (l *LockFlatSegment) StateTypeName() string {
	return "pkg/sentry/fsimpl/lock.LockFlatSegment"
}

func (l *LockFlatSegment) StateFields() []string {
	return []string{
		"Start",
		"End",
		"Value",
	}
}

func (l *LockFlatSegment) beforeSave() {}

// +checklocksignore
func (l *LockFlatSegment) StateSave(stateSinkObject state.Sink) {
	l.beforeSave()
	stateSinkObject.Save(0, &l.Start)
	stateSinkObject.Save(1, &l.End)
	stateSinkObject.Save(2, &l.Value)
}

func (l *LockFlatSegment) afterLoad(context.Context) {}

// +checklocksignore
func (l *LockFlatSegment) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &l.Start)
	stateSourceObject.Load(1, &l.End)
	stateSourceObject.Load(2, &l.Value)
}

func init() {
	state.Register((*OwnerInfo)(nil))
	state.Register((*Lock)(nil))
	state.Register((*Locks)(nil))
	state.Register((*LockRange)(nil))
	state.Register((*LockSet)(nil))
	state.Register((*Locknode)(nil))
	state.Register((*LockFlatSegment)(nil))
}
