gouring/util_union.go
Nugraha 7eedf9754b
all: use of unsafe pointer for ring, and adjustments
There's other adjustment/addition:
 * Function name CQE/SQE renamed to Cqe/Sqe.
 * SQ entry union sets value withput util to reduce function
   complexity, so leaving function budget for another stuff.
 * UserData has its own type, implement for uint64, uintptr,
   and unsafe.
 * TODO: decide what to use `Syscall` or `RawSyscall`.
 * Exposed `SeenCqe`.
 * Ignore *.test file extension.
 * Inline cost tool.

Signed-off-by: Nugraha <richiisei@gmail.com>
2022-07-28 19:45:51 +07:00

52 lines
2.9 KiB
Go

package gouring
import "unsafe"
type union64 [8]byte
func (u *union64) PutUnsafe(v unsafe.Pointer) { putUnsafe(unsafe.Pointer(u), v) }
func (u *union64) PutUintptr(v uintptr) { putUintptr(unsafe.Pointer(u), v) }
func (u *union64) PutUint64(v uint64) { putUint64(unsafe.Pointer(u), v) }
func (u *union64) PutUint32(v uint32) { putUint32(unsafe.Pointer(u), v) }
func (u *union64) PutUint16(v uint16) { putUint16(unsafe.Pointer(u), v) }
func (u *union64) PutUint8(v uint8) { putUint8(unsafe.Pointer(u), v) }
func (u *union64) PutInt32(v int32) { putInt32(unsafe.Pointer(u), v) }
func (u *union64) Unsafe() unsafe.Pointer { return unsafe.Pointer(u) }
func (u *union64) Uint64() uint64 { return *(*uint64)(unsafe.Pointer(u)) }
func (u *union64) Uint32() uint32 { return *(*uint32)(unsafe.Pointer(u)) }
func (u *union64) Uint16() uint16 { return *(*uint16)(unsafe.Pointer(u)) }
func (u *union64) Uint8() uint8 { return *(*uint8)(unsafe.Pointer(u)) }
type union32 [4]byte
func (u *union32) PutUnsafe(v unsafe.Pointer) { putUnsafe(unsafe.Pointer(u), v) }
func (u *union32) PutUintptr(v uintptr) { putUintptr(unsafe.Pointer(u), uintptr(uint32(v))) }
func (u *union32) PutUint64(v uint64) { putUint32(unsafe.Pointer(u), uint32(v)) }
func (u *union32) PutUint32(v uint32) { putUint32(unsafe.Pointer(u), v) }
func (u *union32) PutUint16(v uint16) { putUint16(unsafe.Pointer(u), v) }
func (u *union32) PutUint8(v uint8) { putUint8(unsafe.Pointer(u), v) }
func (u *union32) PutInt32(v int32) { putInt32(unsafe.Pointer(u), v) }
func (u *union32) Unsafe() unsafe.Pointer { return unsafe.Pointer(u) }
func (u *union32) Uint64() uint64 { return *(*uint64)(unsafe.Pointer(u)) }
func (u *union32) Uint32() uint32 { return *(*uint32)(unsafe.Pointer(u)) }
func (u *union32) Uint16() uint16 { return *(*uint16)(unsafe.Pointer(u)) }
func (u *union32) Uint8() uint8 { return *(*uint8)(unsafe.Pointer(u)) }
type union16 [2]byte
func (u *union16) PutUnsafe(v unsafe.Pointer) { putUnsafe(unsafe.Pointer(u), v) }
func (u *union16) PutUintptr(v uintptr) { putUintptr(unsafe.Pointer(u), uintptr(uint16(v))) }
func (u *union16) PutUint64(v uint64) { putUint16(unsafe.Pointer(u), uint16(v)) }
func (u *union16) PutUint32(v uint32) { putUint16(unsafe.Pointer(u), uint16(v)) }
func (u *union16) PutUint16(v uint16) { putUint16(unsafe.Pointer(u), v) }
func (u *union16) PutUint8(v uint8) { putUint8(unsafe.Pointer(u), v) }
func (u *union16) Unsafe() unsafe.Pointer { return unsafe.Pointer(u) }
func (u *union16) Uint64() uint64 { return *(*uint64)(unsafe.Pointer(u)) }
func (u *union16) Uint32() uint32 { return *(*uint32)(unsafe.Pointer(u)) }
func (u *union16) Uint16() uint16 { return *(*uint16)(unsafe.Pointer(u)) }
func (u *union16) Uint8() uint8 { return *(*uint8)(unsafe.Pointer(u)) }