mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
syscall: add Mmap, Munmap on Linux, FreeBSD, OS X
* tweak mksyscall*.pl to be more gofmt-compatible. * add mkall.sh -syscalls option. * add sys/mman.h constants on OS X R=r, eds, niemeyer CC=golang-dev https://golang.org/cl/4369044
This commit is contained in:
parent
c45a08e5ba
commit
48ae1f2d9b
22 changed files with 343 additions and 16 deletions
|
|
@ -56,6 +56,16 @@ func NsecToTimeval(nsec int64) (tv Timeval) {
|
|||
//sysnb setgroups(n int, list *_Gid_t) (errno int) = SYS_SETGROUPS32
|
||||
//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, errno int) = SYS__NEWSELECT
|
||||
|
||||
//sys mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, errno int)
|
||||
|
||||
func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, errno int) {
|
||||
page := uintptr(offset / 4096)
|
||||
if offset != int64(page)*4096 {
|
||||
return 0, EINVAL
|
||||
}
|
||||
return mmap2(addr, length, prot, flags, fd, page)
|
||||
}
|
||||
|
||||
// Underlying system call writes to newoffset via pointer.
|
||||
// Implemented in assembly to avoid allocation.
|
||||
func Seek(fd int, offset int64, whence int) (newoffset int64, errno int)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue