aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime/go-varargs.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2015-10-07 17:22:08 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2015-10-07 17:22:08 +0000
commit0786e1fe8688691332e6c4f9aab82956546073c5 (patch)
treedfed1026d5397402b85feef171a5e9c2c1ff4dae /libgo/runtime/go-varargs.c
parent919e06d3f59f9770be5e3968159a46f6c077c9f8 (diff)
downloadgcc-0786e1fe8688691332e6c4f9aab82956546073c5.zip
gcc-0786e1fe8688691332e6c4f9aab82956546073c5.tar.gz
gcc-0786e1fe8688691332e6c4f9aab82956546073c5.tar.bz2
re PR go/67874 (fd_unix.go does not build when there is fcntl64 and no fcntl syscall)
PR go/67874 net, runtime: Call C library fcntl function rather than syscall.Syscall. Not all systems define a fcntl syscall; some only have fcntl64. Fixes GCC PR go/67874. Reviewed-on: https://go-review.googlesource.com/15497 From-SVN: r228576
Diffstat (limited to 'libgo/runtime/go-varargs.c')
-rw-r--r--libgo/runtime/go-varargs.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/libgo/runtime/go-varargs.c b/libgo/runtime/go-varargs.c
index 705f55e..7a2006f 100644
--- a/libgo/runtime/go-varargs.c
+++ b/libgo/runtime/go-varargs.c
@@ -6,6 +6,8 @@
#include "config.h"
+#include <errno.h>
+#include <stdint.h>
#include <sys/types.h>
#include <fcntl.h>
@@ -32,6 +34,28 @@ __go_fcntl_flock (int fd, int cmd, struct flock *arg)
return fcntl (fd, cmd, arg);
}
+// This is for the net package. We use uintptr_t to make sure that
+// the types match, since the Go and C "int" types are not the same.
+struct go_fcntl_ret {
+ uintptr_t r;
+ uintptr_t err;
+};
+
+struct go_fcntl_ret
+__go_fcntl_uintptr (uintptr_t fd, uintptr_t cmd, uintptr_t arg)
+{
+ int r;
+ struct go_fcntl_ret ret;
+
+ r = fcntl ((int) fd, (int) cmd, (int) arg);
+ ret.r = (uintptr_t) r;
+ if (r < 0)
+ ret.err = (uintptr_t) errno;
+ else
+ ret.err = 0;
+ return ret;
+}
+
#ifdef HAVE_OPEN64
int