OSDN Git Service

libgo http/cgi: Pass down environment variables for irix and solaris.
[pf3gnuchains/gcc-fork.git] / libgo / syscalls / syscall_unix.go
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 file.
4
5 package syscall
6
7 import "unsafe"
8
9 var (
10         Stdin  = 0
11         Stdout = 1
12         Stderr = 2
13 )
14
15 const ENONE = 0
16
17 func GetErrno() int
18 func SetErrno(int)
19
20 func Uname(buf *Utsname) (errno int) {
21         r := libc_uname(buf)
22         if r < 0 {
23                 errno = GetErrno()
24         }
25         return
26 }
27
28 var mapper = &mmapper{
29         active: make(map[*byte][]byte),
30         mmap:   mmap,
31         munmap: munmap,
32 }
33
34 func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, errno int) {
35         return mapper.Mmap(fd, offset, length, prot, flags)
36 }
37
38 func Munmap(b []byte) (errno int) {
39         return mapper.Munmap(b)
40 }
41
42 func libc_munmap(*byte, Size_t) int __asm__ ("munmap")
43
44 func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, errno int) {
45         r0 := libc_mmap((*byte)(unsafe.Pointer(addr)), Size_t(length), prot, flag, fd, Offset_t(pos))
46         ret = uintptr(unsafe.Pointer(r0))
47         if ret + 1 == 0 {
48                 errno = GetErrno()
49         }
50         return
51 }
52
53 func munmap(addr uintptr, length uintptr) (errno int) {
54         if libc_munmap((*byte)(unsafe.Pointer(addr)), Size_t(length)) < 0 {
55                 errno = GetErrno()
56         }
57         return
58 }