diff options
author | 2024-10-02 10:58:20 +0000 | |
---|---|---|
committer | 2024-10-02 10:58:20 +0000 | |
commit | c17abea92162f0ac1ccfff4223e26eac431c1198 (patch) | |
tree | ac9809f327136590a5c239c8f9594c1fea1ad989 /vendor/codeberg.org/gruf/go-structr/runtime.go | |
parent | [chore]: Bump go.uber.org/automaxprocs from 1.5.3 to 1.6.0 (#3376) (diff) | |
download | gotosocial-c17abea92162f0ac1ccfff4223e26eac431c1198.tar.xz |
update go-structr to v0.8.11 (#3380)
Diffstat (limited to 'vendor/codeberg.org/gruf/go-structr/runtime.go')
-rw-r--r-- | vendor/codeberg.org/gruf/go-structr/runtime.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/vendor/codeberg.org/gruf/go-structr/runtime.go b/vendor/codeberg.org/gruf/go-structr/runtime.go index d2bdba380..6e8af83dd 100644 --- a/vendor/codeberg.org/gruf/go-structr/runtime.go +++ b/vendor/codeberg.org/gruf/go-structr/runtime.go @@ -2,7 +2,10 @@ package structr import ( "fmt" + "os" "reflect" + "runtime" + "strings" "unicode" "unicode/utf8" "unsafe" @@ -182,7 +185,32 @@ func deref(p unsafe.Pointer, n uint) unsafe.Pointer { return p } +// eface_data returns the data ptr from an empty interface. +func eface_data(a any) unsafe.Pointer { + type eface struct{ _, data unsafe.Pointer } + return (*eface)(unsafe.Pointer(&a)).data +} + // panicf provides a panic with string formatting. func panicf(format string, args ...any) { panic(fmt.Sprintf(format, args...)) } + +// should_not_reach can be called to indicated a +// block of code should not be able to be reached, +// else it prints callsite info with a BUG report. +// +//go:noinline +func should_not_reach() { + pcs := make([]uintptr, 1) + _ = runtime.Callers(2, pcs) + fn := runtime.FuncForPC(pcs[0]) + funcname := "go-structr" // by default use just our library name + if fn != nil { + funcname = fn.Name() + if i := strings.LastIndexByte(funcname, '/'); i != -1 { + funcname = funcname[i+1:] + } + } + os.Stderr.WriteString("BUG: assertion failed in " + funcname + "\n") +} |