github.com/sagernet/gvisor@v0.0.0-20240428053021-e691de28565f/pkg/buffer/buffer_state_autogen.go (about) 1 // automatically generated by stateify. 2 3 package buffer 4 5 import ( 6 "context" 7 8 "github.com/sagernet/gvisor/pkg/state" 9 ) 10 11 func (b *Buffer) StateTypeName() string { 12 return "pkg/buffer.Buffer" 13 } 14 15 func (b *Buffer) StateFields() []string { 16 return []string{ 17 "data", 18 "size", 19 } 20 } 21 22 func (b *Buffer) beforeSave() {} 23 24 // +checklocksignore 25 func (b *Buffer) StateSave(stateSinkObject state.Sink) { 26 b.beforeSave() 27 var dataValue []byte 28 dataValue = b.saveData() 29 stateSinkObject.SaveValue(0, dataValue) 30 stateSinkObject.Save(1, &b.size) 31 } 32 33 func (b *Buffer) afterLoad(context.Context) {} 34 35 // +checklocksignore 36 func (b *Buffer) StateLoad(ctx context.Context, stateSourceObject state.Source) { 37 stateSourceObject.Load(1, &b.size) 38 stateSourceObject.LoadValue(0, new([]byte), func(y any) { b.loadData(ctx, y.([]byte)) }) 39 } 40 41 func (c *chunk) StateTypeName() string { 42 return "pkg/buffer.chunk" 43 } 44 45 func (c *chunk) StateFields() []string { 46 return []string{ 47 "chunkRefs", 48 "data", 49 } 50 } 51 52 func (c *chunk) beforeSave() {} 53 54 // +checklocksignore 55 func (c *chunk) StateSave(stateSinkObject state.Sink) { 56 c.beforeSave() 57 stateSinkObject.Save(0, &c.chunkRefs) 58 stateSinkObject.Save(1, &c.data) 59 } 60 61 func (c *chunk) afterLoad(context.Context) {} 62 63 // +checklocksignore 64 func (c *chunk) StateLoad(ctx context.Context, stateSourceObject state.Source) { 65 stateSourceObject.Load(0, &c.chunkRefs) 66 stateSourceObject.Load(1, &c.data) 67 } 68 69 func (r *chunkRefs) StateTypeName() string { 70 return "pkg/buffer.chunkRefs" 71 } 72 73 func (r *chunkRefs) StateFields() []string { 74 return []string{ 75 "refCount", 76 } 77 } 78 79 func (r *chunkRefs) beforeSave() {} 80 81 // +checklocksignore 82 func (r *chunkRefs) StateSave(stateSinkObject state.Sink) { 83 r.beforeSave() 84 stateSinkObject.Save(0, &r.refCount) 85 } 86 87 // +checklocksignore 88 func (r *chunkRefs) StateLoad(ctx context.Context, stateSourceObject state.Source) { 89 stateSourceObject.Load(0, &r.refCount) 90 stateSourceObject.AfterLoad(func() { r.afterLoad(ctx) }) 91 } 92 93 func (v *View) StateTypeName() string { 94 return "pkg/buffer.View" 95 } 96 97 func (v *View) StateFields() []string { 98 return []string{ 99 "read", 100 "write", 101 "chunk", 102 } 103 } 104 105 func (v *View) beforeSave() {} 106 107 // +checklocksignore 108 func (v *View) StateSave(stateSinkObject state.Sink) { 109 v.beforeSave() 110 stateSinkObject.Save(0, &v.read) 111 stateSinkObject.Save(1, &v.write) 112 stateSinkObject.Save(2, &v.chunk) 113 } 114 115 func (v *View) afterLoad(context.Context) {} 116 117 // +checklocksignore 118 func (v *View) StateLoad(ctx context.Context, stateSourceObject state.Source) { 119 stateSourceObject.Load(0, &v.read) 120 stateSourceObject.Load(1, &v.write) 121 stateSourceObject.Load(2, &v.chunk) 122 } 123 124 func (l *ViewList) StateTypeName() string { 125 return "pkg/buffer.ViewList" 126 } 127 128 func (l *ViewList) StateFields() []string { 129 return []string{ 130 "head", 131 "tail", 132 } 133 } 134 135 func (l *ViewList) beforeSave() {} 136 137 // +checklocksignore 138 func (l *ViewList) StateSave(stateSinkObject state.Sink) { 139 l.beforeSave() 140 stateSinkObject.Save(0, &l.head) 141 stateSinkObject.Save(1, &l.tail) 142 } 143 144 func (l *ViewList) afterLoad(context.Context) {} 145 146 // +checklocksignore 147 func (l *ViewList) StateLoad(ctx context.Context, stateSourceObject state.Source) { 148 stateSourceObject.Load(0, &l.head) 149 stateSourceObject.Load(1, &l.tail) 150 } 151 152 func (e *ViewEntry) StateTypeName() string { 153 return "pkg/buffer.ViewEntry" 154 } 155 156 func (e *ViewEntry) StateFields() []string { 157 return []string{ 158 "next", 159 "prev", 160 } 161 } 162 163 func (e *ViewEntry) beforeSave() {} 164 165 // +checklocksignore 166 func (e *ViewEntry) StateSave(stateSinkObject state.Sink) { 167 e.beforeSave() 168 stateSinkObject.Save(0, &e.next) 169 stateSinkObject.Save(1, &e.prev) 170 } 171 172 func (e *ViewEntry) afterLoad(context.Context) {} 173 174 // +checklocksignore 175 func (e *ViewEntry) StateLoad(ctx context.Context, stateSourceObject state.Source) { 176 stateSourceObject.Load(0, &e.next) 177 stateSourceObject.Load(1, &e.prev) 178 } 179 180 func init() { 181 state.Register((*Buffer)(nil)) 182 state.Register((*chunk)(nil)) 183 state.Register((*chunkRefs)(nil)) 184 state.Register((*View)(nil)) 185 state.Register((*ViewList)(nil)) 186 state.Register((*ViewEntry)(nil)) 187 }