diff --git a/hdr.go b/hdr.go index e105c58..a619ceb 100644 --- a/hdr.go +++ b/hdr.go @@ -252,8 +252,6 @@ const IORING_SETUP_DEFER_TASKRUN = (1 << 13) type IoUringOp = uint8 -//go:generate stringerx -type=IoUringOp - const ( IORING_OP_NOP IoUringOp = iota IORING_OP_READV @@ -672,7 +670,7 @@ type IoUringProbeOp struct { type IoUringProbe struct { last_op uint8 /* last opcode supported */ - uint8 /* length of ops[] array below */ + ops_len uint8 /* length of ops[] array below */ resv uint16 resv2 [3]uint32 diff --git a/hdr_extra.go b/hdr_extra.go index 1ec9234..9fc699b 100644 --- a/hdr_extra.go +++ b/hdr_extra.go @@ -22,6 +22,9 @@ func (cqe *IoUringCqe) GetBigCqe() unsafe.Pointer { func (probe *IoUringProbe) GetOps() unsafe.Pointer { return unsafe.Add(unsafe.Pointer(probe), SizeofIoUringProbe) } +func (probe *IoUringProbe) GetOpAt(index int) *IoUringProbeOp { + return (*IoUringProbeOp)(unsafe.Add(probe.GetOps(), SizeofIoUringProbeOp*uintptr(index))) +} /* * GetBufs @@ -31,3 +34,6 @@ func (probe *IoUringProbe) GetOps() unsafe.Pointer { func (bring *IoUringBufRing) GetBufs() unsafe.Pointer { return unsafe.Add(unsafe.Pointer(bring), SizeofIoUringBufRing) } +func (bring *IoUringBufRing) GetBufAt(index int) *IoUringBuf { + return (*IoUringBuf)(unsafe.Add(bring.GetBufs(), SizeofIoUringBuf*uintptr(index))) +} diff --git a/hdr_struct.go b/hdr_struct.go index dfa7ab3..2114567 100644 --- a/hdr_struct.go +++ b/hdr_struct.go @@ -13,6 +13,7 @@ const ( SizeofIoUringProbe = unsafe.Sizeof(IoUringProbe{}) SizeofIoUringProbeOp = unsafe.Sizeof(IoUringProbeOp{}) SizeofIoUringBufRing = unsafe.Sizeof(IoUringBufRing{}) + SizeofIoUringBuf = unsafe.Sizeof(IoUringBuf{}) ) func _SizeChecker() { @@ -22,6 +23,7 @@ func _SizeChecker() { _ = x[SizeofIoUringProbe-16] _ = x[SizeofIoUringProbeOp-8] _ = x[SizeofIoUringBufRing-16] + _ = x[SizeofIoUringBuf-16] } type IoUring struct { diff --git a/uring.go b/uring.go index c94aac4..ccd8278 100644 --- a/uring.go +++ b/uring.go @@ -46,3 +46,7 @@ func (h *IoUring) Submit() (int, error) { func (h *IoUring) SubmitAndWait(waitNr uint32) (int, error) { return h.io_uring_submit_and_wait(waitNr) } + +func (h *IoUring) GetProbeRing() *IoUringProbe { + return h.io_uring_get_probe_ring() +}