net/uring: add probing capability

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 <[email protected]>
This commit is contained in:
kadmin authored and Josh Bleecher Snyder committed 2021-07-13 15:15:16 -07:00
1 parent c0deb1c65e
commit 07374071d0
2 files changed
+31

No files matched your search

+20
View File
@@ -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
}
+11
View File
@@ -0,0 +1,11 @@
// +build linux
package uring
import (
"testing"
)
func TestUringAvailable(t *testing.T) {
uringSupported()
}