]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgo/syscalls/sysfile_linux.go
Add Go frontend, libgo library, and Go testsuite.
[thirdparty/gcc.git] / libgo / syscalls / sysfile_linux.go
1 // sysfile_linux.go -- Linux specific file handling.
2
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.
6
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.
10
11 package syscall
12
13 const OS = "linux"
14
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")
21
22 func Sleep(nsec int64) (errno int) {
23 tv := NsecToTimeval(nsec);
24 n, err := Select(0, nil, nil, nil, &tv);
25 return err;
26 }
27
28 func Setgroups(gids []int) (errno int) {
29 if len(gids) == 0 {
30 return libc_setgroups(0, nil);
31 }
32
33 a := make([]Gid_t, len(gids));
34 for i, v := range gids {
35 a[i] = Gid_t(v);
36 }
37 return libc_setgroups(Size_t(len(a)), &a[0]);
38 }