mmap_linux_64.go 896 B

1234567891011121314151617181920212223242526
  1. // Copyright 2009 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE-GO file.
  4. //go:build linux && (amd64 || arm64 || mips64 || mips64le || riscv64 || ppc64le)
  5. // +build linux
  6. // +build amd64 arm64 mips64 mips64le riscv64 ppc64le
  7. package memory
  8. import (
  9. "syscall"
  10. )
  11. // Function syscall.mmap is same for linux/amd64, linux/arm64, linux/mips64,
  12. // linux/mips64le and linux/riscv64.
  13. // https://cs.opensource.google/go/go/+/refs/tags/go1.17.8:src/syscall/zsyscall_linux_amd64.go;l=1575-1584
  14. func mmapSyscall(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
  15. r0, _, e1 := syscall.Syscall6(syscall.SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset))
  16. xaddr = uintptr(r0)
  17. if e1 != 0 {
  18. err = e1
  19. }
  20. return
  21. }