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:
parent
4937c09d11
commit
8d37b05bc1
2 changed files with 6 additions and 2 deletions
|
@ -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())
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue