diff options
| author | Andrew Wilkins <axwalk@gmail.com> | 2016-03-15 05:36:43 +0000 |
|---|---|---|
| committer | Andrew Wilkins <axwalk@gmail.com> | 2016-03-15 05:36:43 +0000 |
| commit | 6436a4abd7a2f3a60b230453295dba199d8a59c3 (patch) | |
| tree | 125aef80fc2cf46c5d1758a8ece1fde14e7b13fd /llgo/third_party/gofrontend/libgo/go/os/file_unix.go | |
| parent | 36761bf92427846ce40fdd849615732c852e44dd (diff) | |
| download | bcm5719-llvm-6436a4abd7a2f3a60b230453295dba199d8a59c3.tar.gz bcm5719-llvm-6436a4abd7a2f3a60b230453295dba199d8a59c3.zip | |
[llgo] Roll gofrontend forward
Switch gofrontend to using go.googlesource.com, and
update to 81eb6a3f425b2158c67ee32c0cc973a72ce9d6be.
There are various changes required to update to the
go 1.5 runtime:
typemap.go is changed to accommodate the change in representation for equal/hash algorithms, and the removal of the zero value/type.
CMakeLists.txt is updated to add the build tree to the package search path, so internal packages, which are not installed, are found.
various files changes due to removal of __go_new_nopointers; the same change as in D11863, but with NoUnwindAttribute added to the added runtime functions which are called with "callOnly".
minor cleanups in ssa.go while investigating issues with unwinding/panic handling.
Differential Revisision: http://reviews.llvm.org/D15188
llvm-svn: 263536
Diffstat (limited to 'llgo/third_party/gofrontend/libgo/go/os/file_unix.go')
| -rw-r--r-- | llgo/third_party/gofrontend/libgo/go/os/file_unix.go | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/llgo/third_party/gofrontend/libgo/go/os/file_unix.go b/llgo/third_party/gofrontend/libgo/go/os/file_unix.go index b25e62ff003..7a18987d283 100644 --- a/llgo/third_party/gofrontend/libgo/go/os/file_unix.go +++ b/llgo/third_party/gofrontend/libgo/go/os/file_unix.go @@ -12,6 +12,14 @@ import ( "syscall" ) +func rename(oldname, newname string) error { + e := syscall.Rename(oldname, newname) + if e != nil { + return &LinkError{"rename", oldname, newname, e} + } + return nil +} + // File represents an open file descriptor. type File struct { *file @@ -73,12 +81,24 @@ const DevNull = "/dev/null" // (O_RDONLY etc.) and perm, (0666 etc.) if applicable. If successful, // methods on the returned File can be used for I/O. // If there is an error, it will be of type *PathError. -func OpenFile(name string, flag int, perm FileMode) (file *File, err error) { +func OpenFile(name string, flag int, perm FileMode) (*File, error) { + chmod := false + if !supportsCreateWithStickyBit && flag&O_CREATE != 0 && perm&ModeSticky != 0 { + if _, err := Stat(name); IsNotExist(err) { + chmod = true + } + } + r, e := syscall.Open(name, flag|syscall.O_CLOEXEC, syscallMode(perm)) if e != nil { return nil, &PathError{"open", name, e} } + // open(2) itself won't handle the sticky bit on *BSD and Solaris + if chmod { + Chmod(name, perm) + } + // There's a race here with fork/exec, which we are // content to live with. See ../syscall/exec_unix.go. if !supportsCloseOnExec { @@ -126,12 +146,12 @@ func (file *file) close() error { // Stat returns the FileInfo structure describing file. // If there is an error, it will be of type *PathError. -func (f *File) Stat() (fi FileInfo, err error) { +func (f *File) Stat() (FileInfo, error) { if f == nil { return nil, ErrInvalid } var stat syscall.Stat_t - err = syscall.Fstat(f.fd, &stat) + err := syscall.Fstat(f.fd, &stat) if err != nil { return nil, &PathError{"stat", f.name, err} } @@ -140,9 +160,9 @@ func (f *File) Stat() (fi FileInfo, err error) { // Stat returns a FileInfo describing the named file. // If there is an error, it will be of type *PathError. -func Stat(name string) (fi FileInfo, err error) { +func Stat(name string) (FileInfo, error) { var stat syscall.Stat_t - err = syscall.Stat(name, &stat) + err := syscall.Stat(name, &stat) if err != nil { return nil, &PathError{"stat", name, err} } @@ -153,9 +173,9 @@ func Stat(name string) (fi FileInfo, err error) { // If the file is a symbolic link, the returned FileInfo // describes the symbolic link. Lstat makes no attempt to follow the link. // If there is an error, it will be of type *PathError. -func Lstat(name string) (fi FileInfo, err error) { +func Lstat(name string) (FileInfo, error) { var stat syscall.Stat_t - err = syscall.Lstat(name, &stat) + err := syscall.Lstat(name, &stat) if err != nil { return nil, &PathError{"lstat", name, err} } |

