github.com/iceber/iouring-go@v0.0.0-20230403020409-002cfd2e2a90/fixed_buffers.go (about) 1 // +build linux 2 3 package iouring 4 5 import ( 6 "errors" 7 "unsafe" 8 9 iouring_syscall "github.com/iceber/iouring-go/syscall" 10 ) 11 12 func (iour *IOURing) RegisterBuffers(bs [][]byte) error { 13 if len(bs) == 0 { 14 return errors.New("buffer is empty") 15 } 16 17 iovecs := bytes2iovec(bs) 18 bp := unsafe.Pointer(&iovecs[0]) 19 20 return iouring_syscall.IOURingRegister(iour.fd, iouring_syscall.IORING_REGISTER_BUFFERS, bp, uint32(len(iovecs))) 21 } 22 23 func (iour *IOURing) UnRegisterBuffers() error { 24 return iouring_syscall.IOURingRegister(iour.fd, iouring_syscall.IORING_UNREGISTER_BUFFERS, nil, 0) 25 }