// SPDX-License-Identifier: BSD-3-Clause
//go:build openbsd

package load

import (
	"fmt"
	"unsafe"

	"golang.org/x/sys/unix"
)

func getForkStat() (forkstat, error) {
	b, err := unix.SysctlRaw("kern.forkstat")
	if err != nil {
		return forkstat{}, err
	}
	if len(b) < int(unsafe.Sizeof(forkstat{})) {
		return forkstat{}, fmt.Errorf("unexpected size: kern.forkstat, %d", len(b))
	}
	return *(*forkstat)(unsafe.Pointer((&b[0]))), nil
}
