1
0
Fork 0
mirror of https://github.com/ii64/gouring.git synced 2025-04-01 03:41:44 +02:00

fix: change base type of UserData to uint64

This commit is contained in:
Xeffy Chen 2022-10-13 22:03:46 +07:00
parent 4937c09d11
commit 8d37b05bc1
Signed by: Xeffy
GPG key ID: E41C08AD390E7C49
2 changed files with 6 additions and 2 deletions

View file

@ -34,7 +34,7 @@ func ioUringCqe32Array_Index(u ioUringCqeArray, i uintptr) *IoUringCqe {
//
type UserData [8]byte // uint64
type UserData uint64
func (u *UserData) SetUint64(v uint64) {
putUintptr(unsafe.Pointer(u), uintptr(v))
@ -50,6 +50,9 @@ func (u *UserData) SetUnsafe(ptr unsafe.Pointer) {
func (u UserData) GetUnsafe() unsafe.Pointer {
return *(*unsafe.Pointer)(unsafe.Pointer(&u))
}
func (u UserData) GetBytes() [8]byte {
return *(*[8]byte)(u.GetUnsafe())
}
func (u UserData) GetUintptr() uintptr {
return uintptr(u.GetUnsafe())
}

View file

@ -39,6 +39,7 @@ func TestUserdata(t *testing.T) {
var exp [8]byte
bo.PutUint64(exp[:], tc.exp)
assert.Equal(t, exp[:], u[:])
// assert.Equal(t, exp[:], u[:])
assert.Equal(t, tc.exp, u.GetUint64())
}
}