Patchwork libgo patch committed: Update to weekly.2011-12-22

login
register
mail settings
Submitter Ian Taylor
Date Jan. 13, 2012, 11:18 p.m.
Message ID <mcrvcofmbsi.fsf@dhcp-172-18-216-180.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/136042/
State New
Headers show

Comments

Ian Taylor - Jan. 13, 2012, 11:18 p.m.
Uros Bizjak <ubizjak@gmail.com> writes:

> On Fri, Jan 13, 2012 at 7:00 PM, Ian Lance Taylor <iant@google.com> wrote:
>
>> Thanks for the report, but this is surprising.  Doesn't Alpha GNU/Linux
>> define TIOCGWINSZ in /usr/include/asm-generic/ioctls.h?  And isn't that
>> file #include'd, indirectly, by <sys/ioctl.h>?
>>
>> If not, does Alpha GNU/Linux define TIOCGWINSZ at all, and how does it
>> define it?  I thought TIOCGWINSZ was common, and I'm particularly
>> surprised to not find it on a GNU/Linux system.
>
> This is the same problem with -fdump-go-spec we discussed a couple of
> months ago [1]. In short, alpha linux doesn't just include
> <asm-generic/ioctls.h> with hardcoded numbers in asm/ioctls.h, but
> builds ioctl arguments as shown in [1]. Probably, this is the right
> way ...

Oh yeah.

I think I've worked out a way to handle this kind of thing.  With luck
this patch will fix the problem.  Bootstrapped on
x86_64-unknown-linux-gnu, although that doesn't really test it properly.
Committed to mainline.  Please let me know if this helps.

Thanks for reporting the problem.

Ian

Patch

diff -r ade619795842 libgo/mksysinfo.sh
--- a/libgo/mksysinfo.sh	Fri Jan 13 15:02:22 2012 -0800
+++ b/libgo/mksysinfo.sh	Fri Jan 13 15:15:32 2012 -0800
@@ -89,6 +89,15 @@ 
 #if defined(HAVE_NET_IF_H)
 #include <net/if.h>
 #endif
+
+/* Constants that may only be defined as expressions on some systems,
+   expressions too complex for -fdump-go-spec to handle.  These are
+   handled specially below.  */
+enum {
+#ifdef TIOCGWINSZ
+  TIOCGWINSZ_val = TIOCGWINSZ,
+#endif
+};
 EOF
 
 ${CC} -fdump-go-spec=gen-sysinfo.go -std=gnu99 -S -o sysinfo.s sysinfo.c
@@ -524,7 +533,14 @@ 
 
 # The ioctl flags for the controlling TTY.
 grep '^const _TIOC' gen-sysinfo.go | \
+    grep -v '_val =' | \
     sed -e 's/^\(const \)_\(TIOC[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
+# We need TIOCGWINSZ.
+if ! grep '^const TIOCGWINSZ' ${OUT} >/dev/null 2>&1; then
+  if grep '^const _TIOCGWINSZ_val' ${OUT} >/dev/null 2>&1; then
+    echo 'const TIOCGWINSZ = TIOCGWINSZ_val' >> ${OUT}
+  fi
+fi
 
 # The ioctl flags for terminal control
 grep '^const _TC[GS]ET' gen-sysinfo.go | \