mirror of
https://github.com/tailscale/tailscale.git
synced 2026-04-04 06:36:01 -04:00
Adds the ability to probe for various capabilities. It will not call into C unless necessary. It also allocates one probe per call to new capability, which may be expensive, so in theory they could be reused instead. Signed-off-by: kadmin <julianknodt@gmail.com>
21 lines
435 B
Go
21 lines
435 B
Go
package uring
|
|
|
|
// #cgo CFLAGS: -I${SRCDIR}/liburing/src/include
|
|
// #cgo LDFLAGS: -L${SRCDIR}/liburing/src/ -luring
|
|
// #include "io_uring.c"
|
|
import "C"
|
|
|
|
import (
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
// hasUring reports whether it is possible to use io_uring syscalls on the system.
|
|
func uringSupported() bool {
|
|
probe, err := C.io_uring_get_probe()
|
|
if err == nil && probe != nil {
|
|
C.free(unsafe.Pointer(probe))
|
|
}
|
|
return err != syscall.ENOSYS
|
|
}
|