diff --git a/util_ptr_arith.go b/util_ptr_arith.go index 7192fa8..7767488 100644 --- a/util_ptr_arith.go +++ b/util_ptr_arith.go @@ -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()) } diff --git a/util_ptr_arith_test.go b/util_ptr_arith_test.go index 27f50fb..b8c33c8 100644 --- a/util_ptr_arith_test.go +++ b/util_ptr_arith_test.go @@ -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()) } }