// automatically generated by stateify.

package shm

import (
	"context"

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

func (r *Registry) StateTypeName() string {
	return "pkg/sentry/kernel/shm.Registry"
}

func (r *Registry) StateFields() []string {
	return []string{
		"userNS",
		"reg",
		"totalPages",
	}
}

func (r *Registry) beforeSave() {}

// +checklocksignore
func (r *Registry) StateSave(stateSinkObject state.Sink) {
	r.beforeSave()
	stateSinkObject.Save(0, &r.userNS)
	stateSinkObject.Save(1, &r.reg)
	stateSinkObject.Save(2, &r.totalPages)
}

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

// +checklocksignore
func (r *Registry) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &r.userNS)
	stateSourceObject.Load(1, &r.reg)
	stateSourceObject.Load(2, &r.totalPages)
}

func (s *Shm) StateTypeName() string {
	return "pkg/sentry/kernel/shm.Shm"
}

func (s *Shm) StateFields() []string {
	return []string{
		"ShmRefs",
		"registry",
		"devID",
		"size",
		"effectiveSize",
		"fr",
		"obj",
		"attachTime",
		"detachTime",
		"changeTime",
		"creatorPID",
		"lastAttachDetachPID",
		"pendingDestruction",
	}
}

func (s *Shm) beforeSave() {}

// +checklocksignore
func (s *Shm) StateSave(stateSinkObject state.Sink) {
	s.beforeSave()
	stateSinkObject.Save(0, &s.ShmRefs)
	stateSinkObject.Save(1, &s.registry)
	stateSinkObject.Save(2, &s.devID)
	stateSinkObject.Save(3, &s.size)
	stateSinkObject.Save(4, &s.effectiveSize)
	stateSinkObject.Save(5, &s.fr)
	stateSinkObject.Save(6, &s.obj)
	stateSinkObject.Save(7, &s.attachTime)
	stateSinkObject.Save(8, &s.detachTime)
	stateSinkObject.Save(9, &s.changeTime)
	stateSinkObject.Save(10, &s.creatorPID)
	stateSinkObject.Save(11, &s.lastAttachDetachPID)
	stateSinkObject.Save(12, &s.pendingDestruction)
}

// +checklocksignore
func (s *Shm) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &s.ShmRefs)
	stateSourceObject.Load(1, &s.registry)
	stateSourceObject.Load(2, &s.devID)
	stateSourceObject.Load(3, &s.size)
	stateSourceObject.Load(4, &s.effectiveSize)
	stateSourceObject.Load(5, &s.fr)
	stateSourceObject.Load(6, &s.obj)
	stateSourceObject.Load(7, &s.attachTime)
	stateSourceObject.Load(8, &s.detachTime)
	stateSourceObject.Load(9, &s.changeTime)
	stateSourceObject.Load(10, &s.creatorPID)
	stateSourceObject.Load(11, &s.lastAttachDetachPID)
	stateSourceObject.Load(12, &s.pendingDestruction)
	stateSourceObject.AfterLoad(func() { s.afterLoad(ctx) })
}

func (r *ShmRefs) StateTypeName() string {
	return "pkg/sentry/kernel/shm.ShmRefs"
}

func (r *ShmRefs) StateFields() []string {
	return []string{
		"refCount",
	}
}

func (r *ShmRefs) beforeSave() {}

// +checklocksignore
func (r *ShmRefs) StateSave(stateSinkObject state.Sink) {
	r.beforeSave()
	stateSinkObject.Save(0, &r.refCount)
}

// +checklocksignore
func (r *ShmRefs) StateLoad(ctx context.Context, stateSourceObject state.Source) {
	stateSourceObject.Load(0, &r.refCount)
	stateSourceObject.AfterLoad(func() { r.afterLoad(ctx) })
}

func init() {
	state.Register((*Registry)(nil))
	state.Register((*Shm)(nil))
	state.Register((*ShmRefs)(nil))
}
