Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(799)

Side by Side Diff: libgo/syscalls/sysfile_posix.go

Issue 4035044: code review 4035044: Update to current version of Go library. (Closed)
Patch Set: Created 14 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « libgo/syscalls/socket.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // sysfile_posix.go -- POSIX File handling. 1 // sysfile_posix.go -- POSIX File handling.
2 2
3 // Copyright 2010 The Go Authors. All rights reserved. 3 // Copyright 2010 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style 4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file. 5 // license that can be found in the LICENSE file.
6 6
7 // Support for basic Unix file operations. This file simply 7 // Support for basic Unix file operations. This file simply
8 // translates from Go data types to Unix data types, and handles 8 // translates from Go data types to Unix data types, and handles
9 // errno. FIXME: This could probably be done mechanically. 9 // errno. FIXME: This could probably be done mechanically.
10 10
11 package syscall 11 package syscall
12 12
13 import "unsafe" 13 import "unsafe"
14 14
15 func libc_open(name *byte, mode int, perm Mode_t) int __asm__ ("open"); 15 func libc_open(name *byte, mode int, perm Mode_t) int __asm__ ("open");
16 func libc_close(fd int) int __asm__ ("close"); 16 func libc_close(fd int) int __asm__ ("close");
17 func libc_read(fd int, buf *byte, count Size_t) Ssize_t __asm__ ("read"); 17 func libc_read(fd int, buf *byte, count Size_t) Ssize_t __asm__ ("read");
18 func libc_write(fd int, buf *byte, count Size_t) Ssize_t __asm__ ("write"); 18 func libc_write(fd int, buf *byte, count Size_t) Ssize_t __asm__ ("write");
19 func libc_fsync(fd int) int __asm__ ("fsync")
19 func libc_pipe(filedes *int) int __asm__("pipe"); 20 func libc_pipe(filedes *int) int __asm__("pipe");
20 func libc_stat(name *byte, buf *Stat_t) int __asm__ ("stat"); 21 func libc_stat(name *byte, buf *Stat_t) int __asm__ ("stat");
21 func libc_fstat(fd int, buf *Stat_t) int __asm__ ("fstat"); 22 func libc_fstat(fd int, buf *Stat_t) int __asm__ ("fstat");
22 func libc_lstat(name *byte, buf *Stat_t) int __asm__ ("lstat"); 23 func libc_lstat(name *byte, buf *Stat_t) int __asm__ ("lstat");
23 func libc_unlink(name *byte) int __asm__ ("unlink"); 24 func libc_unlink(name *byte) int __asm__ ("unlink");
24 func libc_rmdir(name *byte) int __asm__ ("rmdir"); 25 func libc_rmdir(name *byte) int __asm__ ("rmdir");
25 func libc_fcntl(fd int, cmd int, arg int) int __asm__ ("fcntl"); 26 func libc_fcntl(fd int, cmd int, arg int) int __asm__ ("fcntl");
26 func libc_mkdir(name *byte, perm Mode_t) int __asm__ ("mkdir"); 27 func libc_mkdir(name *byte, perm Mode_t) int __asm__ ("mkdir");
27 func libc_dup(int) int __asm__ ("dup") 28 func libc_dup(int) int __asm__ ("dup")
28 func libc_gettimeofday(tv *Timeval, tz *byte) int __asm__ ("gettimeofday"); 29 func libc_gettimeofday(tv *Timeval, tz *byte) int __asm__ ("gettimeofday");
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 81
81 func Write(fd int, p []byte) (n int, errno int) { 82 func Write(fd int, p []byte) (n int, errno int) {
82 var _p0 *byte; 83 var _p0 *byte;
83 if len(p) > 0 { _p0 = &p[0]; } 84 if len(p) > 0 { _p0 = &p[0]; }
84 r := libc_write(fd, _p0, Size_t(len(p))); 85 r := libc_write(fd, _p0, Size_t(len(p)));
85 if r == -1 { errno = GetErrno() } 86 if r == -1 { errno = GetErrno() }
86 n = int(r); 87 n = int(r);
87 return; 88 return;
88 } 89 }
89 90
91 func Fsync(fd int) (errno int) {
92 if libc_fsync(fd) < 0 {
93 errno = GetErrno()
94 }
95 return
96 }
97
90 func Pread(fd int, p []byte, offset int64) (n int, errno int) { 98 func Pread(fd int, p []byte, offset int64) (n int, errno int) {
91 var _p0 *byte; 99 var _p0 *byte;
92 if len(p) > 0 { _p0 = &p[0]; } 100 if len(p) > 0 { _p0 = &p[0]; }
93 r := libc_pread(fd, _p0, Size_t(len(p)), Offset_t(offset)); 101 r := libc_pread(fd, _p0, Size_t(len(p)), Offset_t(offset));
94 if r == -1 { errno = GetErrno() } 102 if r == -1 { errno = GetErrno() }
95 n = int(r); 103 n = int(r);
96 return; 104 return;
97 } 105 }
98 106
99 func Pwrite(fd int, p []byte, offset int64) (n int, errno int) { 107 func Pwrite(fd int, p []byte, offset int64) (n int, errno int) {
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 return int(libc_getppid()); 421 return int(libc_getppid());
414 } 422 }
415 423
416 func Kill(pid int, sig int) (errno int) { 424 func Kill(pid int, sig int) (errno int) {
417 r := libc_kill(Pid_t(pid), sig) 425 r := libc_kill(Pid_t(pid), sig)
418 if r < 0 { 426 if r < 0 {
419 errno = GetErrno() 427 errno = GetErrno()
420 } 428 }
421 return 429 return
422 } 430 }
OLDNEW
« no previous file with comments | « libgo/syscalls/socket.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b