Hurd port for gcc go PATCH 7-9 (9)

2014-05-06 Thread Svante Signell

(continued)

patch7.diff: src/libgo/go/syscall/wait.c
Set WCONTINUED to zero if not defined (same fix as for lto in gcc-4.9)

patch8.diff: src/libgo/mksysinfo.sh
Add special treatment of EWOULDBLOCK, SYS_FCNTL and st_dev since they
are either not defined or defined differently for the script to catch
them. The patch for st_dev by Thomas Schwinge was not liked by Samuel so
I have included a more clumsy version. A better solution is needed.
Thomas version is commented out in the patch.

patch9.diff: src/libgo/runtime/netpoll.goc
Rename errno to errno1 since errno clashes with errno.h included in
that file on Hurd.

--- a/src/libgo/go/syscall/wait.c
+++ b/src/libgo/go/syscall/wait.c
@@ -8,6 +8,9 @@
OS-independent.  */
 
 #include stdint.h
+#ifndef WCONTINUED
+#define WCONTINUED 0
+#endif
 #include sys/wait.h
 
 #include runtime.h
--- a/src/libgo/mksysinfo.sh
+++ b/src/libgo/mksysinfo.sh
@@ -210,6 +210,11 @@
   egrep '#define E[A-Z0-9_]+ ' | \
   sed -e 's/^#define \(E[A-Z0-9_]*\) .*$/const \1 = Errno(_\1)/'  ${OUT}
 
+# Special treatment of EWOULDBLOCK for GNU/Hurd
+# /usr/include/bits/errno.h: #define EWOULDBLOCK EAGAIN
+egrep '^const EWOULDBLOCK = Errno(_EWOULDBLOCK)' ${OUT} | \
+sed -i.bak -e 's/_EWOULDBLOCK/_EAGAIN/' ${OUT}
+
 # The O_xxx flags.
 egrep '^const _(O|F|FD)_' gen-sysinfo.go | \
   sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/'  ${OUT}
@@ -225,6 +230,11 @@
   echo const F_DUPFD_CLOEXEC = 0  ${OUT}
 fi
 
+# Special treatment of SYS_FCNTL for GNU/Hurd
+if ! grep '^const SYS_FCNTL' ${OUT} /dev/null 21; then
+  echo const SYS_FCNTL = 0  ${OUT}
+fi
+
 # These flags can be lost on i386 GNU/Linux when using
 # -D_FILE_OFFSET_BITS=64, because we see #define F_SETLK F_SETLK64
 # before we see the definition of F_SETLK64.
@@ -528,6 +538,15 @@
 
 # The stat type.
 # Prefer largefile variant if available.
+# Special treatment of st_dev for GNU/Hurd
+# /usr/include/i386-gnu/bits/stat.h: #define st_dev st_fsid
+if grep 'define st_dev st_fsid' gen-sysinfo.go /dev/null 21; then
+ grep '^type _stat ' gen-sysinfo.go | \
+ sed -i.bak -e 's/st_fsid\([^;]*\)/st_fsid\1; st_dev\1/' gen-sysinfo.go
+ grep '^type _stat ' ${OUT} | \
+ sed -i.bak -e 's/st_fsid\([^;]*\)/; st_dev\1/' ${OUT}
+fi
+# -e 's/st_fsid/Dev/'
 stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
 if test $stat != ; then
   grep '^type _stat64 ' gen-sysinfo.go
--- a/src/libgo/runtime/netpoll.goc.orig	2013-11-07 01:23:21.0 +0100
+++ b/src/libgo/runtime/netpoll.goc	2014-03-28 09:07:15.0 +0100
@@ -68,7 +68,7 @@
 	runtime_netpollinit();
 }
 
