mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 12:52:25 -05:00 
			
		
		
		
	[chore]: Bump github.com/KimMachineGun/automemlimit from 0.2.4 to 0.2.5 (#1666)
Bumps [github.com/KimMachineGun/automemlimit](https://github.com/KimMachineGun/automemlimit) from 0.2.4 to 0.2.5. - [Release notes](https://github.com/KimMachineGun/automemlimit/releases) - [Commits](https://github.com/KimMachineGun/automemlimit/compare/v0.2.4...v0.2.5) --- updated-dependencies: - dependency-name: github.com/KimMachineGun/automemlimit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
		
					parent
					
						
							
								3f9b2336c0
							
						
					
				
			
			
				commit
				
					
						57dc742c76
					
				
			
		
					 200 changed files with 16392 additions and 38190 deletions
				
			
		
							
								
								
									
										83
									
								
								vendor/github.com/cilium/ebpf/marshalers.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										83
									
								
								vendor/github.com/cilium/ebpf/marshalers.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -8,9 +8,11 @@ import ( | |||
| 	"fmt" | ||||
| 	"reflect" | ||||
| 	"runtime" | ||||
| 	"sync" | ||||
| 	"unsafe" | ||||
| 
 | ||||
| 	"github.com/cilium/ebpf/internal" | ||||
| 	"github.com/cilium/ebpf/internal/sys" | ||||
| ) | ||||
| 
 | ||||
| // marshalPtr converts an arbitrary value into a pointer suitable | ||||
|  | @ -18,17 +20,17 @@ import ( | |||
| // | ||||
| // As an optimization, it returns the original value if it is an | ||||
| // unsafe.Pointer. | ||||
| func marshalPtr(data interface{}, length int) (internal.Pointer, error) { | ||||
| func marshalPtr(data interface{}, length int) (sys.Pointer, error) { | ||||
| 	if ptr, ok := data.(unsafe.Pointer); ok { | ||||
| 		return internal.NewPointer(ptr), nil | ||||
| 		return sys.NewPointer(ptr), nil | ||||
| 	} | ||||
| 
 | ||||
| 	buf, err := marshalBytes(data, length) | ||||
| 	if err != nil { | ||||
| 		return internal.Pointer{}, err | ||||
| 		return sys.Pointer{}, err | ||||
| 	} | ||||
| 
 | ||||
| 	return internal.NewSlicePointer(buf), nil | ||||
| 	return sys.NewSlicePointer(buf), nil | ||||
| } | ||||
| 
 | ||||
| // marshalBytes converts an arbitrary value into a byte buffer. | ||||
|  | @ -39,6 +41,10 @@ func marshalPtr(data interface{}, length int) (internal.Pointer, error) { | |||
| // Returns an error if the given value isn't representable in exactly | ||||
| // length bytes. | ||||
| func marshalBytes(data interface{}, length int) (buf []byte, err error) { | ||||
| 	if data == nil { | ||||
| 		return nil, errors.New("can't marshal a nil value") | ||||
| 	} | ||||
| 
 | ||||
| 	switch value := data.(type) { | ||||
| 	case encoding.BinaryMarshaler: | ||||
| 		buf, err = value.MarshalBinary() | ||||
|  | @ -68,29 +74,32 @@ func marshalBytes(data interface{}, length int) (buf []byte, err error) { | |||
| 	return buf, nil | ||||
| } | ||||
| 
 | ||||
| func makeBuffer(dst interface{}, length int) (internal.Pointer, []byte) { | ||||
| func makeBuffer(dst interface{}, length int) (sys.Pointer, []byte) { | ||||
| 	if ptr, ok := dst.(unsafe.Pointer); ok { | ||||
| 		return internal.NewPointer(ptr), nil | ||||
| 		return sys.NewPointer(ptr), nil | ||||
| 	} | ||||
| 
 | ||||
| 	buf := make([]byte, length) | ||||
| 	return internal.NewSlicePointer(buf), buf | ||||
| 	return sys.NewSlicePointer(buf), buf | ||||
| } | ||||
| 
 | ||||
| var bytesReaderPool = sync.Pool{ | ||||
| 	New: func() interface{} { | ||||
| 		return new(bytes.Reader) | ||||
| 	}, | ||||
| } | ||||
| 
 | ||||
| // unmarshalBytes converts a byte buffer into an arbitrary value. | ||||
| // | ||||
| // Prefer using Map.unmarshalKey and Map.unmarshalValue if possible, since | ||||
| // those have special cases that allow more types to be encoded. | ||||
| // | ||||
| // The common int32 and int64 types are directly handled to avoid | ||||
| // unnecessary heap allocations as happening in the default case. | ||||
| func unmarshalBytes(data interface{}, buf []byte) error { | ||||
| 	switch value := data.(type) { | ||||
| 	case unsafe.Pointer: | ||||
| 		sh := &reflect.SliceHeader{ | ||||
| 			Data: uintptr(value), | ||||
| 			Len:  len(buf), | ||||
| 			Cap:  len(buf), | ||||
| 		} | ||||
| 
 | ||||
| 		dst := *(*[]byte)(unsafe.Pointer(sh)) | ||||
| 		dst := unsafe.Slice((*byte)(value), len(buf)) | ||||
| 		copy(dst, buf) | ||||
| 		runtime.KeepAlive(value) | ||||
| 		return nil | ||||
|  | @ -104,12 +113,38 @@ func unmarshalBytes(data interface{}, buf []byte) error { | |||
| 	case *[]byte: | ||||
| 		*value = buf | ||||
| 		return nil | ||||
| 	case *int32: | ||||
| 		if len(buf) < 4 { | ||||
| 			return errors.New("int32 requires 4 bytes") | ||||
| 		} | ||||
| 		*value = int32(internal.NativeEndian.Uint32(buf)) | ||||
| 		return nil | ||||
| 	case *uint32: | ||||
| 		if len(buf) < 4 { | ||||
| 			return errors.New("uint32 requires 4 bytes") | ||||
| 		} | ||||
| 		*value = internal.NativeEndian.Uint32(buf) | ||||
| 		return nil | ||||
| 	case *int64: | ||||
| 		if len(buf) < 8 { | ||||
| 			return errors.New("int64 requires 8 bytes") | ||||
| 		} | ||||
| 		*value = int64(internal.NativeEndian.Uint64(buf)) | ||||
| 		return nil | ||||
| 	case *uint64: | ||||
| 		if len(buf) < 8 { | ||||
| 			return errors.New("uint64 requires 8 bytes") | ||||
| 		} | ||||
| 		*value = internal.NativeEndian.Uint64(buf) | ||||
| 		return nil | ||||
| 	case string: | ||||
| 		return errors.New("require pointer to string") | ||||
| 	case []byte: | ||||
| 		return errors.New("require pointer to []byte") | ||||
| 	default: | ||||
| 		rd := bytes.NewReader(buf) | ||||
| 		rd := bytesReaderPool.Get().(*bytes.Reader) | ||||
| 		rd.Reset(buf) | ||||
| 		defer bytesReaderPool.Put(rd) | ||||
| 		if err := binary.Read(rd, internal.NativeEndian, value); err != nil { | ||||
| 			return fmt.Errorf("decoding %T: %v", value, err) | ||||
| 		} | ||||
|  | @ -123,38 +158,38 @@ func unmarshalBytes(data interface{}, buf []byte) error { | |||
| // Values are initialized to zero if the slice has less elements than CPUs. | ||||
| // | ||||
| // slice must have a type like []elementType. | ||||
| func marshalPerCPUValue(slice interface{}, elemLength int) (internal.Pointer, error) { | ||||
| func marshalPerCPUValue(slice interface{}, elemLength int) (sys.Pointer, error) { | ||||
| 	sliceType := reflect.TypeOf(slice) | ||||
| 	if sliceType.Kind() != reflect.Slice { | ||||
| 		return internal.Pointer{}, errors.New("per-CPU value requires slice") | ||||
| 		return sys.Pointer{}, errors.New("per-CPU value requires slice") | ||||
| 	} | ||||
| 
 | ||||
| 	possibleCPUs, err := internal.PossibleCPUs() | ||||
| 	if err != nil { | ||||
| 		return internal.Pointer{}, err | ||||
| 		return sys.Pointer{}, err | ||||
| 	} | ||||
| 
 | ||||
| 	sliceValue := reflect.ValueOf(slice) | ||||
| 	sliceLen := sliceValue.Len() | ||||
| 	if sliceLen > possibleCPUs { | ||||
| 		return internal.Pointer{}, fmt.Errorf("per-CPU value exceeds number of CPUs") | ||||
| 		return sys.Pointer{}, fmt.Errorf("per-CPU value exceeds number of CPUs") | ||||
| 	} | ||||
| 
 | ||||
| 	alignedElemLength := align(elemLength, 8) | ||||
| 	alignedElemLength := internal.Align(elemLength, 8) | ||||
| 	buf := make([]byte, alignedElemLength*possibleCPUs) | ||||
| 
 | ||||
| 	for i := 0; i < sliceLen; i++ { | ||||
| 		elem := sliceValue.Index(i).Interface() | ||||
| 		elemBytes, err := marshalBytes(elem, elemLength) | ||||
| 		if err != nil { | ||||
| 			return internal.Pointer{}, err | ||||
| 			return sys.Pointer{}, err | ||||
| 		} | ||||
| 
 | ||||
| 		offset := i * alignedElemLength | ||||
| 		copy(buf[offset:offset+elemLength], elemBytes) | ||||
| 	} | ||||
| 
 | ||||
| 	return internal.NewSlicePointer(buf), nil | ||||
| 	return sys.NewSlicePointer(buf), nil | ||||
| } | ||||
| 
 | ||||
| // unmarshalPerCPUValue decodes a buffer into a slice containing one value per | ||||
|  | @ -210,7 +245,3 @@ func unmarshalPerCPUValue(slicePtr interface{}, elemLength int, buf []byte) erro | |||
| 	reflect.ValueOf(slicePtr).Elem().Set(slice) | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func align(n, alignment int) int { | ||||
| 	return (int(n) + alignment - 1) / alignment * alignment | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue