C++ vs. glibc/Hurd/Mach headers

2016-11-25 Thread Thomas Schwinge
Hi!

Motivation for bringing this up again: GDB has recently switched from
using a C to a C++ compiler.  GDB, for obvious reasons, needs to access
low-level Hurd/Mach interfaces.

 "GNU/Hurd headers don't pass c++"
has been closed as "invalid".  Additionally to the issues Samuel pointed
out in 
(still unresolved), I now also ran into:

$ echo -e '#include \n#include \nvoid f(){ error_t err = 
thread_get_state(0,0,0,0); }' | g++ -D_GNU_SOURCE -x c++ - -S -o /dev/null -O2
: In function 'void f()':
:3:41: error: invalid conversion from 'kern_return_t {aka int}' to 
'error_t {aka __error_t_codes}' [-fpermissive]

That is, for Mach API calls such as thread_get_state, their return type
"kern_return_t {aka int}" can't be assigned to (our) error_t type.

The Hurd uses its own "typedef enum __error_t_codes error_t;"
([glibc]/sysdeps/mach/hurd/bits/errno.h), contrary to the default
"typedef int error_t;" ([glibc]/stdlib/errno.h).

Another (inconclusive) discussion thread starts at
, and if I
understand Roland's messages correctly, he has concerns with now changing
the error_t type (for __cplusplus), for compatibility reasons.

Instead of "error_t err = (error_t) thread_get_state([...])", I guess
I'll change such GDB code to plain "int err".

Roland, do you still veto against patches such as Samuel's

()?


Grüße
 Thomas



Hurd port for gcc go PATCH 1-4(23)

2016-11-25 Thread Svante Signell
Hi,

Attached are patches to enable gccgo to build properly on Debian
GNU/Hurd on gcc-6 (6-6.2.1-5).

The first three patches are Debian-specific:

* debian_rules.defs.diff: Enables build of gccgo for GNU/Hurd

Define patches for the generated series file:
* debian_rules.patch.diff:  Enables split-stack support.
* debian_rules.patch.diff:  Does not enable split-stack support.

* src_gcc_config_i386_gnu.h.diff: Enable split-stack support

The test suite results are as follows:
Without split-stack support:
              === go Summary ===
# of expected passes7359
# of unexpected failures7
# of expected failures  1
# of untested testcases 10
# of unsupported tests  2
                === libgo Summary ===
# of expected passes121
# of unexpected failures13

With split-stack support:

                === go Summary ===
# of expected passes7366
# of unexpected failures8
# of expected failures  1
# of untested testcases 6
# of unsupported tests  2
                === libgo Summary ===
# of expected passes120
# of unexpected failures14

All failing go tests and more than half of the libgo tests are runtime
errors due to exception handling not working as expected:
Aborted
runtime_sighandler ...
fatal error: unexpected signal during runtime execution
panic: runtime error: invalid memory address or nil pointer dereference

The above problems are probably due to some remaining issues in
gnumach/hurd/glibc to be solved. According to Samuel Thibault these
problems can be handled late when the patches are accepted upstream or
in Debian gcc. Another more annoying gnumch/hurd/glibc bug is that the
built program go (go-6 in Debian) gets killed when executed from the
shell vi path, but not when issued directly: /usr/bin/go-6 works fine.
 go-6
Segmentation fault (core dumped)
gdb /usr/bin/go-6 -c ./core
warning: Unexpected size of section `.reg2/16883' in core file.
Core was generated by `go-6'.
Program terminated with signal SIGSEGV, Segmentation fault.

