gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

mmap_linux_32.go (1223B)


      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 
      5 //go:build linux && (386 || arm || mips || mipsle)
      6 // +build linux
      7 // +build 386 arm mips mipsle
      8 
      9 package memory
     10 
     11 import (
     12 	"syscall"
     13 )
     14 
     15 // Function syscall.mmap and syscall.mmap2 are same for linux/386, linux/arm,
     16 // linux/mips and linux/mipsle
     17 
     18 // https://cs.opensource.google/go/go/+/refs/tags/go1.17.8:src/syscall/syscall_linux_386.go;l=99-105
     19 func mmapSyscall(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
     20 	page := uintptr(offset / 4096)
     21 	if offset != int64(page)*4096 {
     22 		return 0, syscall.EINVAL
     23 	}
     24 	return mmap2Syscall(addr, length, prot, flags, fd, page)
     25 }
     26 
     27 // https://cs.opensource.google/go/go/+/refs/tags/go1.17.8:src/syscall/zsyscall_linux_386.go;l=1361-1370
     28 func mmap2Syscall(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) {
     29 	r0, _, e1 := syscall.Syscall6(syscall.SYS_MMAP2, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(pageOffset))
     30 	xaddr = uintptr(r0)
     31 	if e1 != 0 {
     32 		err = e1
     33 	}
     34 	return
     35 }