diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-04-07 17:09:10 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-04-07 17:09:10 +0000 |
commit | 405ca10418216fc078ecb29ff13a39c911e8d806 (patch) | |
tree | 39c2c0da7b6c220dd344f134fae07fba0d0266b2 /libgo/syscalls/syscall_unix.go | |
parent | a751005d50fa7347131660e562c5fd9ce3dff75d (diff) | |
download | gcc-405ca10418216fc078ecb29ff13a39c911e8d806.zip gcc-405ca10418216fc078ecb29ff13a39c911e8d806.tar.gz gcc-405ca10418216fc078ecb29ff13a39c911e8d806.tar.bz2 |
libgo: Update to current Go library.
From-SVN: r172106
Diffstat (limited to 'libgo/syscalls/syscall_unix.go')
-rw-r--r-- | libgo/syscalls/syscall_unix.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libgo/syscalls/syscall_unix.go b/libgo/syscalls/syscall_unix.go index a29b6b5..b5a660e 100644 --- a/libgo/syscalls/syscall_unix.go +++ b/libgo/syscalls/syscall_unix.go @@ -4,6 +4,8 @@ package syscall +import "unsafe" + var ( Stdin = 0 Stdout = 1 @@ -22,3 +24,35 @@ func Uname(buf *Utsname) (errno int) { } return } + +var mapper = &mmapper{ + active: make(map[*byte][]byte), + mmap: mmap, + munmap: munmap, +} + +func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, errno int) { + return mapper.Mmap(fd, offset, length, prot, flags) +} + +func Munmap(b []byte) (errno int) { + return mapper.Munmap(b) +} + +func libc_munmap(*byte, Size_t) int __asm__ ("munmap") + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, errno int) { + r0 := libc_mmap((*byte)(unsafe.Pointer(addr)), Size_t(length), prot, flag, fd, Offset_t(pos)) + ret = uintptr(unsafe.Pointer(r0)) + if ret + 1 == 0 { + errno = GetErrno() + } + return +} + +func munmap(addr uintptr, length uintptr) (errno int) { + if libc_munmap((*byte)(unsafe.Pointer(addr)), Size_t(length)) < 0 { + errno = GetErrno() + } + return +} |