diff --git a/libbpfgo.go b/libbpfgo.go index 5b7613c5..d13e16dc 100644 --- a/libbpfgo.go +++ b/libbpfgo.go @@ -2089,3 +2089,11 @@ func BPFProgramTypeIsSupported(progType BPFProgType) (bool, error) { } return cSupported == 1, nil } + +func NumPossibleCPUs() (int, error) { + numCPUs, _ := C.libbpf_num_possible_cpus() + if numCPUs < 0 { + return 0, fmt.Errorf("failed to retrieve the number of CPUs") + } + return int(numCPUs), nil +}