Patchwork libgo patch committed: Fill out syscall package for GNU/Linux

login
register
mail settings
Submitter Ian Taylor
Date March 2, 2012, 9:07 p.m.
Message ID <mcrhay6hftd.fsf@dhcp-172-18-216-180.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/144357/
State New
Headers show

Comments

Ian Taylor - March 2, 2012, 9:07 p.m.
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:
>
>> Ian Lance Taylor <iant@google.com> writes:
>>
>>> This patch to libgo fills out the syscall package for GNU/Linux to match
>>> all the functions in the syscall package in the master Go library.
>>> There is a test case for this patch at
>>> http://code.google.com/p/go/issues/detail?id=3071 .  Bootstrapped and
>>> ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.
>>
>> Unfortunately, this broke Solaris bootstrap:
>
> It also broke Linux/x86_64 bootstrap (CentOS 5.6):
>
> In file included from /usr/include/sys/ustat.h:30:0,
>                  from /usr/include/ustat.h:1,
>                  from sysinfo.c:91:
> /usr/include/bits/ustat.h:25:8: error: redefinition of 'struct ustat'
> In file included from /usr/include/linux/filter.h:8:0,
>                  from sysinfo.c:61:
> /usr/include/linux/types.h:156:8: note: originally defined here

Thanks for the note.  I committed this patch in an attempt to fix these
problems.

Ian

Patch

diff -r 0f5b89756b90 libgo/configure.ac
--- a/libgo/configure.ac	Fri Mar 02 12:47:45 2012 -0800
+++ b/libgo/configure.ac	Fri Mar 02 13:06:49 2012 -0800
@@ -453,7 +453,7 @@ 
   ;;
 esac
 
-AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/if.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h ustat.h utime.h linux/reboot.h)
+AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/if.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/reboot.h)
 
 AC_CHECK_HEADERS([linux/filter.h linux/netlink.h linux/rtnetlink.h], [], [],
 [#ifdef HAVE_SYS_SOCKET_H
@@ -461,6 +461,21 @@ 
 #endif
 ])
 
+AC_CACHE_CHECK([whether <ustat.h> can be used],
+[libgo_cv_c_ustat_h],
+AC_COMPILE_IFELSE(
+[AC_LANG_SOURCE([
+#include <sys/types.h>
+#ifdef HAVE_LINUX_FILTER_H
+#include <linux/filter.h>
+#endif
+#include <ustat.h>
+])], [libgo_cv_c_ustat_h=yes], [libgo_cv_c_ustat_h=no]))
+if test $libgo_cv_c_ustat_h = yes; then
+  AC_DEFINE(HAVE_USTAT_H, 1,
+    [Define to 1 if you have the <ustat.h> header file and it works.])
+fi
+
 AM_CONDITIONAL(HAVE_SYS_MMAN_H, test "$ac_cv_header_sys_mman_h" = yes)
 
 AC_CHECK_FUNCS(strerror_r strsignal wait4 mincore setenv)
diff -r 0f5b89756b90 libgo/mksysinfo.sh
--- a/libgo/mksysinfo.sh	Fri Mar 02 12:47:45 2012 -0800
+++ b/libgo/mksysinfo.sh	Fri Mar 02 13:06:49 2012 -0800
@@ -895,6 +895,11 @@ 
       -e 's/f_fname/Fname/' \
       -e 's/f_fpack/Fpack/' \
     >> ${OUT}
+# Force it to be defined, as on some older GNU/Linux systems the
+# header file fails when using with <linux/filter.h>.
+if ! grep 'type _ustat ' gen-sysinfo.go >/dev/null 2>&1; then
+  echo 'type Ustat_t struct { Tfree int32; Tinoe uint64; Fname [5+1]int8; Fpack [5+1]int8; }' >> ${OUT}
+fi
 
 # The utimbuf struct.
 grep '^type _utimbuf ' gen-sysinfo.go | \