OSDN Git Service

syscall: Portability code for epoll_event on GNU/Linux.
[pf3gnuchains/gcc-fork.git] / libgo / go / syscall / syscall.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 contains an interface to the low-level operating system
6 // primitives.  The details vary depending on the underlying system.
7 // Its primary use is inside other packages that provide a more portable
8 // interface to the system, such as "os", "time" and "net".  Use those
9 // packages rather than this one if you can.
10 // For details of the functions and data types in this package consult
11 // the manuals for the appropriate operating system.
12 // These calls return errno == 0 to indicate success; otherwise
13 // errno is an operating system error number describing the failure.
14 package syscall
15
16 import "unsafe"
17
18 // StringByteSlice returns a NUL-terminated slice of bytes
19 // containing the text of s.
20 func StringByteSlice(s string) []byte {
21         a := make([]byte, len(s)+1)
22         copy(a, s)
23         return a
24 }
25
26 // StringBytePtr returns a pointer to a NUL-terminated array of bytes
27 // containing the text of s.
28 func StringBytePtr(s string) *byte { return &StringByteSlice(s)[0] }
29
30 // Single-word zero for use when we need a valid pointer to 0 bytes.
31 // See mksyscall.pl.
32 var _zero uintptr
33
34 var dummy *byte
35 const sizeofPtr uintptr = uintptr(unsafe.Sizeof(dummy))