diff options
author | Russ Cox <rsc@golang.org> | 2009-06-01 22:14:57 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2009-06-01 22:14:57 -0700 |
commit | 0d2eb8d007cef0e2d96d0ad39cea8b59e0a4336c (patch) | |
tree | 1de95562bcec61caf68813011ee5e5536e6059cf /src/lib/syscall/syscall.go | |
parent | 9849d463b66c597d5e2429274e677030c4465484 (diff) | |
download | golang-0d2eb8d007cef0e2d96d0ad39cea8b59e0a4336c.tar.gz |
new syscall package: manually maintained files and scripts.
auto-generated files and deletions are in another CL.
goals for new syscall:
* automate as much as possible
* do not let clients do unsafe things
* use simple types (int not int64)
* fewer files
the files are renamed from foo_amd64_linux to foo_linux_amd64,
both because it reads better (all the linux are related, all the amd64 less so)
and because it made it easier to replace the existing ones.
R=r
DELTA=2336 (2260 added, 6 deleted, 70 changed)
OCL=29709
CL=29723
Diffstat (limited to 'src/lib/syscall/syscall.go')
-rw-r--r-- | src/lib/syscall/syscall.go | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/lib/syscall/syscall.go b/src/lib/syscall/syscall.go index 93611c86e..5ee44e3e8 100644 --- a/src/lib/syscall/syscall.go +++ b/src/lib/syscall/syscall.go @@ -11,22 +11,27 @@ // the manuals for the appropriate operating system. package syscall -/* - * Foundation of system call interface. - */ +import ( + "syscall"; + "unsafe"; +) -func Syscall(trap int64, a1, a2, a3 int64) (r1, r2, err int64); -func Syscall6(trap int64, a1, a2, a3, a4, a5, a6 int64) (r1, r2, err int64); -func RawSyscall(trap int64, a1, a2, a3 int64) (r1, r2, err int64); +func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) +func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) +func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) -/* - * Used to convert file names to byte arrays for passing to kernel, - * but useful elsewhere too. - */ -func StringBytePtr(s string) *byte { +// StringByteSlice returns a NUL-terminated slice of bytes +// containing the text of s. +func StringByteSlice(s string) []byte { a := make([]byte, len(s)+1); for i := 0; i < len(s); i++ { a[i] = s[i]; } - return &a[0]; + return a; +} + +// StringBytePtr returns a pointer to a NUL-terminated array of bytes +// containing the text of s. +func StringBytePtr(s string) *byte { + return &StringByteSlice(s)[0]; } |