github.com/eh-steve/goloader@v0.0.0-20240111193454-90ff3cfdae39/mmap/zsyscall_6.go (about)

     1  //go:build linux || freebsd
     2  // +build linux freebsd
     3  
     4  package mmap
     5  
     6  import (
     7  	"syscall"
     8  )
     9  
    10  func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
    11  	r0, _, e1 := syscall.Syscall6(syscall.SYS_MMAP, addr, length, uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset))
    12  	xaddr = r0
    13  	if e1 != 0 {
    14  		err = errnoErr(e1)
    15  	}
    16  	return
    17  }
    18  
    19  func munmap(addr uintptr, length uintptr) (err error) {
    20  	_, _, e1 := syscall.Syscall(syscall.SYS_MUNMAP, addr, length, 0)
    21  	if e1 != 0 {
    22  		err = errnoErr(e1)
    23  	}
    24  	return
    25  }