gouring/util_union.go
Nugraha d28b913247
all: initial files
Signed-off-by: Nugraha <richiisei@gmail.com>
2022-07-05 04:52:54 +07:00

87 lines
3.6 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)) }
//
func putUnsafe(ptr unsafe.Pointer, v unsafe.Pointer) {
*(*unsafe.Pointer)(ptr) = v
}
func putUintptr(ptr unsafe.Pointer, v uintptr) {
*(*uintptr)(ptr) = v
}
func putUint64(ptr unsafe.Pointer, v uint64) {
*(*uint64)(ptr) = v
}
func putUint32(ptr unsafe.Pointer, v uint32) {
*(*uint32)(ptr) = v
}
func putUint16(ptr unsafe.Pointer, v uint16) {
*(*uint16)(ptr) = v
}
func putUint8(ptr unsafe.Pointer, v uint8) {
*(*uint8)(ptr) = v
}
func putInt64(ptr unsafe.Pointer, v int64) {
*(*int64)(ptr) = v
}
func putInt32(ptr unsafe.Pointer, v int32) {
*(*int32)(ptr) = v
}
func putInt16(ptr unsafe.Pointer, v int16) {
*(*int16)(ptr) = v
}
func putInt8(ptr unsafe.Pointer, v int8) {
*(*int8)(ptr) = v
}