mirror of
https://github.com/ii64/gouring.git
synced 2025-04-22 20:25:13 +02:00
Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
4937c09d11 | |||
b60c5ed2ba | |||
3409c752f2 | |||
|
4ed8bc99bd | ||
d0c4e7f98f | |||
aad8211d3e |
6 changed files with 46 additions and 4 deletions
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2022 gouring Author
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
13
hdr_test.go
Normal file
13
hdr_test.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
package gouring
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestDataSize(t *testing.T) {
|
||||
|
||||
assert.Equal(t, 64, int(SizeofIoUringSqe), "sqe data size mismatch")
|
||||
assert.Equal(t, 16, int(SizeofIoUringCqe), "cqe data size mismatch")
|
||||
}
|
4
queue.go
4
queue.go
|
@ -234,7 +234,7 @@ func (ring *IoUring) io_uring_wait_cqes_new(cqePtr **IoUringCqe, waitNtr uint32,
|
|||
func (ring *IoUring) __io_uring_submit_timeout(waitNr uint32, ts *syscall.Timespec) (ret int, err error) {
|
||||
sqe := ring.io_uring_get_sqe()
|
||||
if sqe == nil {
|
||||
ret, err = ring.io_uringn_submit()
|
||||
ret, err = ring.io_uring_submit()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ func (ring *IoUring) io_uring_wait_cqe_timeout(cqePtr **IoUringCqe, ts *syscall.
|
|||
*
|
||||
* Returns number of sqes submitted
|
||||
*/
|
||||
func (ring *IoUring) io_uringn_submit() (int, error) {
|
||||
func (ring *IoUring) io_uring_submit() (int, error) {
|
||||
return ring.__io_uring_submit_and_wait(0)
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ func TestRingQueueSubmitSingleConsumer(t *testing.T) {
|
|||
}
|
||||
|
||||
submit := func(t *testing.T, opt *IoUringParams, h *IoUring, expectedSubmitCount int) {
|
||||
submitted, err := h.io_uringn_submit()
|
||||
submitted, err := h.io_uring_submit()
|
||||
assert.NoError(t, err)
|
||||
if opt.Flags&IORING_SETUP_SQPOLL == 0 {
|
||||
assert.Equal(t, expectedSubmitCount, submitted)
|
||||
|
|
2
uring.go
2
uring.go
|
@ -40,7 +40,7 @@ func (h *IoUring) SeenCqe(cqe *IoUringCqe) {
|
|||
}
|
||||
|
||||
func (h *IoUring) Submit() (int, error) {
|
||||
return h.io_uringn_submit()
|
||||
return h.io_uring_submit()
|
||||
}
|
||||
|
||||
func (h *IoUring) SubmitAndWait(waitNr uint32) (int, error) {
|
||||
|
|
|
@ -16,6 +16,10 @@ func ioUringSqeArray_Index(u ioUringSqeArray, i uintptr) *IoUringSqe {
|
|||
return (*IoUringSqe)(unsafe.Pointer(uintptr(unsafe.Pointer(u)) + SizeofIoUringSqe*i))
|
||||
}
|
||||
|
||||
func ioUringSqe128Array_Index(u ioUringSqeArray, i uintptr) *IoUringSqe {
|
||||
return (*IoUringSqe)(unsafe.Pointer(uintptr(unsafe.Pointer(u)) + (SizeofIoUringSqe+64)*i))
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
type ioUringCqeArray = unsafe.Pointer // *IoUringCqe
|
||||
|
@ -24,6 +28,10 @@ func ioUringCqeArray_Index(u ioUringCqeArray, i uintptr) *IoUringCqe {
|
|||
return (*IoUringCqe)(unsafe.Pointer(uintptr(unsafe.Pointer(u)) + SizeofIoUringCqe*i))
|
||||
}
|
||||
|
||||
func ioUringCqe32Array_Index(u ioUringCqeArray, i uintptr) *IoUringCqe {
|
||||
return (*IoUringCqe)(unsafe.Pointer(uintptr(unsafe.Pointer(u)) + (SizeofIoUringCqe+SizeofIoUringCqe)*i))
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
type UserData [8]byte // uint64
|
||||
|
|
Loading…
Add table
Reference in a new issue