diff options
| author | Rutger Broekhoff | 2023-12-29 21:31:53 +0100 |
|---|---|---|
| committer | Rutger Broekhoff | 2023-12-29 21:31:53 +0100 |
| commit | 404aeae4545d2426c089a5f8d5e82dae56f5212b (patch) | |
| tree | 2d84e00af272b39fc04f3795ae06bc48970e57b5 /vendor/github.com/modern-go/reflect2/unsafe_ptr.go | |
| parent | 209d8b0187ed025dec9ac149ebcced3462877bff (diff) | |
| download | gitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.tar.gz gitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.zip | |
Make Nix builds work
Diffstat (limited to 'vendor/github.com/modern-go/reflect2/unsafe_ptr.go')
| -rw-r--r-- | vendor/github.com/modern-go/reflect2/unsafe_ptr.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/vendor/github.com/modern-go/reflect2/unsafe_ptr.go b/vendor/github.com/modern-go/reflect2/unsafe_ptr.go new file mode 100644 index 0000000..8e5ec9c --- /dev/null +++ b/vendor/github.com/modern-go/reflect2/unsafe_ptr.go | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | package reflect2 | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "reflect" | ||
| 5 | "unsafe" | ||
| 6 | ) | ||
| 7 | |||
| 8 | type UnsafePtrType struct { | ||
| 9 | unsafeType | ||
| 10 | } | ||
| 11 | |||
| 12 | func newUnsafePtrType(cfg *frozenConfig, type1 reflect.Type) *UnsafePtrType { | ||
| 13 | return &UnsafePtrType{ | ||
| 14 | unsafeType: *newUnsafeType(cfg, type1), | ||
| 15 | } | ||
| 16 | } | ||
| 17 | |||
| 18 | func (type2 *UnsafePtrType) IsNil(obj interface{}) bool { | ||
| 19 | if obj == nil { | ||
| 20 | return true | ||
| 21 | } | ||
| 22 | objEFace := unpackEFace(obj) | ||
| 23 | assertType("Type.IsNil argument 1", type2.ptrRType, objEFace.rtype) | ||
| 24 | return type2.UnsafeIsNil(objEFace.data) | ||
| 25 | } | ||
| 26 | |||
| 27 | func (type2 *UnsafePtrType) UnsafeIsNil(ptr unsafe.Pointer) bool { | ||
| 28 | if ptr == nil { | ||
| 29 | return true | ||
| 30 | } | ||
| 31 | return *(*unsafe.Pointer)(ptr) == nil | ||
| 32 | } | ||
| 33 | |||
| 34 | func (type2 *UnsafePtrType) LikePtr() bool { | ||
| 35 | return true | ||
| 36 | } | ||
| 37 | |||
| 38 | func (type2 *UnsafePtrType) Indirect(obj interface{}) interface{} { | ||
| 39 | objEFace := unpackEFace(obj) | ||
| 40 | assertType("Type.Indirect argument 1", type2.ptrRType, objEFace.rtype) | ||
| 41 | return type2.UnsafeIndirect(objEFace.data) | ||
| 42 | } | ||
| 43 | |||
| 44 | func (type2 *UnsafePtrType) UnsafeIndirect(ptr unsafe.Pointer) interface{} { | ||
| 45 | return packEFace(type2.rtype, *(*unsafe.Pointer)(ptr)) | ||
| 46 | } | ||