-func runtime_pollOpen(fd uintptr) (pd *PollDesc, errno int) {
+func runtime_pollOpen(fd uintptr) (pd *PollDesc, errno1 int) {
 	pd = allocPollDesc();
 	runtime_lock(pd);
 	if(pd-wg != nil  pd-wg != READY)
@@ -84,7 +84,7 @@
 	pd-wd = 0;
 	runtime_unlock(pd);
 
-	errno = runtime_netpollopen(fd, pd);
+	errno1 = runtime_netpollopen(fd, pd);
 }
 
 func runtime_pollClose(pd *PollDesc) {


Re: Hurd port for gcc go PATCH 7-9 (9)

2014-05-06 Thread Samuel Thibault
Svante Signell, le Tue 06 May 2014 10:58:38 +0200, a écrit :
 The patch for st_dev by Thomas Schwinge was not liked by Samuel

Uh?

I said “These should be fine, however.” and “a sed rule can't hurt even
if there is no occurrence...”

So just keep that precise part back as it was, no need for being clumsy.

What I however said was:

“Err, these seem to get applied to all systems, not just GNU/Hurd, isn't
that a concern?”

By that, I mean this:

 +# Special treatment of EWOULDBLOCK for GNU/Hurd
 +# /usr/include/bits/errno.h: #define EWOULDBLOCK EAGAIN
 +egrep '^const EWOULDBLOCK = Errno(_EWOULDBLOCK)' ${OUT} | \
 +sed -i.bak -e 's/_EWOULDBLOCK/_EAGAIN/' ${OUT}
 +

and that:

 +# Special treatment of SYS_FCNTL for GNU/Hurd
 +if ! grep '^const SYS_FCNTL' ${OUT} /dev/null 21; then
 +  echo const SYS_FCNTL = 0  ${OUT}
 +fi

AIUI, the patch you propose does those changes for all systems, not just
GNU/Hurd.  That most probably will pose a problem.

Samuel


Re: Hurd port for gcc go PATCH 7-9 (9)

2014-05-06 Thread Svante Signell
On Tue, 2014-05-06 at 11:07 +0200, Samuel Thibault wrote:
 Svante Signell, le Tue 06 May 2014 10:58:38 +0200, a écrit :
  The patch for st_dev by Thomas Schwinge was not liked by Samuel
 
 Uh?
 
 I said “These should be fine, however.” and “a sed rule can't hurt even
 if there is no occurrence...”
 
 So just keep that precise part back as it was, no need for being clumsy.
 
 What I however said was:
 
 “Err, these seem to get applied to all systems, not just GNU/Hurd, isn't
 that a concern?”
 
 By that, I mean this:
 
  +# Special treatment of EWOULDBLOCK for GNU/Hurd
  +# /usr/include/bits/errno.h: #define EWOULDBLOCK EAGAIN
  +egrep '^const EWOULDBLOCK = Errno(_EWOULDBLOCK)' ${OUT} | \
  +sed -i.bak -e 's/_EWOULDBLOCK/_EAGAIN/' ${OUT}
  +

This applies to all systems yes, how to modify?

 and that:
 
  +# Special treatment of SYS_FCNTL for GNU/Hurd
  +if ! grep '^const SYS_FCNTL' ${OUT} /dev/null 21; then
  +  echo const SYS_FCNTL = 0  ${OUT}
  +fi

And this applies to systems not defining FCNTL.
How many systems could possibly be affected?
 
 AIUI, the patch you propose does those changes for all systems, not just
 GNU/Hurd.  That most probably will pose a problem.

And you wrote in your reply to the above: see e.g.
http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00644.html
 These should be fine, however.

I asked for help with sed but have not obtained any yet, so what to do?



Re: Hurd port for gcc go PATCH 7-9 (9)

2014-05-06 Thread Samuel Thibault
Svante Signell, le Tue 06 May 2014 14:13:54 +0200, a écrit :
   +# Special treatment of EWOULDBLOCK for GNU/Hurd
   +# /usr/include/bits/errno.h: #define EWOULDBLOCK EAGAIN
   +egrep '^const EWOULDBLOCK = Errno(_EWOULDBLOCK)' ${OUT} | \
   +sed -i.bak -e 's/_EWOULDBLOCK/_EAGAIN/' ${OUT}
   +
 
 This applies to all systems yes, how to modify?

Well, either explicitly test for the system, or find a way to make it
actually do things only for the systems which need it. You could for
instance grep for #define EWOULDBLOCK EAGAIN.

  and that:
  
   +# Special treatment of SYS_FCNTL for GNU/Hurd
   +if ! grep '^const SYS_FCNTL' ${OUT} /dev/null 21; then
   +  echo const SYS_FCNTL = 0  ${OUT}
   +fi
 
 And this applies to systems not defining FCNTL.
 How many systems could possibly be affected?

I misread it indeed, I'm sorry about that.  So it adds SYS_FCNTL = 0 to
any system which does not have it already.  What is the consequence of
this?  Where is this used?  (I can't find any go reference to SYS_FCNTL
in the gcc source)

Samuel


Re: Hurd port for gcc go PATCH 7-9 (9)

2014-04-14 Thread Svante Signell
On Fri, 2014-04-11 at 22:55 +0200, Samuel Thibault wrote:
 Svante Signell, le Fri 11 Apr 2014 14:57:35 +0200, a écrit :
  --- a/src/libgo/mksysinfo.sh
  +++ b/src/libgo/mksysinfo.sh
 
 Err, these seem to get applied to all systems, not just GNU/Hurd, isn't
 that a concern?
 
  @@ -210,6 +210,11 @@
 egrep '#define E[A-Z0-9_]+ ' | \
 sed -e 's/^#define \(E[A-Z0-9_]*\) .*$/const \1 = Errno(_\1)/'  ${OUT}
   
  +# Special treatment of EWOULDBLOCK for GNU/Hurd
  +# /usr/include/bits/errno.h: #define EWOULDBLOCK EAGAIN
  +egrep '^const EWOULDBLOCK = Errno(_EWOULDBLOCK)' ${OUT} | \
  +sed -i.bak -e 's/_EWOULDBLOCK/_EAGAIN/' ${OUT}
  +
   # The O_xxx flags.
   egrep '^const _(O|F|FD)_' gen-sysinfo.go | \
 sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/'  ${OUT}
  @@ -225,6 +230,11 @@
 echo const F_DUPFD_CLOEXEC = 0  ${OUT}
   fi
   
  +# Special treatment of SYS_FCNTL for GNU/Hurd
  +if ! grep '^const SYS_FCNTL' ${OUT} /dev/null 21; then
  +  echo const SYS_FCNTL = 0  ${OUT}
  +fi
  +
   # These flags can be lost on i386 GNU/Linux when using
   # -D_FILE_OFFSET_BITS=64, because we see #define F_SETLK F_SETLK64
   # before we see the definition of F_SETLK64.
 
 These should be fine, however.

OK!

  @@ -528,6 +538,8 @@
   
   # The stat type.
   # Prefer largefile variant if available.
  +# Special treatment of st_dev for GNU/Hurd
  +# /usr/include/i386-gnu/bits/stat.h: #define st_dev st_fsid
   stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
   if test $stat != ; then
 grep '^type _stat64 ' gen-sysinfo.go
  @@ -536,6 +548,7 @@
   fi | sed -e 's/type _stat64/type Stat_t/' \
-e 's/type _stat/type Stat_t/' \
-e 's/st_dev/Dev/' \
  + -e 's/st_fsid/Dev/' \
-e 's/st_ino/Ino/g' \
-e 's/st_nlink/Nlink/' \
-e 's/st_mode/Mode/' \

Don't know if any other system defines st_fsid as st_dev like Hurd does.
If not this one would be fine too?




Re: Hurd port for gcc go PATCH 7-9 (9)

2014-04-14 Thread Samuel Thibault
Svante Signell, le Mon 14 Apr 2014 09:59:03 +0200, a écrit :
   @@ -528,6 +538,8 @@

# The stat type.
# Prefer largefile variant if available.
   +# Special treatment of st_dev for GNU/Hurd
   +# /usr/include/i386-gnu/bits/stat.h: #define st_dev st_fsid
stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
if test $stat != ; then
  grep '^type _stat64 ' gen-sysinfo.go
   @@ -536,6 +548,7 @@
fi | sed -e 's/type _stat64/type Stat_t/' \
 -e 's/type _stat/type Stat_t/' \
 -e 's/st_dev/Dev/' \
   + -e 's/st_fsid/Dev/' \
 -e 's/st_ino/Ino/g' \
 -e 's/st_nlink/Nlink/' \
 -e 's/st_mode/Mode/' \
 
 Don't know if any other system defines st_fsid as st_dev like Hurd does.
 If not this one would be fine too?

I don't know any other system doing it, but a sed rule can't hurt even
if there is no occurrence...

Samuel


Re: Hurd port for gcc go PATCH 7-9 (9)

2014-04-14 Thread Svante Signell
On Mon, 2014-04-14 at 11:03 +0200, Samuel Thibault wrote:
 Svante Signell, le Mon 14 Apr 2014 09:59:03 +0200, a écrit :
@@ -528,6 +538,8 @@
 
 # The stat type.
 # Prefer largefile variant if available.
+# Special treatment of st_dev for GNU/Hurd
+# /usr/include/i386-gnu/bits/stat.h: #define st_dev st_fsid
 stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
 if test $stat != ; then
   grep '^type _stat64 ' gen-sysinfo.go
@@ -536,6 +548,7 @@
 fi | sed -e 's/type _stat64/type Stat_t/' \
  -e 's/type _stat/type Stat_t/' \
  -e 's/st_dev/Dev/' \
+ -e 's/st_fsid/Dev/' \
  -e 's/st_ino/Ino/g' \
  -e 's/st_nlink/Nlink/' \
  -e 's/st_mode/Mode/' \
  
  Don't know if any other system defines st_fsid as st_dev like Hurd does.
  If not this one would be fine too?
 
 I don't know any other system doing it, but a sed rule can't hurt even
 if there is no occurrence...

The current code was written by Thomas. I had the following in an older,
not so elegant patch: (I'm in no way fluent in sed, I need help here):
(indentation modified)

if grep 'define st_dev st_fsid' gen-sysinfo.go /dev/null 21; then
 grep '^type _stat ' gen-sysinfo.go | \
 sed -i.bak -e 's/st_fsid\([^;]*\)/st_fsid\1; st_dev\1/' gen-sysinfo.go
 grep '^type _stat ' ${OUT} | \
 sed -i.bak -e 's/st_fsid\([^;]*\)/; st_dev\1/' ${OUT}
fi




[Fwd: Hurd port for gcc go PATCH 7-9 (9)]

2014-04-11 Thread Svante Signell

---BeginMessage---
(continued)

patch7.diff: src/libgo/go/syscall/wait.c
Set WCONTINUED to zero if not defined (same fix as for lto in gcc-4.9)

patch8.diff: src/libgo/mksysinfo.sh
Add special treatment of EWOULDBLOCK, SYS_FCNTL and st_dev since they
are either not defined or defined differently for the script to catch
them. 

patch9.diff: src/libgo/runtime/netpoll.goc
Rename errno to errno1 since errno clashes with errno.h included in
that file on Hurd.
--- a/src/libgo/go/syscall/wait.c
+++ b/src/libgo/go/syscall/wait.c
@@ -8,6 +8,9 @@
OS-independent.  */
 
 #include stdint.h
+#ifndef WCONTINUED
+#define WCONTINUED 0
+#endif
 #include sys/wait.h
 
 #include runtime.h
--- a/src/libgo/mksysinfo.sh
+++ b/src/libgo/mksysinfo.sh
@@ -210,6 +210,11 @@
   egrep '#define E[A-Z0-9_]+ ' | \
   sed -e 's/^#define \(E[A-Z0-9_]*\) .*$/const \1 = Errno(_\1)/'  ${OUT}
 
+# Special treatment of EWOULDBLOCK for GNU/Hurd
+# /usr/include/bits/errno.h: #define EWOULDBLOCK EAGAIN
+egrep '^const EWOULDBLOCK = Errno(_EWOULDBLOCK)' ${OUT} | \
+sed -i.bak -e 's/_EWOULDBLOCK/_EAGAIN/' ${OUT}
+
 # The O_xxx flags.
 egrep '^const _(O|F|FD)_' gen-sysinfo.go | \
   sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/'  ${OUT}
@@ -225,6 +230,11 @@
   echo const F_DUPFD_CLOEXEC = 0  ${OUT}
 fi
 
+# Special treatment of SYS_FCNTL for GNU/Hurd
+if ! grep '^const SYS_FCNTL' ${OUT} /dev/null 21; then
+  echo const SYS_FCNTL = 0  ${OUT}
+fi
+
 # These flags can be lost on i386 GNU/Linux when using
 # -D_FILE_OFFSET_BITS=64, because we see #define F_SETLK F_SETLK64
 # before we see the definition of F_SETLK64.
@@ -528,6 +538,8 @@
 
 # The stat type.
 # Prefer largefile variant if available.
+# Special treatment of st_dev for GNU/Hurd
+# /usr/include/i386-gnu/bits/stat.h: #define st_dev st_fsid
 stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
 if test $stat != ; then
   grep '^type _stat64 ' gen-sysinfo.go
@@ -536,6 +548,7 @@
 fi | sed -e 's/type _stat64/type Stat_t/' \
  -e 's/type _stat/type Stat_t/' \
  -e 's/st_dev/Dev/' \
+ -e 's/st_fsid/Dev/' \
  -e 's/st_ino/Ino/g' \
  -e 's/st_nlink/Nlink/' \
  -e 's/st_mode/Mode/' \
--- a/src/libgo/runtime/netpoll.goc.orig	2013-11-07 01:23:21.0 +0100
+++ b/src/libgo/runtime/netpoll.goc	2014-03-28 09:07:15.0 +0100
@@ -68,7 +68,7 @@
 	runtime_netpollinit();
 }
 
-func runtime_pollOpen(fd uintptr) (pd *PollDesc, errno int) {
+func runtime_pollOpen(fd uintptr) (pd *PollDesc, errno1 int) {
 	pd = allocPollDesc();
 	runtime_lock(pd);
 	if(pd-wg != nil  pd-wg != READY)
@@ -84,7 +84,7 @@
 	pd-wd = 0;
 	runtime_unlock(pd);
 
-	errno = runtime_netpollopen(fd, pd);
+	errno1 = runtime_netpollopen(fd, pd);
 }
 
 func runtime_pollClose(pd *PollDesc) {
---End Message---