aboutsummaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2017-12-16 01:45:45 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2017-12-16 01:45:45 +0000
commitfe6272cc446f327c8e72c0c99aebd69fe9672c21 (patch)
tree6f28e29ad1612736e6c4437ac5d5a215b6fc05dd /libgo
parentdead5b9978dc169e846a726a6538b165a5c00274 (diff)
downloadgcc-fe6272cc446f327c8e72c0c99aebd69fe9672c21.zip
gcc-fe6272cc446f327c8e72c0c99aebd69fe9672c21.tar.gz
gcc-fe6272cc446f327c8e72c0c99aebd69fe9672c21.tar.bz2
syscall: emulate Flock on AIX
Reviewed-on: https://go-review.googlesource.com/79095 From-SVN: r255737
Diffstat (limited to 'libgo')
-rw-r--r--libgo/go/syscall/libcall_aix.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/libgo/go/syscall/libcall_aix.go b/libgo/go/syscall/libcall_aix.go
index 072f92a..5afc65e 100644
--- a/libgo/go/syscall/libcall_aix.go
+++ b/libgo/go/syscall/libcall_aix.go
@@ -111,6 +111,28 @@ func Reboot(how int) (err error) {
//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
//fchownat(dirfd _C_int, path *byte, owner Uid_t, group Gid_t, flags _C_int) _C_int
+// On AIX, there is no flock() system call, we emulate it.
+func Flock(fd int, op int) (err error) {
+ lk := &Flock_t{}
+ if (op & LOCK_UN) != 0 {
+ lk.Type = F_UNLCK
+ } else if (op & LOCK_EX) != 0 {
+ lk.Type = F_WRLCK
+ } else if (op & LOCK_SH) != 0 {
+ lk.Type = F_RDLCK
+ } else {
+ return nil
+ }
+ if (op & LOCK_NB) != 0 {
+ err = FcntlFlock(uintptr(fd), F_SETLK, lk)
+ if err != nil && (err == EAGAIN || err == EACCES) {
+ return EWOULDBLOCK
+ }
+ return err
+ }
+ return FcntlFlock(uintptr(fd), F_SETLKW, lk)
+}
+
//sys Fstatfs(fd int, buf *Statfs_t) (err error)
//fstatfs64(fd _C_int, buf *Statfs_t) _C_int