warning: Unexpected size of section `.reg2/16883' in core file.
#0  0x01e854ae in ?? ()
(gdb) bt
#0  0x01e854ae in ?? ()
#1  0x in ?? ()

Nevertheless, it seems like not so much is left for gccgo working
properly on GNU/Hurd.

Thanks!

--- a/debian/rules.defs	2014-01-07 11:10:44.0 +0100
+++ b/debian/rules.defs	2014-01-07 11:23:47.0 +0100
@@ -933,7 +933,7 @@
 ifeq (,$(filter $(distrelease),lenny etch squeeze dapper hardy jaunty karmic lucid maverick natty oneiric))
   go_no_cpus := $(filter-out arm, $(go_no_cpus))
 endif
-go_no_systems := gnu kfreebsd-gnu
+go_no_systems := kfreebsd
 
 ifneq ($(with_base_only),yes)
   ifneq ($(separate_lang),yes)
@@ -943,7 +943,7 @@
 ifneq (,$(filter $(DEB_TARGET_ARCH_CPU),$(go_no_cpus)))
   with_go := disabled for cpu $(DEB_TARGET_ARCH_CPU)
 endif
-ifneq (,$(findstring $(DEB_TARGET_GNU_SYSTEM),$(go_no_systems)))
+ifneq (,$(findstring $(DEB_TARGET_ARCH_OS),$(go_no_systems)))
   with_go := disabled for system $(DEB_TARGET_GNU_SYSTEM)
 endif
 ifeq ($(go_no_cross)-$(DEB_CROSS),yes-yes)
--- a/debian/rules.patch.orig	2016-11-12 16:50:46.0 +0100
+++ b/debian/rules.patch	2016-11-12 16:55:24.0 +0100
@@ -276,6 +276,27 @@
 
 ifeq ($(DEB_TARGET_ARCH_OS),hurd)
   debian_patches += hurd-changes
+  debian_patches += \
+ src_gcc_config_i386_gnu.h \
+ src_libgo_configure.ac \
+ src_libgo_go_net_sendfile_gnu.go \
+ src_libgo_go_net_sock_gnu.go \
+ src_libgo_go_net_sockopt_gnu.go \
+ src_libgo_go_net_sockoptip_gnu.go \
+ src_libgo_go_syscall_libcall_gnu_386.go \
+ src_libgo_go_syscall_libcall_gnu.go \
+ src_libgo_go_syscall_libcall_posix-1.go \
+ src_libgo_go_syscall_socket_gnu.go \
+ src_libgo_go_syscall_wait.c \
+ src_libgo_Makefile.am \
+ src_libgo_Makefile.in \
+ src_libgo_mksysinfo.sh \
+ src_libgo_runtime_getncpu-gnu.c \
+ src_libgo_runtime_netpoll.goc \
+		  src_libgo_go_os_os_test.go \
+ src_libgo_go_syscall_syscall_gnu_test.go \
+ src_libgo_testsuite_gotest \
+		  add-gnu-to-libgo-headers
 endif
 
 debian_patches += gcc-ice-dump
--- a/debian/rules.patch.orig	2016-11-12 16:50:46.0 +0100
+++ b/debian/rules.patch	2016-11-12 16:55:24.0 +0100
@@ -276,6 +276,26 @@
 
 ifeq ($(DEB_TARGET_ARCH_OS),hurd)
   debian_patches += hurd-changes
+  debian_patches += \
+ src_libgo_configure.ac \
+ src_libgo_go_net_sendfile_gnu.go \
+ src_libgo_go_net_sock_gnu.go \
+ src_libgo_go_net_sockopt_gnu.go \
+ src_libgo_go_net_sockoptip_gnu.go \
+ src_libgo_go_syscall_libcall_gnu_386.go \
+ src_libgo_go_sysc

Hurd port for gcc go PATCH 5-10(23)

2016-11-25 Thread Svante Signell
* src_libgo_configure.ac.diff: Define GOOS=gnu and LIBGO_IS_GNU
* src_libgo_Makefile.am.diff: Add support for GNU/Hurd.
* src_libgo_Makefile.in.diff: Update accordingly with autreconf2.64
* src_libgo_mksysinfo.sh.diff: Define SYS_IOCTL to 0 if not defined,
 Fix: #define EWOULDBLOCK EAGAIN in 
 Fix: #define st_dev st_fsid in Index: gcc-6-6.2.1-4.1/src/libgo/configure.ac
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/configure.ac
+++ gcc-6-6.2.1-4.1/src/libgo/configure.ac
@@ -151,6 +151,7 @@ is_openbsd=no
 is_dragonfly=no
 is_rtems=no
 is_solaris=no
+is_gnu=no
 GOOS=unknown
 case ${host} in
   *-*-darwin*)   is_darwin=yes;  GOOS=darwin ;;
@@ -162,6 +163,7 @@ case ${host} in
   *-*-dragonfly*) is_dragonfly=yes; GOOS=dragonfly ;;
   *-*-rtems*)is_rtems=yes;   GOOS=rtems ;;
   *-*-solaris2*) is_solaris=yes; GOOS=solaris ;;
+  *-*-gnu*)  is_gnu=yes; GOOS=gnu ;;
 esac
 AM_CONDITIONAL(LIBGO_IS_DARWIN, test $is_darwin = yes)
 AM_CONDITIONAL(LIBGO_IS_FREEBSD, test $is_freebsd = yes)
@@ -172,6 +174,7 @@ AM_CONDITIONAL(LIBGO_IS_OPENBSD, test $i
 AM_CONDITIONAL(LIBGO_IS_DRAGONFLY, test $is_dragonfly = yes)
 AM_CONDITIONAL(LIBGO_IS_RTEMS, test $is_rtems = yes)
 AM_CONDITIONAL(LIBGO_IS_SOLARIS, test $is_solaris = yes)
+AM_CONDITIONAL(LIBGO_IS_GNU, test $is_gnu = yes)
 AC_SUBST(GOOS)
 
 dnl Test whether we need to use DejaGNU or whether we can use the
Index: gcc-6-6.2.1-4.1/src/libgo/go/syscall/wait.c
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/syscall/wait.c
+++ gcc-6-6.2.1-4.1/src/libgo/go/syscall/wait.c
@@ -8,6 +8,9 @@
OS-independent.  */
 
 #include 
+#ifndef WCONTINUED
+#define WCONTINUED 0
+#endif
 #include 
 
 #include "runtime.h"
Index: gcc-6-6.2.1-4.1/src/libgo/Makefile.am
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/Makefile.am
+++ gcc-6-6.2.1-4.1/src/libgo/Makefile.am
@@ -419,6 +419,9 @@ else
 if LIBGO_IS_NETBSD
 runtime_getncpu_file = runtime/getncpu-bsd.c
 else
+if LIBGO_IS_GNU
+runtime_getncpu_file = runtime/getncpu-gnu.c
+else
 runtime_getncpu_file = runtime/getncpu-none.c
 endif
 endif
@@ -426,6 +429,7 @@ endif
 endif
 endif
 endif
+endif
 
 if LIBGO_IS_LINUX
 runtime_netpoll_files = runtime/netpoll_epoll.c
@@ -433,9 +437,13 @@ else
 if LIBGO_IS_SOLARIS
 runtime_netpoll_files = runtime/netpoll_select.c
 else
+if LIBGO_IS_GNU
+runtime_netpoll_files = runtime/netpoll_select.c
+else
 runtime_netpoll_files = runtime/netpoll_kqueue.c
 endif
 endif
+endif
 
 runtime_files = \
 	runtime/go-append.c \
@@ -744,6 +752,14 @@ go_net_sockoptip_file = go/net/sockoptip
 go_net_cgo_sock_file = go/net/cgo_sockold.go
 go_net_cgo_res_file = go/net/cgo_resnew.go
 else
+if LIBGO_IS_GNU
+go_net_cgo_file = go/net/cgo_linux.go
+go_net_sock_file = go/net/sock_gnu.go
+go_net_sockopt_file = go/net/sockopt_gnu.go
+go_net_sockoptip_file = go/net/sockoptip_gnu.go go/net/sockoptip_posix.go
+go_net_cgo_sock_file = go/net/cgo_socknew.go
+go_net_cgo_res_file = go/net/cgo_resnew.go
+else
 go_net_cgo_file = go/net/cgo_bsd.go
 go_net_sock_file = go/net/sock_bsd.go
 go_net_sockopt_file = go/net/sockopt_bsd.go
@@ -755,6 +771,7 @@ endif
 endif
 endif
 endif
+endif
 
 if LIBGO_IS_LINUX
 go_net_sendfile_file = go/net/sendfile_linux.go
@@ -768,11 +785,15 @@ else
 if LIBGO_IS_SOLARIS
 go_net_sendfile_file = go/net/sendfile_solaris.go
 else
+if LIBGO_IS_GNU
+go_net_sendfile_file = go/net/sendfile_gnu.go
+else
 go_net_sendfile_file = go/net/sendfile_stub.go
 endif
 endif
 endif
 endif
+endif
 
 if LIBGO_IS_LINUX
 go_net_interface_file = go/net/interface_linux.go
@@ -794,9 +815,13 @@ else
 if LIBGO_IS_FREEBSD
 go_net_cloexec_file = go/net/sock_cloexec.go go/net/hook_cloexec.go
 else
+if LIBGO_IS_GNU
+go_net_cloexec_file = go/net/sock_cloexec.go go/net/hook_cloexec.go
+else
 go_net_cloexec_file = go/net/sys_cloexec.go
 endif
 endif
+endif
 
 if LIBGO_IS_OPENBSD
 go_net_tcpsockopt_file = go/net/tcpsockopt_openbsd.go
@@ -889,9 +914,13 @@ else
 if LIBGO_IS_LINUX
 go_os_dir_file = go/os/dir_largefile.go
 else
+if LIBGO_IS_GNU
+go_os_dir_file = go/os/dir_largefile.go
+else
 go_os_dir_file = go/os/dir_regfile.go
 endif
 endif
+endif
 
 if LIBGO_IS_DARWIN
 go_os_getwd_file = go/os/getwd_darwin.go
@@ -911,11 +940,15 @@ else
 if LIBGO_IS_RTEMS
 go_os_sys_file = go/os/sys_uname.go
 else
+if LIBGO_IS_GNU
+go_os_sys_file = go/os/sys_uname.go
+else
 go_os_sys_file = go/os/sys_bsd.go
 endif
 endif
 endif
 endif
+endif
 
 if LIBGO_IS_FREEBSD
 go_os_cloexec_file = go/os/sys_freebsd.go
@@ -937,6 +970,9 @@ else
 if LIBGO_IS_LINUX
 go_os_stat_file = go/os/stat_atim.go
 else
+if LIBGO_IS_GNU
+go_os_stat_file = go/os/stat_atim.go
+else
 if LIBGO_IS_OPENBSD
 go_os_stat_file = go/os/stat_atim.go
 else
@@ -960,12 +996,17 @@ endif
 endif
 endif
 endif
+endif
 
 if LIBGO_IS_LINUX
 go_os_pipe_file = go/os/pipe_linux.go
 else
+if LIBGO_IS_GNU
+go_os_pipe_file = go/os/pipe_linux.go
+else
 go_o

Hurd port for gcc go PATCH 11-18(23)

2016-11-25 Thread Svante Signell
* src_libgo_go_net_sendfile_gnu.go.diff: New file
* src_libgo_go_net_sock_gnu.go.diff: New file
* src_libgo_go_net_sockopt_gnu.go.diff: New file
* src_libgo_go_net_sockoptip_gnu.go.diff: New file
* src_libgo_go_syscall_libcall_gnu_386.go.diff: New file
* src_libgo_go_syscall_libcall_gnu.go.diff: New file
* src_libgo_go_syscall_libcall_posix-1.go.diff: New file derived from
libcall_posix.go
  Removed the mount call for GNU/Hurd, it exists but use translators.
  Removed the mlockall/munlockall calls for GNU/Hurd, not yet
implemented.
  Removed the madvise call for GNU/Hurd, not yet implemented.
* src_libgo_go_syscall_socket_gnu.go.diff: New fileIndex: gcc-6-6.2.1-4.1/src/libgo/go/net/sendfile_gnu.go
===
--- /dev/null
+++ gcc-6-6.2.1-4.1/src/libgo/go/net/sendfile_gnu.go
@@ -0,0 +1,79 @@
+// Copyright 2011 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package net
+
+import (
+	"io"
+	"os"
+	"syscall"
+)
+
+// maxSendfileSize is the largest chunk size we ask the kernel to copy
+// at a time.
+const maxSendfileSize int = 4 << 20
+
+// sendFile copies the contents of r to c using the sendfile
+// system call to minimize copies.
+//
+// if handled == true, sendFile returns the number of bytes copied and any
+// non-EOF error.
+//
+// if handled == false, sendFile performed no work.
+func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) {
+	var remain int64 = 1 << 62 // by default, copy until EOF
+
+	lr, ok := r.(*io.LimitedReader)
+	if ok {
+		remain, r = lr.N, lr.R
+		if remain <= 0 {
+			return 0, nil, true
+		}
+	}
+	f, ok := r.(*os.File)
+	if !ok {
+		return 0, nil, false
+	}
+
+	if err := c.writeLock(); err != nil {
+		return 0, err, true
+	}
+	defer c.writeUnlock()
+
+	dst := c.sysfd
+	src := int(f.Fd())
+	for remain > 0 {
+		n := maxSendfileSize
+		if int64(n) > remain {
+			n = int(remain)
+		}
+		n, err1 := syscall.Sendfile(dst, src, nil, n)
+		if n > 0 {
+			written += int64(n)
+			remain -= int64(n)
+		}
+		if n == 0 && err1 == nil {
+			break
+		}
+		if err1 == syscall.EAGAIN {
+			if err1 = c.pd.WaitWrite(); err1 == nil {
+continue
+			}
+		}
+		if err1 != nil {
+			// This includes syscall.ENOSYS (no kernel
+			// support) and syscall.EINVAL (fd types which
+			// don't implement sendfile)
+			err = err1
+			break
+		}
+	}
+	if lr != nil {
+		lr.N = remain
+	}
+	if err != nil {
+		err = os.NewSyscallError("sendfile", err)
+	}
+	return written, err, written > 0
+}
Index: gcc-6-6.2.1-4.1/src/libgo/go/net/sock_gnu.go
===
--- /dev/null
+++ gcc-6-6.2.1-4.1/src/libgo/go/net/sock_gnu.go
@@ -0,0 +1,14 @@
+// Copyright 2014 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build gnu
+
+package net
+
+import "syscall"
+
+func maxListenerBacklog() int {
+   // From /usr/include/i386-gnu/bits/socket.h
+   return syscall.SOMAXCONN
+}
Index: gcc-6-6.2.1-4.1/src/libgo/go/net/sockopt_gnu.go
===
--- /dev/null
+++ gcc-6-6.2.1-4.1/src/libgo/go/net/sockopt_gnu.go
@@ -0,0 +1,45 @@
+// Copyright 2011 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build gnu
+
+package net
+
+import (
+	"os"
+	"syscall"
+)
+
+func setDefaultSockopts(s, family, sotype int, ipv6only bool) error {
+	if family == syscall.AF_INET6 && sotype != syscall.SOCK_RAW {
+		// Allow both IP versions even if the OS default
+		// is otherwise.  Note that some operating systems
+		// never admit this option.
+		syscall.SetsockoptInt(s, syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, boolint(ipv6only))
+	}
+	// Allow broadcast.
+	return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1))
+}
+
+func setDefaultListenerSockopts(s int) error {
+	// Allow reuse of recently-used addresses.
+	return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1))
+}
+
+func setDefaultMulticastSockopts(s int) error {
+	// Allow multicast UDP and raw IP datagram sockets to listen
+	// concurrently across multiple listeners.
+	if err := syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1); err != nil {
+		return os.NewSyscallError("setsockopt", err)
+	}
+	// Allow reuse of recently-used ports.
+	// This option is supported only in descendants of 4.4BSD,
+	// to make an effective multicast application that requires
+	// quick draw possible.
+	// Not supported on GNU/Hurd
+	//if syscall.SO_REUSEPORT != 0 {
+	//	return os.NewSyscallError("setsockopt", syscall.SetsockoptInt(s, syscall.SOL_SOCKET, syscall.SO_REUSEPORT, 1))
+	//}
+	return nil
+}
Ind

Hurd port for gcc go PATCH 19-23(23)

2016-11-25 Thread Svante Signell
* src_libgo_runtime_netpoll.goc.diff: Fix restricted word bug.
  Rename variable errno to errno1.
* src_libgo_go_os_os_test.go.diff: Allow EFBIG return code to big
seeks.
* src_libgo_go_syscall_syscall_gnu_test.go: New file:
  Define Type and Whence as 32bit in syscall.Flock_t
* src_libgo_testsuite_gotest.diff: Remove comm option for ps -o.
* add-gnu-to-libgo-headers.diff:
  Add gnu to +build entry in file headers included in the build.
  FIXME:  Index: gcc-6-6.2.1-4.1/src/libgo/go/archive/tar/stat_atim.go
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/archive/tar/stat_atim.go
+++ gcc-6-6.2.1-4.1/src/libgo/go/archive/tar/stat_atim.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build linux dragonfly openbsd solaris
+// +build linux dragonfly openbsd solaris gnu
 
 package tar
 
Index: gcc-6-6.2.1-4.1/src/libgo/go/net/cgo_resnew.go
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/net/cgo_resnew.go
+++ gcc-6-6.2.1-4.1/src/libgo/go/net/cgo_resnew.go
@@ -3,7 +3,7 @@
 // license that can be found in the LICENSE file.
 
 // +build cgo,!netgo
-// +build darwin linux,!android netbsd solaris
+// +build darwin linux,!android netbsd solaris gnu
 
 package net
 
Index: gcc-6-6.2.1-4.1/src/libgo/go/net/cgo_socknew.go
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/net/cgo_socknew.go
+++ gcc-6-6.2.1-4.1/src/libgo/go/net/cgo_socknew.go
@@ -3,7 +3,7 @@
 // license that can be found in the LICENSE file.
 
 // +build cgo,!netgo
-// +build android linux solaris
+// +build android linux solaris gnu
 
 package net
 
Index: gcc-6-6.2.1-4.1/src/libgo/go/net/hook_cloexec.go
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/net/hook_cloexec.go
+++ gcc-6-6.2.1-4.1/src/libgo/go/net/hook_cloexec.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build freebsd linux
+// +build freebsd linux gnu
 
 package net
 
Index: gcc-6-6.2.1-4.1/src/libgo/go/net/main_unix_test.go
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/net/main_unix_test.go
+++ gcc-6-6.2.1-4.1/src/libgo/go/net/main_unix_test.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
+// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris gnu
 
 package net
 
Index: gcc-6-6.2.1-4.1/src/libgo/go/net/sock_cloexec.go
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/net/sock_cloexec.go
+++ gcc-6-6.2.1-4.1/src/libgo/go/net/sock_cloexec.go
@@ -5,7 +5,7 @@
 // This file implements sysSocket and accept for platforms that
 // provide a fast path for setting SetNonblock and CloseOnExec.
 
-// +build freebsd linux
+// +build freebsd linux gnu
 
 package net
 
Index: gcc-6-6.2.1-4.1/src/libgo/go/net/sockoptip_posix.go
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/net/sockoptip_posix.go
+++ gcc-6-6.2.1-4.1/src/libgo/go/net/sockoptip_posix.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux netbsd openbsd windows
+// +build darwin dragonfly freebsd linux netbsd openbsd windows gnu
 
 package net
 
Index: gcc-6-6.2.1-4.1/src/libgo/go/syscall/exec_unix.go
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/syscall/exec_unix.go
+++ gcc-6-6.2.1-4.1/src/libgo/go/syscall/exec_unix.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux netbsd openbsd solaris
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris gnu
 
 // Fork, exec, wait, etc.
 
Index: gcc-6-6.2.1-4.1/src/libgo/runtime/netpoll_select.c
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/runtime/netpoll_select.c
+++ gcc-6-6.2.1-4.1/src/libgo/runtime/netpoll_select.c
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build solaris
+// +build solaris gnu
 
 #include "config.h"
 
Index: gcc-6-6.2.1-4.1/src/libgo/go/os/exec/lp_unix.go
===
--- gcc-6-6.2.1-4.1.orig/src/libgo/go/os/exec/lp_unix.go
+++ gcc-6-6.2.1-4.1/src/libgo/go/os/exec/lp_unix.go
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found

Re: сигнализация и видеонаблюдение

2016-11-25 Thread sergey9167553133
установка и ремонт домофонов видеодомофонов и систем видеонаблюдения 
http://pulsarvideo.ru/

Re: C++ vs. glibc/Hurd/Mach headers

2016-11-25 Thread Brent W. Baccala
On Fri, Nov 25, 2016 at 1:46 AM, Thomas Schwinge 
wrote:

> Hi!
>
> Motivation for bringing this up again: GDB has recently switched from
> using a C to a C++ compiler.  GDB, for obvious reasons, needs to access
> low-level Hurd/Mach interfaces.
>
>
I've also had problems compiling hurd code using g++.

In addition to what Thomas has described, the ports library is unusable
with C++ because struct port_info has a member named "class".

Also, the initializer syntax used in /usr/include/refcount.h is unusable
with g++.  For example:

209   const union _references op =
210 { .references = { .weak = ~0U, .hard = 1} };

generates a compiler error:

sorry, unimplemented: non-trivial designated initializers not supported

To reproduce both problems, just create a file containing the line #include
 and try to compile it with g++.  It doesn't matter if you
put it inside an extern "C" block, either.

agape
brent


Re: gdb handling of Mach exceptions

2016-11-25 Thread Brent W. Baccala
On Wed, Nov 23, 2016 at 10:03 PM, Brent W. Baccala 
wrote:

>
> Any comments?
>

Well, yes, actually.  :-)

gdb's hurd target has a poorly documented command "set noninvasive".  I
don't completely understand it, but...

I'm starting to see the rational for an "invasive" debugging mode.
"Invasive" means that we debug by wrapping Mach ports - the task port needs
to be wrapped along with the exception ports.  "Non-invasive" means that we
rely on the C library in the program under test to provide some debugging
support.  No port wrapping is done.  Breakpoints, for example, work by
letting the program's message thread generate a SIGTRAP, which gets relayed
to the proc server and is presented to the debugger in response to a wait()
call.

Non-invasive is more efficient, but invasive is more reliable.

I'd code it myself, except that we've got the same old problem with
detaching a process when its ports are wrapped.  This shows, incidentally,
that adding a system call trace facility to the kernel isn't a complete
solution.  We don't just want to trace these messages - we want to
intercept them and only deliver them after a human being has had the chance
to inspect them at a debugger prompt.

agape
brent


signal preemptors

2016-11-25 Thread Brent W. Baccala
Coming back to the subject of signal preemptors...

Why do we need them at all?  Why not just use the existing POSIX signal
facilities?

We install a signal handler, saving the old signal handler, check the
faulting memory address inside the new signal handler, and relay the signal
on to the saved signal handler if it doesn't match.

Also, codesearch.debian.net shows that the only place signal preemptors are
used is in the hurd source tree itself (no great surprise), and the four
places that it's used there (libpager, libstore, libdiskfs, and exec) don't
do anything else with SIGBUS or SIGSEGV, so we don't even have to worry
about nested signal handlers, really.  We can just catch the signals.

Signal preemptors, as a non standard addition to the already complicated
POSIX signal API, raise questions like, what happens when a signal is
preempted while a debugger is attached?  Does the debugger get the signal
before the preemptor, or does the preemptor fire without waiting for the
debugger?

agape
brent