// automatically generated by stateify.

package refs

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

func (x *WeakRef) beforeSave() {}
func (x *WeakRef) save(m state.Map) {
	x.beforeSave()
	var obj savedReference = x.saveObj()
	m.SaveValue("obj", obj)
	m.Save("user", &x.user)
}

func (x *WeakRef) afterLoad() {}
func (x *WeakRef) load(m state.Map) {
	m.Load("user", &x.user)
	m.LoadValue("obj", new(savedReference), func(y interface{}) { x.loadObj(y.(savedReference)) })
}

func (x *AtomicRefCount) beforeSave() {}
func (x *AtomicRefCount) save(m state.Map) {
	x.beforeSave()
	m.Save("refCount", &x.refCount)
	m.Save("name", &x.name)
	m.Save("stack", &x.stack)
}

func (x *AtomicRefCount) afterLoad() {}
func (x *AtomicRefCount) load(m state.Map) {
	m.Load("refCount", &x.refCount)
	m.Load("name", &x.name)
	m.Load("stack", &x.stack)
}

func (x *savedReference) beforeSave() {}
func (x *savedReference) save(m state.Map) {
	x.beforeSave()
	m.Save("obj", &x.obj)
}

func (x *savedReference) afterLoad() {}
func (x *savedReference) load(m state.Map) {
	m.Load("obj", &x.obj)
}

func (x *weakRefList) beforeSave() {}
func (x *weakRefList) save(m state.Map) {
	x.beforeSave()
	m.Save("head", &x.head)
	m.Save("tail", &x.tail)
}

func (x *weakRefList) afterLoad() {}
func (x *weakRefList) load(m state.Map) {
	m.Load("head", &x.head)
	m.Load("tail", &x.tail)
}

func (x *weakRefEntry) beforeSave() {}
func (x *weakRefEntry) save(m state.Map) {
	x.beforeSave()
	m.Save("next", &x.next)
	m.Save("prev", &x.prev)
}

func (x *weakRefEntry) afterLoad() {}
func (x *weakRefEntry) load(m state.Map) {
	m.Load("next", &x.next)
	m.Load("prev", &x.prev)
}

func init() {
	state.Register("pkg/refs.WeakRef", (*WeakRef)(nil), state.Fns{Save: (*WeakRef).save, Load: (*WeakRef).load})
	state.Register("pkg/refs.AtomicRefCount", (*AtomicRefCount)(nil), state.Fns{Save: (*AtomicRefCount).save, Load: (*AtomicRefCount).load})
	state.Register("pkg/refs.savedReference", (*savedReference)(nil), state.Fns{Save: (*savedReference).save, Load: (*savedReference).load})
	state.Register("pkg/refs.weakRefList", (*weakRefList)(nil), state.Fns{Save: (*weakRefList).save, Load: (*weakRefList).load})
	state.Register("pkg/refs.weakRefEntry", (*weakRefEntry)(nil), state.Fns{Save: (*weakRefEntry).save, Load: (*weakRefEntry).load})
}