diff --git a/net/uring/capability_linux.go b/net/uring/capability_linux.go new file mode 100644 index 000000000..ea8a96765 --- /dev/null +++ b/net/uring/capability_linux.go @@ -0,0 +1,20 @@ +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 +} diff --git a/net/uring/io_uring_test.go b/net/uring/io_uring_test.go new file mode 100644 index 000000000..983638e39 --- /dev/null +++ b/net/uring/io_uring_test.go @@ -0,0 +1,11 @@ +// +build linux + +package uring + +import ( + "testing" +) + +func TestUringAvailable(t *testing.T) { + uringSupported() +}