summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-kv/v2/format/abi.go
blob: 16b9c8cb9181676e44e37083fa3bed1d4bbff84b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//go:build go1.24 && !go1.26

package format

import (
	"reflect"
	"unsafe"

	"codeberg.org/gruf/go-xunsafe"
)

// add returns the ptr addition of starting ptr and a delta.
func add(ptr unsafe.Pointer, delta uintptr) unsafe.Pointer {
	return unsafe.Pointer(uintptr(ptr) + delta)
}

// typeof is short-hand for reflect.TypeFor[T]().
func typeof[T any]() reflect.Type {
	return reflect.TypeFor[T]()
}

const (
	// custom xunsafe.Reflect_flag to indicate key types.
	flagKeyType xunsafe.Reflect_flag = 1 << 10
)