Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / libgo / syscalls / sysfile_linux.go
blob3e77e900cafd3b9671780502296d4703adf7550e
1 // sysfile_linux.go -- Linux specific file handling.
3 // Copyright 2010 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Support for basic Unix file operations. This file simply
8 // translates from Go data types to Unix data types, and handles
9 // errno. FIXME: This could probably be done mechanically.
11 package syscall
13 const OS = "linux"
15 func libc_pread(fd int, buf *byte, count Size_t, offset Offset_t) Ssize_t __asm__ ("pread64")
16 func libc_pwrite(fd int, buf *byte, count Size_t, offset Offset_t) Ssize_t __asm__ ("pwrite64")
17 func libc_lseek64(int, Offset_t, int) Offset_t __asm__ ("lseek64")
18 func libc_truncate64(path *byte, length Offset_t) int __asm__ ("truncate64")
19 func libc_ftruncate64(fd int, length Offset_t) int __asm__ ("ftruncate64")
20 func libc_setgroups(size Size_t, list *Gid_t) int __asm__ ("setgroups")
22 func Sleep(nsec int64) (errno int) {
23 tv := NsecToTimeval(nsec);
24 n, err := Select(0, nil, nil, nil, &tv);
25 return err;
28 func Setgroups(gids []int) (errno int) {
29 if len(gids) == 0 {
30 return libc_setgroups(0, nil);
33 a := make([]Gid_t, len(gids));
34 for i, v := range gids {
35 a[i] = Gid_t(v);
37 return libc_setgroups(Size_t(len(a)), &a[0]);