diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-04-23 12:53:36 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-04-23 12:53:36 +0000 |
commit | 65cbf05437b8a57ff08846beb19407c9e0dd2553 (patch) | |
tree | 0b0bd391a56275bab5bf67e4094d9b7a24ade79c /libgo | |
parent | 381399a9fee786a047529a0f7de787de475ab97c (diff) | |
download | gcc-65cbf05437b8a57ff08846beb19407c9e0dd2553.tar.gz |
2012-04-23 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 186692 using svnmerge
[gcc/]
2012-04-23 Basile Starynkevitch <basile@starynkevitch.net>
{{improvements for merging with GCC 4.8 trunk svn rev 186692}}
* melt-run.proto.h (MELT_GCC_VERSION): Define, if unknown, in the
generated melt-run.h
* melt-runtime.c (melt_val2passflag): TODO_dump_func &
TODO_dump_cgraph don't exist in GCC 4.8.
* melt-build.tpl: Say flavor, not variant! Build first the
quicklybuilt application modules, to catch error in macro C
strings...
* melt-build.mk: Regenerate.
* melt/warmelt-base.melt (valdesc_strbuf): Check for MELT_GCC_VERSION also.
* melt/warmelt-genobj.melt (compilobj_nrep_citeration): Use
meltcit prefix in generated citerator names..
* melt/warmelt-outobj.melt (syntestgen_citerator): Use
meltcitstate prefix.
* melt/xtramelt-ana-base.melt (each_cgraph_fun_body)
(each_cgraph_fun_entryblock, each_cgraph_fun_call_flow_graph)
(each_bb_cfun, with_cfun_decl): Adapt to GCC 4.8, add
documentation.
(each_cgraph_decl): Only for GCC 4.6 & 4.7
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@186705 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/Makefile.am | 1 | ||||
-rw-r--r-- | libgo/Makefile.in | 2 | ||||
-rw-r--r-- | libgo/config.h.in | 36 | ||||
-rwxr-xr-x | libgo/configure | 15 | ||||
-rw-r--r-- | libgo/configure.ac | 10 | ||||
-rw-r--r-- | libgo/go/debug/dwarf/line.go | 4 | ||||
-rw-r--r-- | libgo/go/net/http/fs_test.go | 2 | ||||
-rw-r--r-- | libgo/go/net/interface_linux.go | 17 | ||||
-rw-r--r-- | libgo/go/os/stat.go | 4 | ||||
-rw-r--r-- | libgo/go/os/stat_solaris.go | 4 | ||||
-rw-r--r-- | libgo/go/runtime/gc_test.go | 2 | ||||
-rw-r--r-- | libgo/go/syscall/libcall_linux.go | 2 | ||||
-rw-r--r-- | libgo/go/syscall/libcall_posix.go | 2 | ||||
-rw-r--r-- | libgo/go/syscall/netlink_linux.go | 43 | ||||
-rw-r--r-- | libgo/go/syscall/sockcmsg_unix.go | 4 | ||||
-rw-r--r-- | libgo/go/syscall/socket.go | 2 | ||||
-rwxr-xr-x | libgo/mksysinfo.sh | 202 | ||||
-rw-r--r-- | libgo/runtime/go-runtime-error.c | 8 | ||||
-rw-r--r-- | libgo/runtime/malloc.goc | 2 | ||||
-rw-r--r-- | libgo/runtime/mgc0.c | 11 | ||||
-rw-r--r-- | libgo/runtime/proc.c | 4 | ||||
-rw-r--r-- | libgo/runtime/runtime.h | 5 | ||||
-rw-r--r-- | libgo/testsuite/Makefile.in | 1 | ||||
-rwxr-xr-x | libgo/testsuite/gotest | 6 |
24 files changed, 253 insertions, 136 deletions
diff --git a/libgo/Makefile.am b/libgo/Makefile.am index e19cdf0a36d..11a650be689 100644 --- a/libgo/Makefile.am +++ b/libgo/Makefile.am @@ -1559,7 +1559,6 @@ s-syscall_arch: Makefile echo "package syscall" > syscall_arch.go.tmp echo 'const ARCH = "'$(GOARCH)'"' >> syscall_arch.go.tmp echo 'const OS = "'$(GOOS)'"' >> syscall_arch.go.tmp - echo 'const BigEndian = $(GO_BIGENDIAN)' >> syscall_arch.go.tmp $(SHELL) $(srcdir)/../move-if-change syscall_arch.go.tmp syscall_arch.go $(STAMP) $@ diff --git a/libgo/Makefile.in b/libgo/Makefile.in index 4695a4e20da..62cdf6dba78 100644 --- a/libgo/Makefile.in +++ b/libgo/Makefile.in @@ -379,7 +379,6 @@ GOARCH = @GOARCH@ GOC = @GOC@ GOCFLAGS = $(CFLAGS) GOOS = @GOOS@ -GO_BIGENDIAN = @GO_BIGENDIAN@ GO_LIBCALL_OS_ARCH_FILE = @GO_LIBCALL_OS_ARCH_FILE@ GO_LIBCALL_OS_FILE = @GO_LIBCALL_OS_FILE@ GO_SYSCALL_OS_ARCH_FILE = @GO_SYSCALL_OS_ARCH_FILE@ @@ -4332,7 +4331,6 @@ s-syscall_arch: Makefile echo "package syscall" > syscall_arch.go.tmp echo 'const ARCH = "'$(GOARCH)'"' >> syscall_arch.go.tmp echo 'const OS = "'$(GOOS)'"' >> syscall_arch.go.tmp - echo 'const BigEndian = $(GO_BIGENDIAN)' >> syscall_arch.go.tmp $(SHELL) $(srcdir)/../move-if-change syscall_arch.go.tmp syscall_arch.go $(STAMP) $@ diff --git a/libgo/config.h.in b/libgo/config.h.in index 270a4ae37fa..91b91bfb0a9 100644 --- a/libgo/config.h.in +++ b/libgo/config.h.in @@ -48,6 +48,18 @@ /* Define to 1 if you have the <linux/filter.h> header file. */ #undef HAVE_LINUX_FILTER_H +/* Define to 1 if you have the <linux/fs.h> header file. */ +#undef HAVE_LINUX_FS_H + +/* Define to 1 if you have the <linux/if_addr.h> header file. */ +#undef HAVE_LINUX_IF_ADDR_H + +/* Define to 1 if you have the <linux/if_ether.h> header file. */ +#undef HAVE_LINUX_IF_ETHER_H + +/* Define to 1 if you have the <linux/if_tun.h> header file. */ +#undef HAVE_LINUX_IF_TUN_H + /* Define to 1 if you have the <linux/netlink.h> header file. */ #undef HAVE_LINUX_NETLINK_H @@ -75,12 +87,30 @@ /* Define to 1 if you have the `mknodat' function. */ #undef HAVE_MKNODAT +/* Define to 1 if you have the <netinet/if_ether.h> header file. */ +#undef HAVE_NETINET_IF_ETHER_H + +/* Define to 1 if you have the <netinet/in_syst.h> header file. */ +#undef HAVE_NETINET_IN_SYST_H + +/* Define to 1 if you have the <netinet/ip.h> header file. */ +#undef HAVE_NETINET_IP_H + +/* Define to 1 if you have the <netinet/ip_mroute.h> header file. */ +#undef HAVE_NETINET_IP_MROUTE_H + +/* Define to 1 if you have the <netpacket/packet.h> header file. */ +#undef HAVE_NETPACKET_PACKET_H + /* Define to 1 if you have the <net/if_arp.h> header file. */ #undef HAVE_NET_IF_ARP_H /* Define to 1 if you have the <net/if.h> header file. */ #undef HAVE_NET_IF_H +/* Define to 1 if you have the <net/route.h> header file. */ +#undef HAVE_NET_ROUTE_H + /* Define to 1 if the system has the type `off64_t'. */ #undef HAVE_OFF64_T @@ -145,6 +175,12 @@ /* Define to 1 if you have the <sys/epoll.h> header file. */ #undef HAVE_SYS_EPOLL_H +/* Define to 1 if you have the <sys/file.h> header file. */ +#undef HAVE_SYS_FILE_H + +/* Define to 1 if you have the <sys/inotify.h> header file. */ +#undef HAVE_SYS_INOTIFY_H + /* Define to 1 if you have the <sys/mman.h> header file. */ #undef HAVE_SYS_MMAN_H diff --git a/libgo/configure b/libgo/configure index e58b238cd0f..24b05b9271b 100755 --- a/libgo/configure +++ b/libgo/configure @@ -612,7 +612,6 @@ HAVE_STRERROR_R_FALSE HAVE_STRERROR_R_TRUE HAVE_SYS_MMAN_H_FALSE HAVE_SYS_MMAN_H_TRUE -GO_BIGENDIAN PTHREAD_LIBS PTHREAD_CFLAGS NET_LIBS @@ -11101,7 +11100,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11104 "configure" +#line 11103 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11207,7 +11206,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11210 "configure" +#line 11209 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -14409,12 +14408,6 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac -case $ac_cv_c_bigendian in - yes) GO_BIGENDIAN=true ;; - no) GO_BIGENDIAN=false ;; - *) as_fn_error "unknown endianness" "$LINENO" 5 ;; -esac - @@ -14515,7 +14508,7 @@ no) ;; esac -for ac_header in 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 net/if_arp.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/reboot.h +for ac_header in sys/file.h sys/mman.h syscall.h sys/epoll.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -14530,7 +14523,7 @@ fi done -for ac_header in linux/filter.h linux/netlink.h linux/rtnetlink.h +for ac_header in linux/filter.h linux/if_addr.h linux/if_ether.h linux/if_tun.h linux/netlink.h linux/rtnetlink.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef HAVE_SYS_SOCKET_H diff --git a/libgo/configure.ac b/libgo/configure.ac index f1d0bfc8b32..7da76191404 100644 --- a/libgo/configure.ac +++ b/libgo/configure.ac @@ -400,12 +400,6 @@ dnl Test if -lrt is required for sched_yield. AC_SEARCH_LIBS([sched_yield], [rt]) AC_C_BIGENDIAN -case $ac_cv_c_bigendian in - yes) GO_BIGENDIAN=true ;; - no) GO_BIGENDIAN=false ;; - *) AC_MSG_ERROR([unknown endianness]) ;; -esac -AC_SUBST(GO_BIGENDIAN) GCC_CHECK_UNWIND_GETIPINFO @@ -459,9 +453,9 @@ no) ;; 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 net/if_arp.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/reboot.h) +AC_CHECK_HEADERS(sys/file.h sys/mman.h syscall.h sys/epoll.h sys/inotify.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/if.h net/if_arp.h net/route.h netpacket/packet.h sys/prctl.h sys/mount.h sys/vfs.h sys/statfs.h sys/timex.h sys/sysinfo.h utime.h linux/ether.h linux/fs.h linux/reboot.h netinet/in_syst.h netinet/ip.h netinet/ip_mroute.h netinet/if_ether.h) -AC_CHECK_HEADERS([linux/filter.h linux/netlink.h linux/rtnetlink.h], [], [], +AC_CHECK_HEADERS([linux/filter.h linux/if_addr.h linux/if_ether.h linux/if_tun.h linux/netlink.h linux/rtnetlink.h], [], [], [#ifdef HAVE_SYS_SOCKET_H #include <sys/socket.h> #endif diff --git a/libgo/go/debug/dwarf/line.go b/libgo/go/debug/dwarf/line.go index f9c77cc87e4..52c3b114da3 100644 --- a/libgo/go/debug/dwarf/line.go +++ b/libgo/go/debug/dwarf/line.go @@ -415,6 +415,10 @@ func (d *Data) addLine(lines []mapLineInfo, lineInfo Line, address uint64, line if newLineInfo { if len(lines) > 0 { sort.Sort(lines[len(lines)-1].addrs) + p := &lines[len(lines)-1] + if len(p.addrs) > 0 && address > p.addrs[len(p.addrs)-1].pc { + p.addrs = append(p.addrs, oneLineInfo{address, p.addrs[len(p.addrs)-1].line}) + } } lines = append(lines, mapLineInfo{line: lineInfo}) } diff --git a/libgo/go/net/http/fs_test.go b/libgo/go/net/http/fs_test.go index 5aa93ce5837..ffba6a7bcb7 100644 --- a/libgo/go/net/http/fs_test.go +++ b/libgo/go/net/http/fs_test.go @@ -396,7 +396,7 @@ func TestLinuxSendfile(t *testing.T) { defer ln.Close() var buf bytes.Buffer - child := exec.Command("strace", "-f", os.Args[0], "-test.run=TestLinuxSendfileChild") + child := exec.Command("strace", "-f", "-e!sigaltstack", os.Args[0], "-test.run=TestLinuxSendfileChild") child.ExtraFiles = append(child.ExtraFiles, lnf) child.Env = append([]string{"GO_WANT_HELPER_PROCESS=1"}, os.Environ()...) child.Stdout = &buf diff --git a/libgo/go/net/interface_linux.go b/libgo/go/net/interface_linux.go index 0d7017f301e..ce2e921e865 100644 --- a/libgo/go/net/interface_linux.go +++ b/libgo/go/net/interface_linux.go @@ -64,11 +64,7 @@ func newLink(ifim *syscall.IfInfomsg, attrs []syscall.NetlinkRouteAttr) Interfac case syscall.IFLA_IFNAME: ifi.Name = string(a.Value[:len(a.Value)-1]) case syscall.IFLA_MTU: - if syscall.BigEndian { - ifi.MTU = int(uint32(a.Value[0])<<24 | uint32(a.Value[1])<<16 | uint32(a.Value[2])<<8 | uint32(a.Value[3])) - } else { - ifi.MTU = int(uint32(a.Value[3])<<24 | uint32(a.Value[2])<<16 | uint32(a.Value[1])<<8 | uint32(a.Value[0])) - } + ifi.MTU = int(*(*uint32)(unsafe.Pointer(&a.Value[:4][0]))) } } return ifi @@ -197,15 +193,14 @@ func parseProcNetIGMP(path string, ifi *Interface) []Addr { name = f[1] case len(f[0]) == 8: if ifi == nil || name == ifi.Name { + // The Linux kernel puts the IP + // address in /proc/net/igmp in native + // endianness. for i := 0; i+1 < len(f[0]); i += 2 { b[i/2], _ = xtoi2(f[0][i:i+2], 0) } - var ifma IPAddr - if syscall.BigEndian { - ifma = IPAddr{IP: IPv4(b[0], b[1], b[2], b[3])} - } else { - ifma = IPAddr{IP: IPv4(b[3], b[2], b[1], b[0])} - } + i := *(*uint32)(unsafe.Pointer(&b[:4][0])) + ifma := IPAddr{IP: IPv4(byte(i>>24), byte(i>>16), byte(i>>8), byte(i))} ifmat = append(ifmat, ifma.toAddr()) } } diff --git a/libgo/go/os/stat.go b/libgo/go/os/stat.go index 789007206fa..01afa39e0f8 100644 --- a/libgo/go/os/stat.go +++ b/libgo/go/os/stat.go @@ -19,7 +19,7 @@ func fileInfoFromStat(st *syscall.Stat_t, name string) FileInfo { fs := &fileStat{ name: basename(name), size: int64(st.Size), - modTime: timespecToTime(st.Mtime), + modTime: timespecToTime(st.Mtim), sys: st, } fs.mode = FileMode(st.Mode & 0777) @@ -52,5 +52,5 @@ func timespecToTime(ts syscall.Timespec) time.Time { // For testing. func atime(fi FileInfo) time.Time { - return timespecToTime(fi.Sys().(*syscall.Stat_t).Atime) + return timespecToTime(fi.Sys().(*syscall.Stat_t).Atim) } diff --git a/libgo/go/os/stat_solaris.go b/libgo/go/os/stat_solaris.go index 93b698c3c4c..51a2f71e1be 100644 --- a/libgo/go/os/stat_solaris.go +++ b/libgo/go/os/stat_solaris.go @@ -19,7 +19,7 @@ func fileInfoFromStat(st *syscall.Stat_t, name string) FileInfo { fs := &fileStat{ name: basename(name), size: int64(st.Size), - modTime: timestrucToTime(st.Mtime), + modTime: timestrucToTime(st.Mtim), sys: st, } fs.mode = FileMode(st.Mode & 0777) @@ -52,5 +52,5 @@ func timestrucToTime(ts syscall.Timestruc) time.Time { // For testing. func atime(fi FileInfo) time.Time { - return timestrucToTime(fi.(*fileStat).Sys().(*syscall.Stat_t).Atime) + return timestrucToTime(fi.(*fileStat).Sys().(*syscall.Stat_t).Atim) } diff --git a/libgo/go/runtime/gc_test.go b/libgo/go/runtime/gc_test.go index 65894a6fd01..7770e499ad3 100644 --- a/libgo/go/runtime/gc_test.go +++ b/libgo/go/runtime/gc_test.go @@ -15,6 +15,8 @@ func TestGcSys(t *testing.T) { runtime.ReadMemStats(memstats) sys := memstats.Sys + runtime.MemProfileRate = 0 // disable profiler + itercount := 1000000 if testing.Short() { itercount = 100000 diff --git a/libgo/go/syscall/libcall_linux.go b/libgo/go/syscall/libcall_linux.go index f5358f53d9b..7c9f05e8d52 100644 --- a/libgo/go/syscall/libcall_linux.go +++ b/libgo/go/syscall/libcall_linux.go @@ -335,7 +335,7 @@ func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n i //sys Tee(rfd int, wfd int, len int, flags int) (n int64, err error) //tee(rfd int, wfd int, len Size_t, flags uint) Ssize_t -func Tgkill(tgid, tid, sig Signal) error { +func Tgkill(tgid int, tid int, sig Signal) error { r1, _, errno := Syscall(SYS_TGKILL, uintptr(tgid), uintptr(tid), uintptr(sig)) if r1 < 0 { return errno diff --git a/libgo/go/syscall/libcall_posix.go b/libgo/go/syscall/libcall_posix.go index 9961ba8ff2d..4f25b82649a 100644 --- a/libgo/go/syscall/libcall_posix.go +++ b/libgo/go/syscall/libcall_posix.go @@ -268,7 +268,7 @@ func Gettimeofday(tv *Timeval) (err error) { //sys Mknod(path string, mode uint32, dev int) (err error) //mknod(path *byte, mode Mode_t, dev _dev_t) int -//sys Mount(source string, target string, fstype string, flags int, data string) (err error) +//sys Mount(source string, target string, fstype string, flags uintptr, data string) (err error) //mount(source *byte, target *byte, fstype *byte, flags _C_long, data *byte) int //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) diff --git a/libgo/go/syscall/netlink_linux.go b/libgo/go/syscall/netlink_linux.go index 1c99a81785f..d535713069b 100644 --- a/libgo/go/syscall/netlink_linux.go +++ b/libgo/go/syscall/netlink_linux.go @@ -30,43 +30,12 @@ type NetlinkRouteRequest struct { func (rr *NetlinkRouteRequest) toWireFormat() []byte { b := make([]byte, rr.Header.Len) - if BigEndian { - b[0] = byte(rr.Header.Len >> 24) - b[1] = byte(rr.Header.Len >> 16) - b[2] = byte(rr.Header.Len >> 8) - b[3] = byte(rr.Header.Len) - b[4] = byte(rr.Header.Type >> 8) - b[5] = byte(rr.Header.Type) - b[6] = byte(rr.Header.Flags >> 8) - b[7] = byte(rr.Header.Flags) - b[8] = byte(rr.Header.Seq >> 24) - b[9] = byte(rr.Header.Seq >> 16) - b[10] = byte(rr.Header.Seq >> 8) - b[11] = byte(rr.Header.Seq) - b[12] = byte(rr.Header.Pid >> 24) - b[13] = byte(rr.Header.Pid >> 16) - b[14] = byte(rr.Header.Pid >> 8) - b[15] = byte(rr.Header.Pid) - b[16] = byte(rr.Data.Family) - } else { - b[0] = byte(rr.Header.Len) - b[1] = byte(rr.Header.Len >> 8) - b[2] = byte(rr.Header.Len >> 16) - b[3] = byte(rr.Header.Len >> 24) - b[4] = byte(rr.Header.Type) - b[5] = byte(rr.Header.Type >> 8) - b[6] = byte(rr.Header.Flags) - b[7] = byte(rr.Header.Flags >> 8) - b[8] = byte(rr.Header.Seq) - b[9] = byte(rr.Header.Seq >> 8) - b[10] = byte(rr.Header.Seq >> 16) - b[11] = byte(rr.Header.Seq >> 24) - b[12] = byte(rr.Header.Pid) - b[13] = byte(rr.Header.Pid >> 8) - b[14] = byte(rr.Header.Pid >> 16) - b[15] = byte(rr.Header.Pid >> 24) - b[16] = byte(rr.Data.Family) - } + *(*uint32)(unsafe.Pointer(&b[0:4][0])) = rr.Header.Len + *(*uint16)(unsafe.Pointer(&b[4:6][0])) = rr.Header.Type + *(*uint16)(unsafe.Pointer(&b[6:8][0])) = rr.Header.Flags + *(*uint32)(unsafe.Pointer(&b[8:12][0])) = rr.Header.Seq + *(*uint32)(unsafe.Pointer(&b[12:16][0])) = rr.Header.Pid + b[16] = byte(rr.Data.Family) return b } diff --git a/libgo/go/syscall/sockcmsg_unix.go b/libgo/go/syscall/sockcmsg_unix.go index 1faac84f4a6..943ebdd7209 100644 --- a/libgo/go/syscall/sockcmsg_unix.go +++ b/libgo/go/syscall/sockcmsg_unix.go @@ -39,7 +39,7 @@ func CmsgSpace(datalen int) int { } func cmsgData(cmsg *Cmsghdr) unsafe.Pointer { - return unsafe.Pointer(uintptr(unsafe.Pointer(cmsg)) + uintptr(SizeofCmsghdr)) + return unsafe.Pointer(uintptr(unsafe.Pointer(cmsg)) + SizeofCmsghdr) } type SocketControlMessage struct { @@ -72,7 +72,7 @@ func ParseSocketControlMessage(buf []byte) ([]SocketControlMessage, error) { func socketControlMessageHeaderAndData(buf []byte) (*Cmsghdr, []byte, error) { h := (*Cmsghdr)(unsafe.Pointer(&buf[0])) - if int(h.Len) < SizeofCmsghdr || int(h.Len) > len(buf) { + if h.Len < SizeofCmsghdr || int(h.Len) > len(buf) { return nil, nil, EINVAL } return h, buf[cmsgAlignOf(SizeofCmsghdr):], nil diff --git a/libgo/go/syscall/socket.go b/libgo/go/syscall/socket.go index 6d36e3985f3..973759086ce 100644 --- a/libgo/go/syscall/socket.go +++ b/libgo/go/syscall/socket.go @@ -22,7 +22,7 @@ type Sockaddr interface { type RawSockaddrAny struct { Addr RawSockaddr - Pad [12]int8 + Pad [96]int8 } const SizeofSockaddrAny = 0x1c diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh index 291fbb52cc0..487965bf3bf 100755 --- a/libgo/mksysinfo.sh +++ b/libgo/mksysinfo.sh @@ -40,6 +40,18 @@ cat > sysinfo.c <<EOF #include <sys/ttold.h> #endif #include <netinet/tcp.h> +#if defined(HAVE_NETINET_IN_SYSTM_H) +#include <netinet/in_systm.h> +#endif +#if defined(HAVE_NETINET_IP_H) +#include <netinet/ip.h> +#endif +#if defined(HAVE_NETINET_IP_MROUTE_H) +#include <netinet/ip_mroute.h> +#endif +#if defined(HAVE_NETINET_IF_ETHER_H) +#include <netinet/if_ether.h> +#endif #include <signal.h> #include <sys/ioctl.h> #include <termios.h> @@ -52,6 +64,9 @@ cat > sysinfo.c <<EOF #if defined(HAVE_SYS_EPOLL_H) #include <sys/epoll.h> #endif +#if defined(HAVE_SYS_FILE_H) +#include <sys/file.h> +#endif #if defined(HAVE_SYS_MMAN_H) #include <sys/mman.h> #endif @@ -85,6 +100,15 @@ cat > sysinfo.c <<EOF #if defined(HAVE_LINUX_FILTER_H) #include <linux/filter.h> #endif +#if defined(HAVE_LINUX_IF_ADDR_H) +#include <linux/if_addr.h> +#endif +#if defined(HAVE_LINUX_IF_ETHER_H) +#include <linux/if_ether.h> +#endif +#if defined(HAVE_LINUX_IF_TUN_H) +#include <linux/if_tun.h> +#endif #if defined(HAVE_LINUX_NETLINK_H) #include <linux/netlink.h> #endif @@ -97,6 +121,12 @@ cat > sysinfo.c <<EOF #if defined(HAVE_NET_IF_ARP_H) #include <net/if_arp.h> #endif +#if defined(HAVE_NET_ROUTE_H) +#include <net/route.h> +#endif +#if defined (HAVE_NETPACKET_PACKET_H) +#include <netpacket/packet.h> +#endif #if defined(HAVE_SYS_MOUNT_H) #include <sys/mount.h> #endif @@ -121,9 +151,15 @@ cat > sysinfo.c <<EOF #if defined(HAVE_LINUX_ETHER_H) #include <linux/ether.h> #endif +#if defined(HAVE_LINUX_FS_H) +#include <linux/fs.h> +#endif #if defined(HAVE_LINUX_REBOOT_H) #include <linux/reboot.h> #endif +#if defined(HAVE_SYS_INOTIFY_H) +#include <sys/inotify.h> +#endif /* Constants that may only be defined as expressions on some systems, expressions too complex for -fdump-go-spec to handle. These are @@ -199,6 +235,8 @@ grep '^const _MAP_' gen-sysinfo.go | \ sed -e 's/^\(const \)_\(MAP_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} grep '^const _MADV_' gen-sysinfo.go | \ sed -e 's/^\(const \)_\(MADV_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} +grep '^const _MCL_' gen-sysinfo.go | \ + sed -e 's/^\(const \)_\(MCL_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} # Process status constants. grep '^const _W' gen-sysinfo.go | @@ -236,6 +274,10 @@ done grep '^const __PC' gen-sysinfo.go | sed -e 's/^\(const \)__\(PC[^= ]*\)\(.*\)$/\1\2 = __\2/' >> ${OUT} +# The PATH_MAX constant. +grep '^const _PATH_MAX ' gen-sysinfo.go | + echo 'const PathMax = _PATH_MAX' >> ${OUT} + # epoll constants. grep '^const _EPOLL' gen-sysinfo.go | sed -e 's/^\(const \)_\(EPOLL[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} @@ -435,9 +477,9 @@ fi | sed -e 's/type _stat64/type Stat_t/' \ -e 's/st_size/Size/' \ -e 's/st_blksize/Blksize/' \ -e 's/st_blocks/Blocks/' \ - -e 's/st_atim/Atime/' \ - -e 's/st_mtim/Mtime/' \ - -e 's/st_ctim/Ctime/' \ + -e 's/st_atim/Atim/' \ + -e 's/st_mtim/Mtim/' \ + -e 's/st_ctim/Ctim/' \ -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \ -e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \ -e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \ @@ -551,9 +593,6 @@ if test -n "$cmsghdr"; then -e 's/cmsg_type/Type/' \ -e 's/\[\]/[0]/' \ >> ${OUT} - - # The size of the cmsghdr struct. - echo 'var SizeofCmsghdr = int(unsafe.Sizeof(Cmsghdr{}))' >> ${OUT} fi # The SCM_ flags for Cmsghdr. @@ -568,11 +607,6 @@ grep '^type _ucred ' gen-sysinfo.go | \ -e 's/gid/Gid/' \ >> ${OUT} -# The size of the ucred struct. -if grep 'type Ucred ' ${OUT} >/dev/null 2>&1; then - echo 'var SizeofUcred = int(unsafe.Sizeof(Ucred{}))' >> ${OUT} -fi - # The ip_mreq struct. grep '^type _ip_mreq ' gen-sysinfo.go | \ sed -e 's/_ip_mreq/IPMreq/' \ @@ -586,9 +620,6 @@ if ! grep 'type IPMreq ' ${OUT} >/dev/null 2>&1; then echo 'type IPMreq struct { Multiaddr [4]byte; Interface [4]byte; }' >> ${OUT} fi -# The size of the ip_mreq struct. -echo 'var SizeofIPMreq = int(unsafe.Sizeof(IPMreq{}))' >> ${OUT} - # The ipv6_mreq struct. grep '^type _ipv6_mreq ' gen-sysinfo.go | \ sed -e 's/_ipv6_mreq/IPv6Mreq/' \ @@ -602,9 +633,6 @@ if ! grep 'type IPv6Mreq ' ${OUT} >/dev/null 2>&1; then echo 'type IPv6Mreq struct { Multiaddr [16]byte; Interface uint32; }' >> ${OUT} fi -# The size of the ipv6_mreq struct. -echo 'var SizeofIPv6Mreq = int(unsafe.Sizeof(IPv6Mreq{}))' >> ${OUT} - # The ip_mreqn struct. grep '^type _ip_mreqn ' gen-sysinfo.go | \ sed -e 's/_ip_mreqn/IPMreqn/' \ @@ -619,9 +647,6 @@ if ! grep 'type IPMreqn ' ${OUT} >/dev/null 2>&1; then echo 'type IPMreqn struct { Multiaddr [4]byte; Interface [4]byte; Ifindex int32 }' >> ${OUT} fi -# The size of the ip_mreqn struct. -echo 'var SizeofIPMreqn = int(unsafe.Sizeof(IPMreqn{}))' >> ${OUT} - # Try to guess the type to use for fd_set. fd_set=`grep '^type _fd_set ' gen-sysinfo.go || true` fds_bits_type="_C_long" @@ -687,8 +712,8 @@ grep '^const _NLM' gen-sysinfo.go | \ # NLMSG_HDRLEN is defined as an expression using sizeof. if ! grep '^const NLMSG_HDRLEN' ${OUT} > /dev/null 2>&1; then - if grep '^type NlMsghdr ' ${OUT} > /dev/null 2>&1; then - echo 'var NLMSG_HDRLEN = int((unsafe.Sizeof(NlMsghdr{}) + (NLMSG_ALIGNTO-1)) &^ (NLMSG_ALIGNTO-1))' >> ${OUT} + if grep '^const _sizeof_nlmsghdr ' ${OUT} > /dev/null 2>&1; then + echo 'const NLMSG_HDRLEN = (_sizeof_nlmsghdr + (NLMSG_ALIGNTO-1)) &^ (NLMSG_ALIGNTO-1)' >> ${OUT} fi fi @@ -700,17 +725,12 @@ grep '^type _rtmsg ' gen-sysinfo.go | \ -e 's/rtm_src_len/Src_len/' \ -e 's/rtm_tos/Tos/' \ -e 's/rtm_table/Table/' \ - -e 's/rtm_protocol/Procotol/' \ + -e 's/rtm_protocol/Protocol/' \ -e 's/rtm_scope/Scope/' \ -e 's/rtm_type/Type/' \ -e 's/rtm_flags/Flags/' \ >> ${OUT} -# The size of the rtmsg struct. -if grep 'type RtMsg ' ${OUT} > /dev/null 2>&1; then - echo 'var SizeofRtMsg = int(unsafe.Sizeof(RtMsg{}))' >> ${OUT} -fi - # The rtgenmsg struct. grep '^type _rtgenmsg ' gen-sysinfo.go | \ sed -e 's/_rtgenmsg/RtGenmsg/' \ @@ -718,6 +738,8 @@ grep '^type _rtgenmsg ' gen-sysinfo.go | \ >> ${OUT} # The routing message flags. +grep '^const _RT_' gen-sysinfo.go | \ + sed -e 's/^\(const \)_\(RT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} grep '^const _RTA' gen-sysinfo.go | \ sed -e 's/^\(const \)_\(RTA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} grep '^const _RTF' gen-sysinfo.go | \ @@ -726,11 +748,10 @@ grep '^const _RTCF' gen-sysinfo.go | \ sed -e 's/^\(const \)_\(RTCF[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} grep '^const _RTM' gen-sysinfo.go | \ sed -e 's/^\(const \)_\(RTM[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} - -# The size of the rtgenmsg struct. -if grep 'type RtGenmsg ' ${OUT} > /dev/null 2>&1; then - echo 'var SizeofRtGenmsg = int(unsafe.Sizeof(RtGenmsg{}))' >> ${OUT} -fi +grep '^const _RTN' gen-sysinfo.go | \ + sed -e 's/^\(const \)_\(RTN[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} +grep '^const _RTPROT' gen-sysinfo.go | \ + sed -e 's/^\(const \)_\(RTPROT[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} # The ifinfomsg struct. grep '^type _ifinfomsg ' gen-sysinfo.go | \ @@ -754,11 +775,6 @@ grep '^const _IFNAMSIZ' gen-sysinfo.go | \ grep '^const _SIOC' gen-sysinfo.go | sed -e 's/^\(const \)_\(SIOC[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} -# The size of the ifinfomsg struct. -if grep 'type IfInfomsg ' ${OUT} > /dev/null 2>&1; then - echo 'var SizeofIfInfomsg = int(unsafe.Sizeof(IfInfomsg{}))' >> ${OUT} -fi - # The ifaddrmsg struct. grep '^type _ifaddrmsg ' gen-sysinfo.go | \ sed -e 's/_ifaddrmsg/IfAddrmsg/' \ @@ -769,11 +785,6 @@ grep '^type _ifaddrmsg ' gen-sysinfo.go | \ -e 's/ifa_index/Index/' \ >> ${OUT} -# The size of the ifaddrmsg struct. -if grep 'type IfAddrmsg ' ${OUT} > /dev/null 2>&1; then - echo 'var SizeofIfAddrmsg = int(unsafe.Sizeof(IfAddrmsg{}))' >> ${OUT} -fi - # The rtattr struct. grep '^type _rtattr ' gen-sysinfo.go | \ sed -e 's/_rtattr/RtAttr/' \ @@ -781,10 +792,22 @@ grep '^type _rtattr ' gen-sysinfo.go | \ -e 's/rta_type/Type/' \ >> ${OUT} -# The size of the rtattr struct. -if grep 'type RtAttr ' ${OUT} > /dev/null 2>&1; then - echo 'var SizeofRtAttr = int(unsafe.Sizeof(RtAttr{}))' >> ${OUT} -fi +# The in_pktinfo struct. +grep '^type _in_pktinfo ' gen-sysinfo.go | \ + sed -e 's/_in_pktinfo/Inet4Pktinfo/' \ + -e 's/ipi_ifindex/Ifindex/' \ + -e 's/ipi_spec_dst/Spec_dst/' \ + -e 's/ipi_addr/Addr/' \ + -e 's/_in_addr/[4]byte/g' \ + >> ${OUT} + +# The in6_pktinfo struct. +grep '^type _in6_pktinfo ' gen-sysinfo.go | \ + sed -e 's/_in6_pktinfo/Inet6Pktinfo/' \ + -e 's/ipi6_addr/Addr/' \ + -e 's/ipi6_ifindex/Ifindex/' \ + -e 's/_in6_addr/[16]byte/' \ + >> ${OUT} # The termios struct. grep '^type _termios ' gen-sysinfo.go | \ @@ -811,13 +834,15 @@ for n in IGNBRK BRKINT IGNPAR PARMRK INPCK ISTRIP INLCR IGNCR ICRNL IUCLC \ TCSAFLUSH TCIFLUSH TCOFLUSH TCIOFLUSH TCOOFF TCOON TCIOFF TCION B0 B50 \ B75 B110 B134 B150 B200 B300 B600 B1200 B1800 B2400 B4800 B9600 B19200 \ B38400 B57600 B115200 B230400 B460800 B500000 B576000 B921600 B1000000 \ - B1152000 B1500000 B2000000 B2500000 B3000000 B4000000; do + B1152000 B1500000 B2000000 B2500000 B3000000 B3500000 B4000000; do grep "^const _$n " gen-sysinfo.go | \ sed -e 's/^\(const \)_\([^=]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} done # The mount flags +grep '^const _MNT_' gen-sysinfo.go | + sed -e 's/^\(const \)_\(MNT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} grep '^const _MS_' gen-sysinfo.go | sed -e 's/^\(const \)_\(MS_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} @@ -893,6 +918,8 @@ grep '^type _rlimit ' gen-sysinfo.go | \ # The RLIMIT constants. grep '^const _RLIMIT_' gen-sysinfo.go | sed -e 's/^\(const \)_\(RLIMIT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} +grep '^const _RLIM_' gen-sysinfo.go | + sed -e 's/^\(const \)_\(RLIM_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} # The sysinfo struct. grep '^type _sysinfo ' gen-sysinfo.go | \ @@ -932,6 +959,10 @@ grep '^type _utimbuf ' gen-sysinfo.go | \ -e 's/modtime/Modtime/' \ >> ${OUT} +# The LOCK flags for flock. +grep '^const _LOCK_' gen-sysinfo.go | + sed -e 's/^\(const \)_\(LOCK_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} + # The GNU/Linux LINUX_REBOOT flags. grep '^const _LINUX_REBOOT_' gen-sysinfo.go | sed -e 's/^\(const \)_\(LINUX_REBOOT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} @@ -957,9 +988,84 @@ grep '^type _sock_fprog ' gen-sysinfo.go | \ grep '^const _BPF_' gen-sysinfo.go | \ sed -e 's/^\(const \)_\(BPF_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} +# The GNU/Linux nlattr struct. +grep '^type _nlattr ' gen-sysinfo.go | \ + sed -e 's/_nlattr/NlAttr/' \ + -e 's/nla_len/Len/' \ + -e 's/nla_type/Type/' \ + >> ${OUT} + +# The GNU/Linux nlmsgerr struct. +grep '^type _nlmsgerr ' gen-sysinfo.go | \ + sed -e 's/_nlmsgerr/NlMsgerr/' \ + -e 's/error/Error/' \ + -e 's/msg/Msg/' \ + -e 's/_nlmsghdr/NlMsghdr/' \ + >> ${OUT} + +# The GNU/Linux rtnexthop struct. +grep '^type _rtnexthop ' gen-sysinfo.go | \ + sed -e 's/_rtnexthop/RtNexthop/' \ + -e 's/rtnh_len/Len/' \ + -e 's/rtnh_flags/Flags/' \ + -e 's/rtnh_hops/Hops/' \ + -e 's/rtnh_ifindex/Ifindex/' \ + >> ${OUT} + +# The GNU/Linux netlink flags. +grep '^const _NETLINK_' gen-sysinfo.go | \ + sed -e 's/^\(const \)_\(NETLINK_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} +grep '^const _NLA_' gen-sysinfo.go | \ + sed -e 's/^\(const \)_\(NLA_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} + +# The GNU/Linux packet socket flags. +grep '^const _PACKET_' gen-sysinfo.go | \ + sed -e 's/^\(const \)_\(PACKET_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} + +# The GNU/Linux inotify_event struct. +grep '^type _inotify_event ' gen-sysinfo.go | \ + sed -e 's/_inotify_event/InotifyEvent/' \ + -e 's/wd/Wd/' \ + -e 's/mask/Mask/' \ + -e 's/cookie/Cookie/' \ + -e 's/len/Len/' \ + -e 's/name/Name/' \ + -e 's/\[\]/[0]/' \ + -e 's/\[0\]byte/[0]int8/' \ + >> ${OUT} + # The Solaris 11 Update 1 _zone_net_addr_t struct. grep '^type _zone_net_addr_t ' gen-sysinfo.go | \ sed -e 's/_in6_addr/[16]byte/' \ >> ${OUT} +# Struct sizes. +set cmsghdr Cmsghdr ip_mreq IPMreq ip_mreqn IPMreqn ipv6_mreq IPv6Mreq \ + ifaddrmsg IfAddrmsg ifinfomsg IfInfomsg in_pktinfo Inet4Pktinfo \ + in6_pktinfo Inet6Pktinfo inotify_event InotifyEvent linger Linger \ + msghdr Msghdr nlattr NlAttr nlmsgerr NlMsgerr nlmsghdr NlMsghdr \ + rtattr RtAttr rtgenmsg RtGenmsg rtmsg RtMsg rtnexthop RtNexthop \ + sock_filter SockFilter sock_fprog SockFprog ucred Ucred +while test $# != 0; do + nc=$1 + ngo=$2 + shift + shift + if grep "^const _sizeof_$nc =" gen-sysinfo.go >/dev/null 2>&1; then + echo "const Sizeof$ngo = _sizeof_$nc" >> ${OUT} + fi +done + +# In order to compile the net package, we need some sizes to exist +# even if the types do not. +if ! grep 'const SizeofIPMreq ' ${OUT} >/dev/null 2>&1; then + echo 'const SizeofIPMreq = 8' >> ${OUT} +fi +if ! grep 'const SizeofIPv6Mreq ' ${OUT} >/dev/null 2>&1; then + echo 'const SizeofIPv6Mreq = 20' >> ${OUT} +fi +if ! grep 'const SizeofIPMreqn ' ${OUT} >/dev/null 2>&1; then + echo 'const SizeofIPMreqn = 12' >> ${OUT} +fi + exit $? diff --git a/libgo/runtime/go-runtime-error.c b/libgo/runtime/go-runtime-error.c index f732e7f017f..68db8acd8b1 100644 --- a/libgo/runtime/go-runtime-error.c +++ b/libgo/runtime/go-runtime-error.c @@ -46,7 +46,10 @@ enum MAKE_MAP_OUT_OF_BOUNDS = 8, /* Channel capacity out of bounds in make: negative or overflow. */ - MAKE_CHAN_OUT_OF_BOUNDS = 9 + MAKE_CHAN_OUT_OF_BOUNDS = 9, + + /* Integer division by zero. */ + DIVISION_BY_ZERO = 10 }; extern void __go_runtime_error () __attribute__ ((noreturn)); @@ -78,6 +81,9 @@ __go_runtime_error (int i) case MAKE_CHAN_OUT_OF_BOUNDS: runtime_panicstring ("make chan len out of range"); + case DIVISION_BY_ZERO: + runtime_panicstring ("integer divide by zero"); + default: runtime_panicstring ("unknown runtime error"); } diff --git a/libgo/runtime/malloc.goc b/libgo/runtime/malloc.goc index 97cfabe040a..253fdbe0ccb 100644 --- a/libgo/runtime/malloc.goc +++ b/libgo/runtime/malloc.goc @@ -72,7 +72,7 @@ runtime_mallocgc(uintptr size, uint32 flag, int32 dogc, int32 zeroed) npages = size >> PageShift; if((size & PageMask) != 0) npages++; - s = runtime_MHeap_Alloc(&runtime_mheap, npages, 0, !(flag & FlagNoGC)); + s = runtime_MHeap_Alloc(&runtime_mheap, npages, 0, 1); if(s == nil) runtime_throw("out of memory"); size = npages<<PageShift; diff --git a/libgo/runtime/mgc0.c b/libgo/runtime/mgc0.c index 4aa7c45dcb3..7e68535ebfd 100644 --- a/libgo/runtime/mgc0.c +++ b/libgo/runtime/mgc0.c @@ -4,6 +4,8 @@ // Garbage collector. +#include <unistd.h> + #include "runtime.h" #include "arch.h" #include "malloc.h" @@ -918,7 +920,7 @@ cachestats(void) uint64 stacks_sys; stacks_inuse = 0; - stacks_sys = 0; + stacks_sys = runtime_stacks_sys; for(m=runtime_allm; m; m=m->alllink) { runtime_purgecachedstats(m); // stacks_inuse += m->stackalloc->inuse; @@ -1020,7 +1022,7 @@ runtime_gc(int32 force) stealcache(); cachestats(); - mstats.next_gc = mstats.heap_alloc+mstats.heap_alloc*gcpercent/100; + mstats.next_gc = mstats.heap_alloc+(mstats.heap_alloc-runtime_stacks_sys)*gcpercent/100; m->gcing = 0; m->locks++; // disable gc during the mallocs in newproc @@ -1329,6 +1331,8 @@ runtime_setblockspecial(void *v, bool s) void runtime_MHeap_MapBits(MHeap *h) { + size_t page_size; + // Caller has added extra mappings to the arena. // Add extra mappings of bitmap words as needed. // We allocate extra bitmap pieces in chunks of bitmapChunk. @@ -1342,6 +1346,9 @@ runtime_MHeap_MapBits(MHeap *h) if(h->bitmap_mapped >= n) return; + page_size = getpagesize(); + n = (n+page_size-1) & ~(page_size-1); + runtime_SysMap(h->arena_start - n, n - h->bitmap_mapped); h->bitmap_mapped = n; } diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c index 9ad9f9659b9..660c69fc03c 100644 --- a/libgo/runtime/proc.c +++ b/libgo/runtime/proc.c @@ -46,6 +46,8 @@ extern void __splitstack_block_signals_context (void *context[10], int *, # define StackMin 2 * 1024 * 1024 #endif +uintptr runtime_stacks_sys; + static void schedule(G*); typedef struct Sched Sched; @@ -1091,6 +1093,7 @@ schedule(G *gp) m->lockedg = nil; } gp->idlem = nil; + runtime_memclr(&gp->context, sizeof gp->context); gfput(gp); if(--runtime_sched.gcount == 0) runtime_exit(0); @@ -1288,6 +1291,7 @@ runtime_malg(int32 stacksize, byte** ret_stack, size_t* ret_stacksize) *ret_stacksize = stacksize; newg->gcinitial_sp = *ret_stack; newg->gcstack_size = stacksize; + runtime_xadd(&runtime_stacks_sys, stacksize); #endif } return newg; diff --git a/libgo/runtime/runtime.h b/libgo/runtime/runtime.h index a81c210a2b8..d379f99f8da 100644 --- a/libgo/runtime/runtime.h +++ b/libgo/runtime/runtime.h @@ -463,3 +463,8 @@ struct root_list { }; void __go_register_gc_roots(struct root_list*); + +// Size of stack space allocated using Go's allocator. +// This will be 0 when using split stacks, as in that case +// the stacks are allocated by the splitstack library. +extern uintptr runtime_stacks_sys; diff --git a/libgo/testsuite/Makefile.in b/libgo/testsuite/Makefile.in index 92defa60b52..1d1e05e7ae3 100644 --- a/libgo/testsuite/Makefile.in +++ b/libgo/testsuite/Makefile.in @@ -86,7 +86,6 @@ GOARCH = @GOARCH@ GOC = @GOC@ GOCFLAGS = @GOCFLAGS@ GOOS = @GOOS@ -GO_BIGENDIAN = @GO_BIGENDIAN@ GO_LIBCALL_OS_ARCH_FILE = @GO_LIBCALL_OS_ARCH_FILE@ GO_LIBCALL_OS_FILE = @GO_LIBCALL_OS_FILE@ GO_SYSCALL_OS_ARCH_FILE = @GO_SYSCALL_OS_ARCH_FILE@ diff --git a/libgo/testsuite/gotest b/libgo/testsuite/gotest index aac67bfbcfb..c6966fa7d4c 100755 --- a/libgo/testsuite/gotest +++ b/libgo/testsuite/gotest @@ -347,18 +347,18 @@ localname() { pattern='Test([^a-z].*)?' # The -p option tells GNU nm not to sort. # The -v option tells Solaris nm to sort by value. - tests=$($NM -p -v _gotest_.o $xofile | egrep " $text .*\."$pattern'$' | grep -v '\..*\..*\.' | fgrep -v '$' | sed 's/.* //' | sed 's/.*\.\(.*\.\)/\1/') + tests=$($NM -p -v _gotest_.o $xofile | egrep " $text .*\."$pattern'$' | grep -v '\..*\..*\.' | fgrep -v '$' | fgrep -v ' __go_' | sed 's/.* //' | sed 's/.*\.\(.*\.\)/\1/') if [ "x$tests" = x ]; then echo 'gotest: warning: no tests matching '$pattern in _gotest_.o $xofile 1>&2 exit 2 fi # benchmarks are named BenchmarkFoo. pattern='Benchmark([^a-z].*)?' - benchmarks=$($NM -p -v _gotest_.o $xofile | egrep ' T .*\.'$pattern'$' | grep -v '\..*\..*\.' | fgrep -v '$' | sed 's/.* //' | sed 's/.*\.\(.*\.\)/\1/') + benchmarks=$($NM -p -v _gotest_.o $xofile | egrep " $test .*\."$pattern'$' | grep -v '\..*\..*\.' | fgrep -v '$' | fgrep -v ' __go_' | sed 's/.* //' | sed 's/.*\.\(.*\.\)/\1/') # examples are named ExampleFoo pattern='Example([^a-z].*)?' - examples=$($NM -p -v _gotest_.o $xofile | egrep ' T .*\.'$pattern'$' | grep -v '\..*\..*\.' | fgrep -v '$' | sed 's/.* //' | sed 's/.*\.\(.*\.\)/\1/') + examples=$($NM -p -v _gotest_.o $xofile | egrep " $text .*\."$pattern'$' | grep -v '\..*\..*\.' | fgrep -v '$' | fgrep -v ' __go_' | sed 's/.* //' | sed 's/.*\.\(.*\.\)/\1/') # package spec echo 'package main' |