mirror of
https://github.com/ii64/gouring.git
synced 2025-04-01 03:41:44 +02:00
feat(syscall): add madvise, epollctl
Signed-off-by: Nugraha <26342994+ii64@users.noreply.github.com>
This commit is contained in:
parent
c232c10e24
commit
50fd85fabc
3 changed files with 33 additions and 2 deletions
|
@ -2,6 +2,7 @@ package syscall
|
|||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/ii64/gouring"
|
||||
)
|
||||
|
@ -9,7 +10,10 @@ import (
|
|||
var _ = syscall.EpollCtl
|
||||
|
||||
// EpollCtl
|
||||
func EpollCtl(sqe *gouring.SQEntry, epfd int, op int, fd int, event *syscall.EpollEvent) (err error) {
|
||||
func EpollCtl(sqe *gouring.SQEntry, epfd int, op int, fd int, event *syscall.EpollEvent) {
|
||||
sqe.Opcode = gouring.IORING_OP_EPOLL_CTL
|
||||
return nil
|
||||
sqe.Fd = int32(epfd)
|
||||
*sqe.Addr() = uint64(uintptr(unsafe.Pointer(event)))
|
||||
sqe.Len = uint32(op)
|
||||
*sqe.Offset() = uint64(fd)
|
||||
}
|
||||
|
|
|
@ -5,5 +5,7 @@ import (
|
|||
_ "unsafe"
|
||||
)
|
||||
|
||||
var _zero uintptr
|
||||
|
||||
//go:linkname anyToSockaddr syscall.anyToSockaddr
|
||||
func anyToSockaddr(rsa *syscall.RawSockaddrAny) (syscall.Sockaddr, error)
|
||||
|
|
25
syscall/mem.go
Normal file
25
syscall/mem.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package syscall
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/ii64/gouring"
|
||||
)
|
||||
|
||||
var _ = syscall.Madvise
|
||||
|
||||
// Madvise
|
||||
func Madvise(sqe *gouring.SQEntry, b []byte, advice int) {
|
||||
var ptr unsafe.Pointer
|
||||
if len(b) > 0 {
|
||||
ptr = unsafe.Pointer(&b[0])
|
||||
} else {
|
||||
ptr = unsafe.Pointer(&_zero)
|
||||
}
|
||||
sqe.Opcode = gouring.IORING_OP_MADVISE
|
||||
sqe.Fd = -1
|
||||
*sqe.Addr() = uint64(uintptr(ptr))
|
||||
sqe.Len = uint32(len(b))
|
||||
*sqe.Offset() = 0
|
||||
}
|
Loading…
Add table
Reference in a new issue