-3039d79149901d25d89c2412bdd8684f3cbcd09e
+651e71a729e5dcbd9dc14c1b59b6eff05bfe3d26
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
return netfd, nil
}
+// Use a helper function to call fcntl. This is defined in C in
+// libgo/runtime.
+//extern __go_fcntl_uintptr
+func fcntl(uintptr, uintptr, uintptr) (uintptr, uintptr)
+
// tryDupCloexec indicates whether F_DUPFD_CLOEXEC should be used.
// If the kernel doesn't support it, this is set to 0.
var tryDupCloexec = int32(1)
func dupCloseOnExec(fd int) (newfd int, err error) {
if atomic.LoadInt32(&tryDupCloexec) == 1 && syscall.F_DUPFD_CLOEXEC != 0 {
- r0, _, e1 := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd), syscall.F_DUPFD_CLOEXEC, 0)
+ syscall.Entersyscall()
+ r0, errno := fcntl(uintptr(fd), syscall.F_DUPFD_CLOEXEC, 0)
+ syscall.Exitsyscall()
+ e1 := syscall.Errno(errno)
if runtime.GOOS == "darwin" && e1 == syscall.EBADF {
// On OS X 10.6 and below (but we only support
// >= 10.6), F_DUPFD_CLOEXEC is unsupported
#include "config.h"
+#include <errno.h>
+#include <stdint.h>
#include <sys/types.h>
#include <fcntl.h>
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