gcc/libgo/mksysinfo.sh

1522 lines
52 KiB
Bash
Raw Normal View History

#!/bin/sh
# Copyright 2009 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.
# Create sysinfo.go from gen-sysinfo.go and errno.i.
# This shell script creates the sysinfo.go file which holds types and
# constants extracted from the system header files. This reads the
# raw data from gen-sysinfo.go which is generated using the
# -fdump-go-spec option.
# This currently exposes some names that ideally should not be
# exposed, as they match grep patterns. E.g., WCHAR_MIN gets exposed
# because it starts with W, like the wait flags.
OUT=tmp-sysinfo.go
set -e
echo 'package syscall' > ${OUT}
echo 'import "unsafe"' >> ${OUT}
echo 'type _ unsafe.Pointer' >> ${OUT}
# Get all the consts and types, skipping ones which could not be
# represented in Go and ones which we need to rewrite. We also skip
# function declarations, as we don't need them here. All the symbols
# will all have a leading underscore.
grep -v '^// ' gen-sysinfo.go | \
grep -v '^func' | \
grep -v '^var' | \
grep -v '^type _timeval ' | \
grep -v '^type _timespec_t ' | \
grep -v '^type _timespec ' | \
grep -v '^type _timestruc_t ' | \
grep -v '^type _epoll_' | \
grep -v '^type _*locale[_ ]' | \
grep -v '^type _in6_addr' | \
grep -v 'sockaddr_in6' | \
egrep -v '^const _*FLT(64|128)_(NORM_)?MAX' | \
sed -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \
-e 's/\([^a-zA-Z0-9_]\)_timeval$/\1Timeval/g' \
-e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
-e 's/\([^a-zA-Z0-9_]\)_timespec_t$/\1Timespec/g' \
-e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
-e 's/\([^a-zA-Z0-9_]\)_timespec$/\1Timespec/g' \
-e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \
-e 's/\([^a-zA-Z0-9_]\)_timestruc_t$/\1Timestruc/g' \
-e 's/\([^a-zA-Z0-9_]\)_in6_addr\([^a-zA-Z0-9_]\)/\1[16]byte\2/g' \
-e 's/\([^a-zA-Z0-9_]\)_in6_addr$/\1[16]byte/g' \
-e 's/\([^a-zA-Z0-9_]\)_in6_addr_t\([^a-zA-Z0-9_]\)/\1[16]byte\2/g' \
-e 's/\([^a-zA-Z0-9_]\)_in6_addr_t$/\1[16]byte/g' \
>> ${OUT}
# The errno constants. These get type Errno.
egrep '#define E[A-Z0-9_]+ [0-9E]' errno.i | \
sed -e 's/^#define \(E[A-Z0-9_]*\) .*$/const \1 = Errno(_\1)/' >> ${OUT}
# Workaround for GNU/Hurd _EMIG_* errors having negative values
egrep '#define E[A-Z0-9_]+ -[0-9]' errno.i | \
sed -e 's/^#define \(E[A-Z0-9_]*\) .*$/const \1 = Errno(-_\1)/' >> ${OUT}
# The O_xxx flags.
egrep '^const _(O|F|FD)_' gen-sysinfo.go | \
sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
if ! grep '^const O_ASYNC' ${OUT} >/dev/null 2>&1; then
echo "const O_ASYNC = 0" >> ${OUT}
fi
if ! grep '^const O_CLOEXEC' ${OUT} >/dev/null 2>&1; then
echo "const O_CLOEXEC = 0" >> ${OUT}
fi
# The os package requires F_DUPFD_CLOEXEC to be defined.
if ! grep '^const F_DUPFD_CLOEXEC' ${OUT} >/dev/null 2>&1; then
echo "const F_DUPFD_CLOEXEC = 0" >> ${OUT}
fi
# The internal/poll package requires F_GETPIPE_SZ to be defined.
if ! grep '^const F_GETPIPE_SZ' ${OUT} >/dev/null 2>&1; then
echo "const F_GETPIPE_SZ = 0" >> ${OUT}
fi
Big merge of changes to gofrontend repo that were postponed due to the GCC release freeze. * go-backend.c: Include "go-c.h". * go-gcc.cc (Gcc_backend::write_export_data): New method. * go-gcc.cc (Gcc_backend::Gcc_backend): Declare __builtin_prefetch. * Make-lang.in (GO_OBJS): Add go/wb.o. commit 884c9f2cafb3fc1decaca70f1817ae269e4c6889 Author: Than McIntosh <thanm@google.com> Date: Mon Jan 23 15:07:07 2017 -0500 compiler: insert additional conversion for type desc ptr expr Change the method Type::type_descriptor_pointer to apply an additional type conversion to its result Bexpression, to avoid type clashes in the back end. The backend expression for a given type descriptor var is given a type of "_type", however the virtual calls that create the variable use types derived from _type, hence the need to force a conversion. Reviewed-on: https://go-review.googlesource.com/35506 commit 5f0647c71e3b29eddcd0eecc44e7ba44ae7fc8dd Author: Than McIntosh <thanm@google.com> Date: Mon Jan 23 15:22:26 2017 -0500 compiler: insure tree integrity in Call_expression::set_result Depending on the back end, it can be problematic to reuse Bexpressions (passing the same Bexpression to more than one Backend call to create additional Bexpressions or Bstatements). The Call_expression::set_result method was reusing its Bexpression input in more than one tree context; the fix is to pass in an Expression instead and generate multiple Bexpression references to it within the method. Reviewed-on: https://go-review.googlesource.com/35505 commit 7a8e49870885af898c3c790275e513d1764a2828 Author: Ian Lance Taylor <iant@golang.org> Date: Tue Jan 24 21:19:06 2017 -0800 runtime: copy more of the scheduler from the Go 1.8 runtime Copies mstart, newm, m0, g0, and friends. Reviewed-on: https://go-review.googlesource.com/35645 commit 3546e2f002d0277d805ec59c5403bc1d4eda4ed9 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Jan 26 19:47:37 2017 -0800 runtime: remove a few C functions that are no longer used Reviewed-on: https://go-review.googlesource.com/35849 commit a71b835254f6d3164a0e6beaf54f2b175d1a6a92 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Jan 26 16:51:16 2017 -0800 runtime: copy over more of the Go 1.8 scheduler In particular __go_go (aka newproc) and goexit[01]. Reviewed-on: https://go-review.googlesource.com/35847 commit c3ffff725adbe54d8283c373b6aa7dc95d6fc27f Author: Ian Lance Taylor <iant@golang.org> Date: Fri Jan 27 16:58:20 2017 -0800 runtime: copy syscall handling from Go 1.8 runtime Entering a syscall still has to start in C, to save the registers. Fix entersyscallblock to save them more reliably. This copies over the tracing code for syscalls, which we previously weren't doing, and lets us turn on runtime/trace/check. Reviewed-on: https://go-review.googlesource.com/35912 commit d5b921de4a28b04000fc4c8dac7f529a4a624dfc Author: Ian Lance Taylor <iant@golang.org> Date: Fri Jan 27 18:34:11 2017 -0800 runtime: copy SIGPROF handling from Go 1.8 runtime Also copy over Breakpoint. Fix Func.Name and Func.Entry to not crash on a nil Func. Reviewed-on: https://go-review.googlesource.com/35913 commit cc60235e55aef14b15c3d2114030245beb3adfef Author: Than McIntosh <thanm@google.com> Date: Mon Feb 6 11:12:12 2017 -0500 compiler: convert go_write_export_data to Backend method. Convert the helper function 'go_write_export_data' into a Backend class method, to allow for an implementation of this function that needs to access backend state. Reviewed-on: https://go-review.googlesource.com/36357 commit e387439bfd24d5e142874b8e68e7039f74c744d7 Author: Than McIntosh <thanm@google.com> Date: Wed Feb 8 11:13:46 2017 -0500 compiler: insert backend conversion in temporary statement init Insert an additional type conversion in Temporary_statement::do_get_backend when assigning a Bexpression initializer to the temporary variable, to avoid potential clashes in the back end. This can come up when assigning something of concrete pointer-to-function type to a variable of generic pointer-to-function type. Reviewed-on: https://go-review.googlesource.com/36591 commit c5acf0ce09e61ff623847a35a99da465b8571609 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 1 17:57:53 2017 +0100 libgo: build tags for aix Build tags for the libgo source files required to build libgo on AIX. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37633 commit 67ed19616898ea18a101ec9325b82d028cd395d9 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 2 15:41:31 2017 +0100 libgo: handle AIX tag in match.sh and gotest Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37638 commit 83ea2d694c10b2dd83fc8620c43da13d20db754e Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 1 17:48:16 2017 +0100 libgo: add AIX support in configure and Makefile - support for GOOS=aix - CFLAGS/GOCFLAGS/LDFLAGS for AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37632 commit 35d577fe22ffa16a3ccaadf5dae9f6f425c8ec8c Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Mon Mar 6 15:00:15 2017 +0100 runtime: adapt memory management to AIX mmap On AIX: * mmap does not allow to map an already mapped range, * mmap range start at 0x30000000 for 32 bits processes, * mmap range start at 0x70000000_00000000 for 64 bits processes Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37845 commit 4e49e56a5fd4072b4ca7fcefe4158d6885d9ee62 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Mon Mar 6 13:42:26 2017 +0100 runtime: add getproccount implementation for AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37844 commit ff626470294237ac664127894826614edc46a3d0 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Mon Mar 6 17:31:21 2017 +0100 runtime: handle ERESTART errno with AIX's wait4 On AIX, wait4 may return with errno set to ERESTART, which causes unexepected behavior (for instance, go build may exit with the message "wait: restart system call" after running a command, even if it was successfull). Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37846 commit 37daabbfc83d533b826ef9ab10e2dee7406e7198 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Mon Mar 6 11:02:58 2017 +0100 runtime: support for AIX's procfs tree On AIX, the process executable file is available under /proc/<pid>/object/a.out Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37842 commit a0275c039d56acf4bf48151978c1a4ec5758cc2c Author: Ian Lance Taylor <iant@golang.org> Date: Wed Mar 8 07:00:05 2017 -0800 libgo/Makefile.am: don't use nonportable \n or \t in sed expression The resulting zstdpktlist.go is less pretty, but it works. Reviewed-on: https://go-review.googlesource.com/37940 commit 29b190f76105aafa2b50b48249afdafecc97a4be Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 9 16:02:34 2017 +0100 runtime: netpoll and semaphores for AIX semaphore implementation based on Solaris implementation in libgo/go/runtime/os_solaris.go netpoll is just a stub to avoid build failure on AIX. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37966 commit 55ca6d3f3cddf0ff9ccb074b2694da9fc54de7ec Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 9 15:38:30 2017 +0100 libmain: ensure initfn is called when loading a go library AIX does not support .init_array. The alterative is to export the __go_init function and tell the linker it is an init function with the -Wl,-binitfini:__go_init option. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37965 commit 349a30d17d880ac8bc1a35e1a2ffee6d6e870ae9 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Mar 10 11:15:08 2017 +0100 libgo: use an import list for missing symbols libgo depends on symbols provided by Go programs at runtime. On AIX, this requires either to build libgo with -Wl,-berok linker option and the programs with -Wl,-brtl, or to provide a list of imported symbols when building libgo. The second options seems preferable, to avoid requiring an additional option for every Go program. There are also some symbols that are specific to GNU ld and do not exist when linking with AIX ld (__data_start, __edata, __etext and __bss_start). Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37969 commit 91db0ea1ff068ca1d97b9c99612100ea5b96ddb2 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 8 15:34:45 2017 +0100 crypto/x509: add certificate files locations for AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37952 commit 92e521c854e91709b949548c47e267377850f26a Author: Ian Lance Taylor <iant@golang.org> Date: Fri Mar 10 14:10:11 2017 -0800 compiler: fix check for pointer in Temporary_reference_expression The check for an unrepresentable pointer in Temporary_reference_expression::do_get_backend was incorrectly translated from C to Go in https://golang.org/cl/14346043. Fix the check to use points_to rather than has_pointer and deref. This should not make any difference in practice as either way the condition will only be true for a pointer to void, but points_to is correct and more efficient. Reviewed-on: https://go-review.googlesource.com/38009 commit 9a0b676e59e7171a630c48fdc3d4de6712bad0ca Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 16 16:51:53 2017 +0100 libgo: add missing _arpcom struct to *sysinfo.go This struct is filtered due to having a field of type _in6_addr, but other types exported to *sysinfo.go are depending on it. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38251 commit 61262a757bdd3d9a595ab6a90f68c0c4ebed7bc1 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 16 18:27:46 2017 +0100 syscall: raw_ptrace stub for AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38253 commit 8029632b50880fd9b5e39299c738b38e3386595f Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 15 16:58:37 2017 +0100 libgo: adapt runtime.inc to AIX * Two AIX types are wrongfully exported to runtime.inc as their names make them look like a Go type. * The sigset go type conflicts with a system sigset type. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38192 commit 25f3a90d14bc268479369ecc0eada72791612f86 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 15 16:58:37 2017 +0100 libgo: update Makefile.in, accidentally omitted from last change Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38310 commit d52b4895616b66f93b460366527e74336829aaa5 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 16 18:39:26 2017 +0100 syscall: TIOCSCTTY does not exist on AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38254 commit ff1ec3847a4472008e5d53a98b6694b1e54ca322 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 16 18:07:34 2017 +0100 syscall: syscall does not exist on AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38252 commit c1ee60dabf0b243a0b0286215481a5d326c34596 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Mar 17 17:18:18 2017 +0100 net: EAI_OVERFLOW does not exist on AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38266 commit ad4ad29aed9f70b14b39b488bfeb9ee745382ec4 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Mar 17 17:23:56 2017 +0100 net: sockopt/sockoptip stubs for AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38267 commit 5d7db2d7542fe7082f426d42f8c2ce14aad6df55 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Mar 17 16:35:05 2017 +0100 os/user: add listgroups stub for AIX This is required to build os/user. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38263 commit 4e57a7973e9fa4cb5ab977c6d792e62a8f7c5795 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 22 11:11:30 2017 +0100 os: fix readdirnames for AIX Largefile implementation should be used on AIX. readdir64_r function returns 9 and sets result to NULL when reaching end of directory, so this return code should not always be considered as an error. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38359 commit b34036967d1ec57b25e3debe077439b4210a1d4a Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Mar 17 17:39:31 2017 +0100 libgo: adapt sigtab.go to AIX On AIX, _NSIG is not directly defined to its integer value in gen-sysinfo.go. The real value is _SIGMAX32+1 or _SIGMAX64+1, depending if we are building a 32bit ligbo or a 64bit libgo, so we need to read one of those constants to set nsig value in mksigtab.sh This change also ensures that all signal numbers from 0 to nsig-1 are referenced in sigtable. Reviewed-on: https://go-review.googlesource.com/38268 commit 20991c32671a183ec859b4f285df37fdd4634247 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 23 17:28:09 2017 +0100 syscall: missing import in socket_bsd.go Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38369 commit c34754bd9adf5496c4c26257eaa50793553c11e8 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 22 17:57:01 2017 +0100 sycall: WCOREDUMP macro is not defined on AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38363 commit 4f38813482227b12ea0ac6ac1b981ff9ef9853ef Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 23 17:44:43 2017 +0100 libgo: additional build tags for AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38510 commit d117ede6ff5a7083e9c40eba28a0f94f3535d773 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 23 17:48:46 2017 +0100 go/build: add AIX to "go build" command known OS Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38511 commit 7b0ddaa6a6a71f9eb1c374122d29775b13c2cac5 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Mar 23 09:57:01 2017 -0700 compiler: don't crash if imported package imports this one When building a test it's OK if test code imports a package that imports this one. The go tool is supposed to catch cases where this creates an impossible initialization order. The compiler already has code to permit this in Gogo::add_import_init_fn. This CL avoids a compiler crash on a similar case when writing out the export data. I have no test case for this. Basically it pushes a compiler crash into an error reported elsewhere. Problem was reported by Tony Reix. Reviewed-on: https://go-review.googlesource.com/38462 commit 925636975d075e3e3353823b09db3f933f23cb03 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Mar 29 14:14:18 2017 -0700 runtime: copy finalizer support from Go 1.8 runtime Reviewed-on: https://go-review.googlesource.com/38794 commit 1ccb22b96cb3b1011db0e427877d9ddecb577fa9 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 30 15:21:06 2017 +0200 runtime: initcontext and setcontext stubs for AIX Further investigations are required to understand the clobbering issue and implement a proper fix. Until then, those stubs are required to allow the build to complete. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38930 commit 27db481f369b54256063c72b911d22390c59199c Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 29 18:07:25 2017 +0200 os: fix Readlink failure on AIX AIX readlink routine returns an error if the link is longer than the buffer, instead of truncating the link. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38700 commit c93babbf48eddd0bc34d4179ffb302dc60087299 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 29 17:26:35 2017 +0200 compiler: implement support for reading AIX big archives This is required to read go export from a Go library. Code courtesy of Damien Bergamini from Atos Infogérance. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38698 commit 930dd53482bdee3a9074850d168d0b9d7819c135 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 6 18:50:11 2017 -0700 compiler: fix whether conversions are static initializers The compiler was incorrectly treating type conversions from string to int or vice-versa as static initializers. That doesn't work, as those conversions are implemented via a function call. This case may never actually arise but it seems like the right thing to do. Reviewed-on: https://go-review.googlesource.com/39872 commit f02691e4195728dbf06f4dde0853c6bccc922183 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 6 17:24:08 2017 -0700 compiler, runtime: don't let slices point past end of memory block When Go code uses a slice expression like [:len(str)] or [:cap(slice)], it's natural for the resulting pointer to point just past the end of the memory block. If the next memory block is not live, we now have a live pointer to a dead block, which will unnecessarily keep the block alive. That wastes space, and with the new Go 1.8 GC (not yet committed) will trigger an error when using GODEBUG=gccheckmark=1. This changes the implementation of slice expressions to not move the pointer if the resulting string length or slice capacity is 0. When the length/capacity is zero, the pointer is never used anyhow. Reviewed-on: https://go-review.googlesource.com/39870 commit 17527c35b027e1afcc318faf5563909e1e9d44a6 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 6 15:30:11 2017 -0700 compiler: emit write barriers The Go 1.8 concurrent GC requires optional write barriers for all assignments that may change pointer values in the heap or in a global variable. For details see https://blog.golang.org/go15gc. This changes the gofrontend code to emit write barriers as needed. This is in preparation for future changes. At the moment the write barriers will do nothing. They test runtime.writeBarrier.enabled, which will never be non-zero. They call simple functions which just do a move without doing any of the other operations required by the write barrier. Reviewed-on: https://go-review.googlesource.com/39852 commit c0b00f072bf34b2c288e1271ec8118b88c4f6f6f Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Tue Apr 11 17:47:29 2017 +0200 libgo: allow building gox files from PIC objects libtool builds non-PIC objects in the same directory as .lo files and PIC objects in a .libs subdirectory. BUILDGOX rule uses the non-PIC objects to build the gox files, but on AIX only the PIC objects are built. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/40355 commit ea0f3da174c5503a209043f14ddda34871cfec52 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 6 19:06:14 2017 -0700 compiler: add code to generate a ptrmask for a type The Go 1.8 garbage collector uses a ptrmask for all types below a certain size. A ptrmask is simply a bit vector with a single bit for each pointer-sized word in the value. The bit is 1 if the type has a pointer in that position, 0 if it does not. This change adds code to the compiler to generate a ptrmask. The code is not used by anything yet, it is just compiled. It will be used when we switch over to the Go 1.8 garbage collector. The new Array_type::int_length method, and the new memory_size methods, will also be used by other patches coming later. Reviewed-on: https://go-review.googlesource.com/39873 commit 3029e1df3be3614d196a03c15e50e68ff850aa4c Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 7 10:31:39 2017 -0700 compiler: add code to generate a gcprog for a type The Go 1.8 garbage collector uses a gcprog for all types above a certain size. A gcprog describes where the pointers are in the type, using a simple bytecode machine that supports repeating bits. The effect is to permit using much less space to describe arrays. The format is described in runtime/mbitmap.go in the docs for runGCProg. This is not yet added to the gofrontend, but can be seen in the gc sources. This change adds code to the compiler to generate a gcprog. The code is not used by anything yet, it is just compiled. It will be used when we switch over to the Go 1.8 garbage collector. Reviewed-on: https://go-review.googlesource.com/39923 commit 8b01ef1e9176d20f4c9e667972fe031069a4d057 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 13 07:00:35 2017 -0700 compiler: add ptrdata computations and expressions For the upcoming Go 1.8 GC we need to compute the "ptrdata" of a type: the number of bytes in the type that can contain pointers. For types that do not contain pointers this number is zero. For many types it is a number larger than zero but smaller than the total size of the type. The Go 1.8 GC uses this number to make loops looking for pointers run faster by not scanning the suffix of a value that can not contain a pointer. Unfortunately there are two subtly different definitions of ptrdata, and we need both. The first is the simple one: the prefix that can contain pointers. The second is the number of bytes described by the gcprog for the type. Recall that we describe the exact position of pointers in a type using either a ptrmask or a gcprog. The ptrmask is simpler, the gcprog uses less space. We use the gcprog for large types, currently defined as types that are more than 2048 bytes. When the Go 1.8 runtime expands a gcprog, it verifies that the gcprog describes exactly the same number of bytes as the ptrdata field in the type descriptor. If the last pointer-containing portion of a type is an array, and if the elements of the array have a ptrdata that is less than the size of the element type, then the simple definition of the ptrdata will not include the final non-pointer-containing bytes of the last element of the array. However, the gcprog will define the array using a repeat count, and will therefore include the full size of the last element of the array. So for a type that needs a gcprog, the ptrdata field in the type descriptor must be the size of the data described by the gcprog, and that is not necessarily the same as the simple ptrdata. It might seem that we can always use the gcprog version of the ptrdata calculation, since that is what will appear in a type descriptor, but it turns out that for global variables we always use a ptrmask, not a gcprog, even if the global variable is large. This is because gcprogs are handled by expanding them into a ptrmask at runtime, and for a global variable there is no natural place to put the ptrmask. Simpler to always use the ptrmask. That means that we need to describe the size of the ptrmask, and that means that we need an expression for the simple form of the ptrdata. This CL implements the ptrdata calculation. This code is not actually used yet. It will be used later when the Go 1.8 GC is committed. Reviewed-on: https://go-review.googlesource.com/40573 commit 7a37331303b572412179a08141f1dd35339d40c8 Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 06:55:48 2017 -0700 compiler: zero length arrays never contain pointers Reviewed-on: https://go-review.googlesource.com/40696 commit c242f0508a64d3d74a28d498cbaeda785ff76258 Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 07:26:54 2017 -0700 bytes: disable allocations test on gccgo It turns out that testing.AllocsPerRun has not been producing correct results with the current gccgo memory allocator. When we update to the Go 1.8 memory allocator, testing.AllocsPerRun will work again, and this test will fail due to lack of escape analysis. Reviewed-on: https://go-review.googlesource.com/40700 commit 0dc369f1d63376a36bfb0999a1b0377fd444bfab Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Tue Apr 11 16:22:38 2017 +0200 os: alternative way to find executable path, using Args[0] AIX does not provide a proper way to find the original executable path from procfs, which contains just an hardlink. Executable path can be found using Args[0], Getcwd and $PATH. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/40353 commit f9bad1342569b338e3b2ea9f12ffc6d3d3fa3028 Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 08:01:19 2017 -0700 compiler: don't write struct with multiple sink fields to C header file When writing a struct to the C header file used by the C runtime code, a single sink field is fine: it will be called "_", which is valid C. There are structs with single sink fields that we want to write out, such as finblock. As it happens, though, the Go 1.8 runtime has a struct with two sink fields, gcControllerState, which will produce a C definition with two fields named "_", which will fail. Since we don't need to know that struct in C, rather than fix the general case, just punt if the struct has multiple sink fields. After the conversion to the Go 1.8 GC, we may be able to get rid of the C header file anyhow. I'm not sure yet. Reviewed-on: https://go-review.googlesource.com/40701 commit cfc28901a572aeb15b2f10a38f79eec04c64dfb2 Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 10:07:23 2017 -0700 runtime: disable allocations test on gccgo It turns out that testing.AllocsPerRun has not been producing correct results with the current gccgo memory allocator. When we update to the Go 1.8 memory allocator, testing.AllocsPerRun will work again, and these tests will fail due to lack of escape analysis. Reviewed-on: https://go-review.googlesource.com/40703 commit 36fedd76edaa48b9ec09709a70d9e4abaddf0caf Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 10:47:06 2017 -0700 runtime: remove unused size argument from hash/equal fns The size argument was removed from hash and equal functions in CL 34983. Somehow I missed removing them from three of the predefined functions. Reviewed-on: https://go-review.googlesource.com/40770 commit 90f6accb48d2e78cad8955b9292933f6ce3fe4c8 Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 13:23:05 2017 -0700 runtime: remove unused stack.go We're never going to use stack.go for gccgo. Although a build tag keeps it from being built, even having it around can be confusing. Remove it. Reviewed-on: https://go-review.googlesource.com/40774 commit befa71603fc66a214e01ac219f2bba36e19f136f Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 13:18:34 2017 -0700 runtime: build fastlog Take out the build tags which were preventing fastlog2 from being built. It's used by the upcoming Go 1.8 GC. Reviewed-on: https://go-review.googlesource.com/40773 commit b7e19e9be4ab4c3cd8f4c9506d79a8cd56bace40 Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 10:04:23 2017 -0700 runtime: add tests from Go 1.8 Some runtime package tests never made it into the gofrontend repo for some reason. Add them now. Reviewed-on: https://go-review.googlesource.com/40869 commit 1feef185aebd71bc2a09b9a04287461806096610 Author: Ian Lance Taylor <iant@golang.org> Date: Mon Apr 17 16:26:11 2017 -0700 runtime: change mcall to take a Go function value For future work in bringing in the Go 1.8 GC, change the mcall function to take a Go function value, which means that mcall can take a closure rather than just a straight C function pointer. As part of this change move kickoff from C to Go, which we want to do anyhow so that we run the write barriers that it generates. Reviewed-on: https://go-review.googlesource.com/40935 commit c3db34f4efc2d610f74a01dd2ad7775f48889b29 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Tue Apr 11 16:11:26 2017 +0200 runtime: netpoll implementation for AIX Code courtesy of Damien Bergamini from Atos Infogérance. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/40352 commit f5634dff40e53ad9ce61afd67fd07334e3af9d1f Author: Ian Lance Taylor <iant@golang.org> Date: Tue Apr 18 22:06:07 2017 -0700 runtime: move mstart from Go to C The assignments done in mstart must be done without write barriers, as mstart is running without an m or p. In the gc toolchain the equivalent code to intialize g and g->m is written in assembler; on GNU/Linux, it's in the clone function. Reviewed-on: https://go-review.googlesource.com/40989 commit 671d7c74592f4b6fe3665af279482ba0ea47ca2d Author: Ian Lance Taylor <iant@golang.org> Date: Tue Apr 18 17:47:28 2017 -0700 compiler: varargs slices do not escape in runtime Also, don't try to allocate an empty slice on the stack, as it will confuse the GCC backend. Also add a few trivial style, code formatting, and debug output fixes. Updates golang/go#17431 Reviewed-on: https://go-review.googlesource.com/40983 commit 94699d25f31353bf03419eda56b15993a39f3275 Author: Ian Lance Taylor <iant@golang.org> Date: Tue Apr 18 17:30:09 2017 -0700 compiler: add Ptrmask_symbol_expression Add an expression to evaluate to the ptrmask for a type. This will be used for global variables, which always use a ptrmask no matter how large they are. Reviewed-on: https://go-review.googlesource.com/40981 commit bfff1654eac5b9288fa6c431e66cba8c9da6a660 Author: Ian Lance Taylor <iant@golang.org> Date: Mon Apr 17 10:51:16 2017 -0700 runtime: change g's in systemstack The systemstack function in the gc toolchain changes to a different g. This is often used to get more stack space; the gofrontend uses a different stack growth mechanism that does not require changing g's, so we've been running with a version of systemstack that keeps the same g. However, the garbage collector has various tests to verify that it is running on g0 rather than on a normal g. For simplicity, change the gofrontend version of systemstack to change to a different g just as the gc toolchain does. This permits us to uncomment some sanity checks in notetsleep. Doing that requires us to fix up a couple of places where C code calls {start,stop}TheWorldWithSema while not on g0. Note that this does slow down some code in the runtime package unnecessarily. It may be useful to find some places where the runtime calls systemstack only to get more stack space and change it to use some other function. That other function would act like systemstack in the gc toolchain but simply call the argument in the gofrontend. Reviewed-on: https://go-review.googlesource.com/40973 commit b2ccc7601ce71a7c5732154cf9b2eeea64681469 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 10:36:12 2017 -0700 compiler, runtime: include ptrmask in GC roots Change the list of registered GC roots to include a ptrmask, and change the data structures to be easily used from Go code. The new ptrmask will be used by the Go 1.8 GC to only scan pointers. Tweak the current GC to use the new structures, but ignore the new ptrmask information for now. The new GC root data includes the size of the variable. The size is not currently used, but will be used later by the cgo checking code. Reviewed-on: https://go-review.googlesource.com/41075 commit 9e065149970bc180e4ca83bb99c74d9c4f43b47b Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 12:23:16 2017 -0700 compiler, runtime: don't pass size to __go_new There is no reason to pass the size to __go_new, as the type descriptor includes the size anyhow. This makes the function correspond to the Go 1.8 function runtime.newobject, which is what we will use when we update to the Go 1.8 memory allocator. Reviewed-on: https://go-review.googlesource.com/41080 commit c321de7b738c4a3387c1842919c9305acfa04c57 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 13:13:56 2017 -0700 compiler, runtime, reflect: make type descriptors more like Go 1.8 Change the type descriptor structure to be more like the one in the Go 1.8 runtime. Specifically we add the ptrdata field, rename the gc field to gcdata and change the type to *byte, and rearrange a few of the fields. The structure is still not identical to the Go 1.8 structure--we don't use any of the tricks to reduce overall executable size--but it is more similar. For now we don't use the new ptrdata field, and the gcdata field is still the old format rather than the new Go 1.8 ptrmask/gcprog format. Reviewed-on: https://go-review.googlesource.com/41081 commit 7b70c52cddeebea9ebeac003f8c6aad59497e5f0 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 14:54:29 2017 -0700 reflect: make sure to clear unusable hash/equal function Otherwise we wind up copying the one from the prototype, which is wrong. Also rewrite the hash/equal functions to look like the ones in Go 1.8, mainly a matter of changing names and using arrayAt. Reviewed-on: https://go-review.googlesource.com/41133 commit 84d26f467f7de8bdbb0d230458135fe1b6b2a99d Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 14:59:13 2017 -0700 runtime: remove duplicate declarations of SetFinalizer/KeepAlive These should have been removed in CL 38794. It's a bug that the compiler even permits these duplicate declarations. Reviewed-on: https://go-review.googlesource.com/41134 commit f85ff7e64c24031f6d0bd7c9c426b6176cb95160 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 15:56:32 2017 -0700 runtime: don't crash if panicstring called with no m It's possible for runtime_panicstring to be called with no m if a signal handler, or scheduler innards, do something wrong. If that happens carry on with the panic rather than crashing. Reviewed-on: https://go-review.googlesource.com/41137 commit 5b362b04f642afb8b20715930416fc3b7d91bb12 Author: Than McIntosh <thanm@google.com> Date: Fri Mar 31 14:35:48 2017 -0400 compiler: fix for expr sharing introduced by Order_eval::statement. When processing an expression statement with a top-level call that returns multiple results, Order_eval::statement can wind up creating a tree that has multiple references to the same call, which results in a confusing AST dump. Change the implementation to avoid introducing this unwanted sharing. Reviewed-on: https://go-review.googlesource.com/39210 commit b05b4260a68695bf9c9cc29e14ae86ca2699458a Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 16:00:28 2017 -0700 runtime: restore correct m in gtraceback If gtraceback is used to get a stack trace of a g running in the same m, as can happen if we collect a stack trace from a g0, then restore the old m value, don't clear it. Reviewed-on: https://go-review.googlesource.com/41138 commit ca8bbf4dfac19b3f4f7ce21a688b96a418c75031 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 16:03:24 2017 -0700 runtime: set startpc field when starting a new goroutine This puts the right value in a trace--previously it was always zero. Reviewed-on: https://go-review.googlesource.com/41139 commit ca8bbf4dfac19b3f4f7ce21a688b96a418c75031 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 16:03:24 2017 -0700 runtime: set startpc field when starting a new goroutine This puts the right value in a trace--previously it was always zero. Reviewed-on: https://go-review.googlesource.com/41139 commit 887690dce42d7bf8f711f8ea082e4928fb70f2a5 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 17:06:11 2017 -0700 runtime: add prefetch functions The Go 1.8 GC uses prefetch functions. Add versions for gccgo that call __builtin_prefetch. Uncomment the test for them in testAtomic64. Don't force the check function to return early, as now taking the address of a local variable in the runtime package does not force it onto the heap. Reviewed-on: https://go-review.googlesource.com/41144 commit 4269db69f9184e5a45c54aaee7352425a1f88bff Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 17:55:21 2017 -0700 runtime: split up ticks to get correct alignment On 32-bit x86 a uint64 variable by itself is aligned to an 8-byte boundary. A uint64 field in a struct is aligned to a 4-byte boundary. The runtime.ticks variable has a uint64 field that must be aligned to an 8-byte boundary. Rather than rely on luck, split up the struct into separate vars so that the required alignment happens reliably. It would be much nicer if issue golang/go#19057 were fixed somehow, but that is for another day. Reviewed-on: https://go-review.googlesource.com/41143 commit 66926cabdbdbf3431b4f172f7756e195c1c6c513 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Apr 20 17:15:38 2017 +0200 libgo: fix bad value for O_CLOEXEC on AIX 7.1 On AIX 7.1, O_CLOEXEC is defined as 0x0000001000000000, which creates an integer constant overflow error when building libgo. This affects only 7.1, O_CLOEXEC is not defined on 6.1 (and defaults to O in sysinfo.go) and is defined as 0x00800000 on AIX 7.2. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/41214 commit af288ff10aeafc47651f5def327ed56425d5be19 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 20 17:15:02 2017 -0700 runtime: preserve stack context in tracebackothers The tracebackothers function works by saving the current stack context in the goroutine's context field and then calling gogo to switch to a new goroutine. The new goroutine will collect its own stack trace and then call gogo to switch back to the original goroutine. This works fine, but if the original goroutine was called by mcall then the contents of its context field are needed to return from the mcall. Fix this by saving the stack context across the calls to the other goroutines. Reviewed-on: https://go-review.googlesource.com/41293 commit 43101e5956e793f1b4de05c15d7738c785e927df Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Apr 21 10:58:52 2017 +0200 os/user: use _posix_* libc functions libc getpwnam_r function has a different signature, we must use _posix_getpwnam_r instead (by default, the pwd.h system include file defines getpwnam_r as a static function calling _posix_getpwnam_r, so a C program calling getpwnam_r will indeed reference the _posix_getpwnam_r symbol). Idem for getpwuid_r, getgrnam_r and getgrgid_r. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/41334 commit 71e1fec4d2a536591ea6657a06916a17b5127071 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 21:24:48 2017 -0700 runtime: don't use pointers in g_ucontext_t or stackcontext The g_ucontext_t type holds registers saved for a goroutine. We have to scan it for pointers, but since registers don't necessarily hold pointers we have to scan it conservatively. That means that it should not have a pointer type, since the GC will always scan pointers. Instead it needs special treatment to be scanned conservatively. The current GC doesn't care when a pointer type holds a non-pointer, but the Go 1.8 GC does. For the current GC this means we have to explicitly scan the g_ucontext_t values in a G. While we're at it change stackcontext to be uintptr too. The entries in stackcontext never hold pointers that the Go GC cares about. Reviewed-on: https://go-review.googlesource.com/41270 commit eab2960aee91d3e3a6baa5b1bce01262d24c714f Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 20 17:08:19 2017 -0700 runtime/internal/sys: define Goexperiment The gc toolchain defines Goexperiment based on the environment variable GOEXPERIMENT when the toolchain is built. We just always set Goexperiment to the empty string. Reviewed-on: https://go-review.googlesource.com/41292 commit be4a751943265c0637da859d15a4faf162f5c478 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Apr 20 14:04:35 2017 +0200 net: sockopt implementation for AIX This is a copy of the Linux implementation, it allows to run some simple client/server applications on AIX, while the current sockopt stubs don't. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/41213 commit 46a669c4ca5b80fd6f6a0a42095804d9f704611d Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 29 17:55:06 2017 +0200 math: fix sign for atan/expm1/log1p(-0) AIX libc returns +0 for atan(-0), expm1(-0) and log1p(-0), while matching Go functions must return -0. Code courtesy of Tony Reix. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38699 commit 53b0e809130038a46f0a3d2870e3905f44ab888d Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Apr 26 17:29:22 2017 +0200 runtime: fix context clobbering on AIX On AIX 64-bits, r13 is a pointer to thread data. setcontext() overwrites r13 with the value saved by getcontext(). So, when a goroutine is scheduled on a new thread, r13 will point to the old thread data after calling setcontext(). Code courtesy of Damien Bergamini. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/41854 commit f8d5ebd71c71e6e777200530d8204b92619157f8 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Apr 26 18:01:19 2017 +0200 runtime: fix wrong time calculation in semasleep tv_nsec is added twice when calculating the sleep end time. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/41855 commit ef56097f4ea848d48fbf61eba1c757fe7fce99d3 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Apr 28 10:27:32 2017 +0200 libgo: pass $(NM) value when running benchmarks On AIX, we need to use "nm -B" instead of "nm", to have the epxected output format, so the configured $(NM) value from the Makefile should be exported before running gotest, which defaults to "nm" if $NM is not set. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/42051 commit 0fb550083ae474fb964435927b899ec8e4b62771 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Nov 16 21:12:53 2016 -0800 runtime: copy garbage collector from Go 1.8 runtime This giant patch replaces the old Go 1.4 memory allocator and garbage collector with the new Go 1.8 code. The memory allocator is fairly similar, though now written in Go rather than C. The garbage collector is completely different. It now uses ptrmask and gcprog information, which requires changes in the compiler and the reflect package as well as the runtime. And, of course, the garbage collector now runs concurrently with program execution. In the gc toolchain the garbage collector is strict and precise at all levels. In the gofrontend we do not have stack maps, so stacks, and register values, are collected conservatively. That means that an old, no longer used, pointer on a stack or in a register can cause a memory object to live longer than it should. That in turns means that we must disable some checks for invalid pointers in the garbage collection code. Not only can we get an invalid pointer on the stack; the concurrent nature of the collector means that we can in effect resurrect a block that was already unmarked but that the collector had not yet gotten around to freeing, and that block can in turn point to other blocks that the collector had managed to already free. So we must disable pointer checks in general. In effect we are relying on the fact that the strict pointer checks in the gc toolchain ensure that the garbage collector is correct, and we just assume that it is correct for the gofrontend since we are using the same code. Reviewed-on: https://go-review.googlesource.com/41307 commit a95078d501175240d095500a8c5fbfb21bec65cb Author: Ian Lance Taylor <iant@golang.org> Date: Mon Apr 24 16:33:47 2017 -0700 libgo/Makefile: clean more files Fix up the mostlyclean, clean, and distclean targets to better follow https://www.gnu.org/prep/standards/html_node/Standard-Targets.html. Reviewed-on: https://go-review.googlesource.com/41625 commit 5956bf1055451cf4239cdfeca259c23b1ded54d8 Author: Ian Lance Taylor <iant@golang.org> Date: Mon May 8 13:35:11 2017 -0700 libgo: delete goc2c The last .goc file has been removed, so remove goc2c. The goc2c program was my first contribution to the gc repository that was more than 100 lines: https://github.com/golang/go/commit/2b57a1124e87b0dc8bc1ff6899297b4d7d6e74f2 The program was used in gc for a few years under various guises but was finally removed in https://golang.org/cl/132680043. Now we can remove it from gofrontend as well. Reviewed-on: https://go-review.googlesource.com/42911 commit a222e35d041de0cd42506b61c93b8209e07702b9 Author: Than McIntosh <thanm@google.com> Date: Tue May 9 10:33:10 2017 -0400 compiler: set "need_init_fn" when adding gc root Variables that back slice initializers in certain cases have to be added to the gc roots list, since they can be modified at runtime. The code that was doing this addition did not update the flag that tracks whether the package being compiled needs an initializer function, which resulted in the call in question being left out of the final generated code in certain cases. Fix is to change Gogo::add_gc_root() to update the "needs init" flag. Reviewed-on: https://go-review.googlesource.com/43030 commit 822ab419bf7d1c705cdce1c12133e7a11f56be2e Author: Than McIntosh <thanm@google.com> Date: Tue May 9 11:36:51 2017 -0400 compiler: fix variable context nit in write barrier generation Update the write barrier generation code to insure that the "lvalue context" tag on the space var expression is set only in the case where the expr feeds directly into an assignment. This is somewhat counter-intuitive, but needed in the case where the backend looks at context tags. Reviewed-on: https://go-review.googlesource.com/43031 From-SVN: r247848
2017-05-11 01:26:09 +08:00
# AIX 7.1 is a 64 bits value for _FCLOEXEC (referenced by O_CLOEXEC)
# which leads to a constant overflow when using O_CLOEXEC in some
# go code. Issue wan not present in 6.1 (no O_CLOEXEC) and is no
# more present in 7.2 (_FCLOEXEC is a 32 bit value).
if test "${GOOS}" = "aix" && `oslevel | grep -q "^7.1"`; then
sed -e 's/const __FCLOEXEC = .*/const __FCLOEXEC = 0/' ${OUT} > ${OUT}-2
mv ${OUT}-2 ${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.
for flag in F_GETLK F_SETLK F_SETLKW; do
if ! grep "^const ${flag} " ${OUT} >/dev/null 2>&1 \
&& grep "^const ${flag}64 " ${OUT} >/dev/null 2>&1; then
echo "const ${flag} = ${flag}64" >> ${OUT}
fi
done
# The Flock_t struct for fcntl.
grep '^type _flock ' gen-sysinfo.go | \
sed -e 's/type _flock/type Flock_t/' \
-e 's/l_type/Type/' \
-e 's/l_whence/Whence/' \
-e 's/l_start/Start/' \
-e 's/l_len/Len/' \
-e 's/l_pid/Pid/' \
>> ${OUT}
# The signal numbers.
grep '^const _SIG[^_]' gen-sysinfo.go | \
grep -v '^const _SIGEV_' | \
sed -e 's/^\(const \)_\(SIG[^= ]*\)\(.*\)$/\1\2 = Signal(_\2)/' >> ${OUT}
if ! grep '^const SIGPOLL ' ${OUT} >/dev/null 2>&1; then
if grep '^const SIGIO ' ${OUT} > /dev/null 2>&1; then
echo "const SIGPOLL = SIGIO" >> ${OUT}
fi
fi
if ! grep '^const SIGCLD ' ${OUT} >/dev/null 2>&1; then
if grep '^const SIGCHLD ' ${OUT} >/dev/null 2>&1; then
echo "const SIGCLD = SIGCHLD" >> ${OUT}
fi
fi
# The syscall numbers. We force the names to upper case.
grep '^const _SYS_' gen-sysinfo.go | \
grep -v '^const _SYS_SECCOMP = ' | \
sed -e 's/const _\(SYS_[^= ]*\).*$/\1/' | \
while read sys; do
sup=`echo $sys | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
echo "const $sup = _$sys" >> ${OUT}
done
# Special treatment of SYS_IOCTL for GNU/Hurd.
if ! grep '^const SYS_IOCTL' ${OUT} > /dev/null 2>&1; then
echo "const SYS_IOCTL = 0" >> ${OUT}
fi
# The GNU/Linux support wants to use SYS_GETDENTS64 if available.
if ! grep '^const SYS_GETDENTS ' ${OUT} >/dev/null 2>&1; then
echo "const SYS_GETDENTS = 0" >> ${OUT}
fi
if ! grep '^const SYS_GETDENTS64 ' ${OUT} >/dev/null 2>&1; then
echo "const SYS_GETDENTS64 = 0" >> ${OUT}
fi
# The syscall package wants the geteuid system call number. It isn't
# defined on Alpha, which only provides the getresuid system call.
if ! grep '^const SYS_GETEUID ' ${OUT} >/dev/null 2>&1; then
echo "const SYS_GETEUID = 0" >> ${OUT}
fi
# Stat constants.
grep '^const _S_' gen-sysinfo.go | \
sed -e 's/^\(const \)_\(S_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
# Mmap constants.
grep '^const _PROT_' gen-sysinfo.go | \
sed -e 's/^\(const \)_\(PROT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
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 |
sed -e 's/^\(const \)_\(W[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
# WSTOPPED was introduced in glibc 2.3.4.
if ! grep '^const _WSTOPPED = ' gen-sysinfo.go >/dev/null 2>&1; then
if grep '^const _WUNTRACED = ' gen-sysinfo.go > /dev/null 2>&1; then
echo 'const WSTOPPED = _WUNTRACED' >> ${OUT}
else
echo 'const WSTOPPED = 2' >> ${OUT}
fi
fi
if grep '^const ___WALL = ' gen-sysinfo.go >/dev/null 2>&1 \
&& ! grep '^const _WALL = ' gen-sysinfo.go >/dev/null 2>&1; then
echo 'const WALL = ___WALL' >> ${OUT}
fi
# On GNU/Linux the os package requires WEXITED and WNOWAIT.
if test "${GOOS}" = "linux"; then
if ! grep '^const WEXITED = ' ${OUT} >/dev/null 2>&1; then
echo 'const WEXITED = 4' >> ${OUT}
fi
if ! grep '^const WNOWAIT = ' ${OUT} >/dev/null 2>&1; then
echo 'const WNOWAIT = 0x01000000' >> ${OUT}
fi
fi
# Networking constants.
egrep '^const _(AF|ARPHRD|ETH|IN|SOCK|SOL|SO|IPPROTO|TCP|IP|IPV6)_' gen-sysinfo.go |
grep -v '_val =' |
sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
grep '^const _SOMAXCONN' gen-sysinfo.go |
sed -e 's/^\(const \)_\(SOMAXCONN[^= ]*\)\(.*\)$/\1\2 = _\2/' \
>> ${OUT}
grep '^const _SHUT_' gen-sysinfo.go |
sed -e 's/^\(const \)_\(SHUT[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
# The net package requires some const definitions.
for m in IP_PKTINFO IPV6_V6ONLY IPPROTO_IPV6 IPV6_JOIN_GROUP IPV6_LEAVE_GROUP IPV6_TCLASS SO_REUSEPORT; do
if ! grep "^const $m " ${OUT} >/dev/null 2>&1; then
echo "const $m = 0" >> ${OUT}
fi
done
for m in SOCK_CLOEXEC SOCK_NONBLOCK; do
if ! grep "^const $m " ${OUT} >/dev/null 2>&1; then
echo "const $m = -1" >> ${OUT}
fi
done
# On 32-bit GNU/Linux the expression for SO_RCVTIMEO is too complicated
# for -fdump-go-spec.
if ! grep '^const SO_RCVTIMEO ' ${OUT} >/dev/null 2>&1; then
if grep '^const _SO_RCVTIMEO_val' ${OUT} >/dev/null 2>&1; then
echo 'const SO_RCVTIMEO = _SO_RCVTIMEO_val' >> ${OUT}
fi
fi
# The syscall package requires AF_LOCAL.
if ! grep '^const AF_LOCAL ' ${OUT} >/dev/null 2>&1; then
if grep '^const AF_UNIX ' ${OUT} >/dev/null 2>&1; then
echo "const AF_LOCAL = AF_UNIX" >> ${OUT}
fi
fi
# The syscall package requires _AT_FDCWD, but doesn't export it.
if ! grep '^const _AT_FDCWD = ' ${OUT} >/dev/null 2>&1; then
echo "const _AT_FDCWD = -100" >> ${OUT}
fi
# sysctl constants.
grep '^const _CTL' gen-sysinfo.go |
sed -e 's/^\(const \)_\(CTL[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
grep '^const _SYSCTL' gen-sysinfo.go |
sed -e 's/^\(const \)_\(SYSCTL[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
grep '^const _NET_RT' gen-sysinfo.go |
sed -e 's/^\(const \)_\(NET_RT[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
# The sysctlnode struct.
grep '^type _sysctlnode ' gen-sysinfo.go | \
sed -e 's/_sysctlnode/Sysctlnode/' \
-e 's/sysctl_flags/Flags/' \
-e 's/sysctl_name/Name/' \
-e 's/sysctl_num/Num/' \
>> ${OUT}
# sysconf constants.
grep '^const __SC' gen-sysinfo.go |
sed -e 's/^\(const \)__\(SC[^= ]*\)\(.*\)$/\1\2 = __\2/' >> ${OUT}
# pathconf constants.
grep '^const __PC' gen-sysinfo.go |
sed -e 's/^\(const \)__\(PC[^= ]*\)\(.*\)$/\1\2 = __\2/' >> ${OUT}
# The PATH_MAX constant.
if grep '^const _PATH_MAX ' gen-sysinfo.go >/dev/null 2>&1; then
echo 'const PathMax = _PATH_MAX' >> ${OUT}
fi
# epoll constants.
grep '^const _EPOLL' gen-sysinfo.go |
grep -v EPOLLET |
sed -e 's/^\(const \)_\(EPOLL[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
# Make sure EPOLLET is positive.
if grep '^const _EPOLLET = [0-9]' gen-sysinfo.go >/dev/null 2>&1; then
grep '^const _EPOLLET ' gen-sysinfo.go |
sed -e 's/^\(const \)_\(EPOLL[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
else
echo "const EPOLLET = 0x80000000" >> ${OUT}
fi
# Make sure EPOLLRDHUP and EPOLL_CLOEXEC are defined.
if ! grep '^const EPOLLRDHUP' ${OUT} >/dev/null 2>&1; then
echo "const EPOLLRDHUP = 0x2000" >> ${OUT}
fi
if ! grep '^const EPOLL_CLOEXEC' ${OUT} >/dev/null 2>&1; then
echo "const EPOLL_CLOEXEC = 02000000" >> ${OUT}
fi
# Prctl constants.
grep '^const _PR_' gen-sysinfo.go |
sed -e 's/^\(const \)_\(PR_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
# Ptrace constants.
grep '^const _PTRACE' gen-sysinfo.go |
sed -e 's/^\(const \)_\(PTRACE[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
# We need some ptrace options that are not defined in older versions
# of glibc.
if ! grep '^const PTRACE_SETOPTIONS' ${OUT} > /dev/null 2>&1; then
echo "const PTRACE_SETOPTIONS = 0x4200" >> ${OUT}
fi
if ! grep '^const PTRACE_O_TRACESYSGOOD' ${OUT} > /dev/null 2>&1; then
echo "const PTRACE_O_TRACESYSGOOD = 0x1" >> ${OUT}
fi
if ! grep '^const PTRACE_O_TRACEFORK' ${OUT} > /dev/null 2>&1; then
echo "const PTRACE_O_TRACEFORK = 0x2" >> ${OUT}
fi
if ! grep '^const PTRACE_O_TRACEVFORK' ${OUT} > /dev/null 2>&1; then
echo "const PTRACE_O_TRACEVFORK = 0x4" >> ${OUT}
fi
if ! grep '^const PTRACE_O_TRACECLONE' ${OUT} > /dev/null 2>&1; then
echo "const PTRACE_O_TRACECLONE = 0x8" >> ${OUT}
fi
if ! grep '^const PTRACE_O_TRACEEXEC' ${OUT} > /dev/null 2>&1; then
echo "const PTRACE_O_TRACEEXEC = 0x10" >> ${OUT}
fi
if ! grep '^const PTRACE_O_TRACEVFORKDONE' ${OUT} > /dev/null 2>&1; then
echo "const PTRACE_O_TRACEVFORKDONE = 0x20" >> ${OUT}
fi
if ! grep '^const PTRACE_O_TRACEEXIT' ${OUT} > /dev/null 2>&1; then
echo "const PTRACE_O_TRACEEXIT = 0x40" >> ${OUT}
fi
if ! grep '^const PTRACE_O_MASK' ${OUT} > /dev/null 2>&1; then
echo "const PTRACE_O_MASK = 0x7f" >> ${OUT}
fi
if ! grep '^const _PTRACE_GETEVENTMSG' ${OUT} > /dev/null 2>&1; then
echo "const PTRACE_GETEVENTMSG = 0x4201" >> ${OUT}
fi
if ! grep '^const PTRACE_EVENT_FORK' ${OUT} > /dev/null 2>&1; then
echo "const PTRACE_EVENT_FORK = 1" >> ${OUT}
fi
if ! grep '^const PTRACE_EVENT_VFORK' ${OUT} > /dev/null 2>&1; then
echo "const PTRACE_EVENT_VFORK = 2" >> ${OUT}
fi
if ! grep '^const PTRACE_EVENT_CLONE' ${OUT} > /dev/null 2>&1; then
echo "const PTRACE_EVENT_CLONE = 3" >> ${OUT}
fi
if ! grep '^const PTRACE_EVENT_EXEC' ${OUT} > /dev/null 2>&1; then
echo "const PTRACE_EVENT_EXEC = 4" >> ${OUT}
fi
if ! grep '^const PTRACE_EVENT_VFORK_DONE' ${OUT} > /dev/null 2>&1; then
echo "const PTRACE_EVENT_VFORK_DONE = 5" >> ${OUT}
fi
if ! grep '^const PTRACE_EVENT_EXIT' ${OUT} > /dev/null 2>&1; then
echo "const PTRACE_EVENT_EXIT = 6" >> ${OUT}
fi
if ! grep '^const _PTRACE_TRACEME' ${OUT} > /dev/null 2>&1; then
echo "const _PTRACE_TRACEME = 0" >> ${OUT}
fi
libgo: add s390 support From Dominik Vogt. * libgo/go/syscall/libcall_linux_s390.go: New file for s390 support. * libgo/go/syscall/syscall_linux_s390.go: Ditto. * libgo/go/syscall/libcall_linux_s390x.go: New file for s390x support. * libgo/go/syscall/syscall_linux_s390x.go: Ditto. * libgo/go/runtime/pprof/pprof.go (printStackRecord): Support s390 and s390x. * libgo/runtime/runtime.c (runtime_cputicks): Add support for s390 and s390x * libgo/mksysinfo.sh: Ditto. (upcase_fields): New helper function * libgo/go/debug/elf/file.go (applyRelocations): Implement relocations on s390x. (applyRelocationsS390x): Ditto. (DWARF): Ditto. * libgo/go/debug/elf/elf.go (R_390): New constants for S390 relocations. (r390Strings): Ditto. (String): Helper function for S390 relocations. (GoString): Ditto. * libgo/go/reflect/makefuncgo_s390.go: New file. (S390MakeFuncStubGo): Implementation of s390 abi. * libgo/go/reflect/makefuncgo_s390x.go: New file. (S390xMakeFuncStubGo): Implementation of s390x abi. * libgo/go/reflect/makefunc_s390.c: New file. (makeFuncStub): s390 and s390x specific implementation of function. * libgo/go/reflect/makefunc.go (MakeFunc): Add support for s390 and s390x. (makeMethodValue): Ditto. (makeValueMethod): Ditto. * libgo/Makefile.am (go_reflect_makefunc_s_file): Ditto. (go_reflect_makefunc_file): Ditto. * libgo/go/reflect/makefunc_dummy.c: Ditto. * libgo/runtime/runtime.h (__go_makefunc_can_recover): Export prototype for use in makefunc_s390.c. (__go_makefunc_returning): Ditto. * libgo/go/syscall/exec_linux.go (forkAndExecInChild): Fix order of the arguments of the clone system call for s390[x]. * libgo/configure.ac (is_s390): New variable. (is_s390x): Ditto (LIBGO_IS_S390): Ditto. (LIBGO_IS_S390X): Ditto. (GOARCH): Support s390 and s390x. * libgo/go/go/build/build.go (cgoEnabled): Ditto. * libgo/go/go/build/syslist.go (goarchList): Ditto. From-SVN: r217106
2014-11-05 06:39:30 +08:00
# A helper function that prints a structure from gen-sysinfo.go with the first
# letter of the field names in upper case. $1 is the name of structure. If $2
# is not empty, the structure or type is renamed to $2.
upcase_fields () {
name="$1"
def=`grep "^type $name " gen-sysinfo.go`
libgo: add s390 support From Dominik Vogt. * libgo/go/syscall/libcall_linux_s390.go: New file for s390 support. * libgo/go/syscall/syscall_linux_s390.go: Ditto. * libgo/go/syscall/libcall_linux_s390x.go: New file for s390x support. * libgo/go/syscall/syscall_linux_s390x.go: Ditto. * libgo/go/runtime/pprof/pprof.go (printStackRecord): Support s390 and s390x. * libgo/runtime/runtime.c (runtime_cputicks): Add support for s390 and s390x * libgo/mksysinfo.sh: Ditto. (upcase_fields): New helper function * libgo/go/debug/elf/file.go (applyRelocations): Implement relocations on s390x. (applyRelocationsS390x): Ditto. (DWARF): Ditto. * libgo/go/debug/elf/elf.go (R_390): New constants for S390 relocations. (r390Strings): Ditto. (String): Helper function for S390 relocations. (GoString): Ditto. * libgo/go/reflect/makefuncgo_s390.go: New file. (S390MakeFuncStubGo): Implementation of s390 abi. * libgo/go/reflect/makefuncgo_s390x.go: New file. (S390xMakeFuncStubGo): Implementation of s390x abi. * libgo/go/reflect/makefunc_s390.c: New file. (makeFuncStub): s390 and s390x specific implementation of function. * libgo/go/reflect/makefunc.go (MakeFunc): Add support for s390 and s390x. (makeMethodValue): Ditto. (makeValueMethod): Ditto. * libgo/Makefile.am (go_reflect_makefunc_s_file): Ditto. (go_reflect_makefunc_file): Ditto. * libgo/go/reflect/makefunc_dummy.c: Ditto. * libgo/runtime/runtime.h (__go_makefunc_can_recover): Export prototype for use in makefunc_s390.c. (__go_makefunc_returning): Ditto. * libgo/go/syscall/exec_linux.go (forkAndExecInChild): Fix order of the arguments of the clone system call for s390[x]. * libgo/configure.ac (is_s390): New variable. (is_s390x): Ditto (LIBGO_IS_S390): Ditto. (LIBGO_IS_S390X): Ditto. (GOARCH): Support s390 and s390x. * libgo/go/go/build/build.go (cgoEnabled): Ditto. * libgo/go/go/build/syslist.go (goarchList): Ditto. From-SVN: r217106
2014-11-05 06:39:30 +08:00
fields=`echo $def | sed -e 's/^[^{]*{\(.*\)}$/\1/'`
prefix=`echo $def | sed -e 's/{.*//'`
if test "$2" != ""; then
prefix=`echo $prefix | sed -e "s/$1/$2/"`
fi
if test "$fields" != ""; then
nfields=
while test -n "$fields"; do
field=`echo $fields | sed -e 's/^\([^;]*\);.*$/\1/'`
fields=`echo $fields | sed -e 's/^[^;]*; *\(.*\)$/\1/'`
# capitalize the next character.
f=`echo $field | sed -e 's/^\(.\).*$/\1/'`
r=`echo $field | sed -e 's/^.\(.*\)$/\1/'`
f=`echo $f | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
field="$f$r"
nfields="$nfields $field;"
done
echo "${prefix} {$nfields }"
fi
}
# The registers returned by PTRACE_GETREGS. This is probably
# GNU/Linux specific; it should do no harm if there is no
# _user_regs_struct.
regs=`grep '^type _user_regs_struct struct' gen-sysinfo.go || true`
if test "$regs" = ""; then
# mips*
regs=`grep '^type _pt_regs struct' gen-sysinfo.go || true`
libgo: add s390 support From Dominik Vogt. * libgo/go/syscall/libcall_linux_s390.go: New file for s390 support. * libgo/go/syscall/syscall_linux_s390.go: Ditto. * libgo/go/syscall/libcall_linux_s390x.go: New file for s390x support. * libgo/go/syscall/syscall_linux_s390x.go: Ditto. * libgo/go/runtime/pprof/pprof.go (printStackRecord): Support s390 and s390x. * libgo/runtime/runtime.c (runtime_cputicks): Add support for s390 and s390x * libgo/mksysinfo.sh: Ditto. (upcase_fields): New helper function * libgo/go/debug/elf/file.go (applyRelocations): Implement relocations on s390x. (applyRelocationsS390x): Ditto. (DWARF): Ditto. * libgo/go/debug/elf/elf.go (R_390): New constants for S390 relocations. (r390Strings): Ditto. (String): Helper function for S390 relocations. (GoString): Ditto. * libgo/go/reflect/makefuncgo_s390.go: New file. (S390MakeFuncStubGo): Implementation of s390 abi. * libgo/go/reflect/makefuncgo_s390x.go: New file. (S390xMakeFuncStubGo): Implementation of s390x abi. * libgo/go/reflect/makefunc_s390.c: New file. (makeFuncStub): s390 and s390x specific implementation of function. * libgo/go/reflect/makefunc.go (MakeFunc): Add support for s390 and s390x. (makeMethodValue): Ditto. (makeValueMethod): Ditto. * libgo/Makefile.am (go_reflect_makefunc_s_file): Ditto. (go_reflect_makefunc_file): Ditto. * libgo/go/reflect/makefunc_dummy.c: Ditto. * libgo/runtime/runtime.h (__go_makefunc_can_recover): Export prototype for use in makefunc_s390.c. (__go_makefunc_returning): Ditto. * libgo/go/syscall/exec_linux.go (forkAndExecInChild): Fix order of the arguments of the clone system call for s390[x]. * libgo/configure.ac (is_s390): New variable. (is_s390x): Ditto (LIBGO_IS_S390): Ditto. (LIBGO_IS_S390X): Ditto. (GOARCH): Support s390 and s390x. * libgo/go/go/build/build.go (cgoEnabled): Ditto. * libgo/go/go/build/syslist.go (goarchList): Ditto. From-SVN: r217106
2014-11-05 06:39:30 +08:00
fi
if test "$regs" != ""; then
regs=`echo $regs | sed -e 's/type _pt_regs struct//'`
libgo: add s390 support From Dominik Vogt. * libgo/go/syscall/libcall_linux_s390.go: New file for s390 support. * libgo/go/syscall/syscall_linux_s390.go: Ditto. * libgo/go/syscall/libcall_linux_s390x.go: New file for s390x support. * libgo/go/syscall/syscall_linux_s390x.go: Ditto. * libgo/go/runtime/pprof/pprof.go (printStackRecord): Support s390 and s390x. * libgo/runtime/runtime.c (runtime_cputicks): Add support for s390 and s390x * libgo/mksysinfo.sh: Ditto. (upcase_fields): New helper function * libgo/go/debug/elf/file.go (applyRelocations): Implement relocations on s390x. (applyRelocationsS390x): Ditto. (DWARF): Ditto. * libgo/go/debug/elf/elf.go (R_390): New constants for S390 relocations. (r390Strings): Ditto. (String): Helper function for S390 relocations. (GoString): Ditto. * libgo/go/reflect/makefuncgo_s390.go: New file. (S390MakeFuncStubGo): Implementation of s390 abi. * libgo/go/reflect/makefuncgo_s390x.go: New file. (S390xMakeFuncStubGo): Implementation of s390x abi. * libgo/go/reflect/makefunc_s390.c: New file. (makeFuncStub): s390 and s390x specific implementation of function. * libgo/go/reflect/makefunc.go (MakeFunc): Add support for s390 and s390x. (makeMethodValue): Ditto. (makeValueMethod): Ditto. * libgo/Makefile.am (go_reflect_makefunc_s_file): Ditto. (go_reflect_makefunc_file): Ditto. * libgo/go/reflect/makefunc_dummy.c: Ditto. * libgo/runtime/runtime.h (__go_makefunc_can_recover): Export prototype for use in makefunc_s390.c. (__go_makefunc_returning): Ditto. * libgo/go/syscall/exec_linux.go (forkAndExecInChild): Fix order of the arguments of the clone system call for s390[x]. * libgo/configure.ac (is_s390): New variable. (is_s390x): Ditto (LIBGO_IS_S390): Ditto. (LIBGO_IS_S390X): Ditto. (GOARCH): Support s390 and s390x. * libgo/go/go/build/build.go (cgoEnabled): Ditto. * libgo/go/go/build/syslist.go (goarchList): Ditto. From-SVN: r217106
2014-11-05 06:39:30 +08:00
regs=`echo $regs |
sed -e 's/type __*user_regs_struct struct //' -e 's/[{}]//g'`
regs=`echo $regs | sed -e s'/^ *//'`
nregs=
while test -n "$regs"; do
field=`echo $regs | sed -e 's/^\([^;]*\);.*$/\1/'`
regs=`echo $regs | sed -e 's/^[^;]*; *\(.*\)$/\1/'`
# Capitalize the first character of the field.
f=`echo $field | sed -e 's/^\(.\).*$/\1/'`
r=`echo $field | sed -e 's/^.\(.*\)$/\1/'`
f=`echo $f | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
field="$f$r"
libgo: add s390 support From Dominik Vogt. * libgo/go/syscall/libcall_linux_s390.go: New file for s390 support. * libgo/go/syscall/syscall_linux_s390.go: Ditto. * libgo/go/syscall/libcall_linux_s390x.go: New file for s390x support. * libgo/go/syscall/syscall_linux_s390x.go: Ditto. * libgo/go/runtime/pprof/pprof.go (printStackRecord): Support s390 and s390x. * libgo/runtime/runtime.c (runtime_cputicks): Add support for s390 and s390x * libgo/mksysinfo.sh: Ditto. (upcase_fields): New helper function * libgo/go/debug/elf/file.go (applyRelocations): Implement relocations on s390x. (applyRelocationsS390x): Ditto. (DWARF): Ditto. * libgo/go/debug/elf/elf.go (R_390): New constants for S390 relocations. (r390Strings): Ditto. (String): Helper function for S390 relocations. (GoString): Ditto. * libgo/go/reflect/makefuncgo_s390.go: New file. (S390MakeFuncStubGo): Implementation of s390 abi. * libgo/go/reflect/makefuncgo_s390x.go: New file. (S390xMakeFuncStubGo): Implementation of s390x abi. * libgo/go/reflect/makefunc_s390.c: New file. (makeFuncStub): s390 and s390x specific implementation of function. * libgo/go/reflect/makefunc.go (MakeFunc): Add support for s390 and s390x. (makeMethodValue): Ditto. (makeValueMethod): Ditto. * libgo/Makefile.am (go_reflect_makefunc_s_file): Ditto. (go_reflect_makefunc_file): Ditto. * libgo/go/reflect/makefunc_dummy.c: Ditto. * libgo/runtime/runtime.h (__go_makefunc_can_recover): Export prototype for use in makefunc_s390.c. (__go_makefunc_returning): Ditto. * libgo/go/syscall/exec_linux.go (forkAndExecInChild): Fix order of the arguments of the clone system call for s390[x]. * libgo/configure.ac (is_s390): New variable. (is_s390x): Ditto (LIBGO_IS_S390): Ditto. (LIBGO_IS_S390X): Ditto. (GOARCH): Support s390 and s390x. * libgo/go/go/build/build.go (cgoEnabled): Ditto. * libgo/go/go/build/syslist.go (goarchList): Ditto. From-SVN: r217106
2014-11-05 06:39:30 +08:00
field=`echo "$field" | sed \
-e 's/__user_psw_struct/PtracePsw/' \
-e 's/__user_fpregs_struct/PtraceFpregs/' \
-e 's/__user_per_struct/PtracePer/'`
nregs="$nregs $field;"
done
echo "type PtraceRegs struct {$nregs }" >> ${OUT}
fi
# Some basic types.
echo 'type Size_t _size_t' >> ${OUT}
echo "type Ssize_t _ssize_t" >> ${OUT}
echo "type Offset_t _libgo_off_t_type" >> ${OUT}
echo "type Mode_t _mode_t" >> ${OUT}
echo "type Pid_t _pid_t" >> ${OUT}
echo "type Uid_t _uid_t" >> ${OUT}
echo "type Gid_t _gid_t" >> ${OUT}
echo "type Socklen_t _socklen_t" >> ${OUT}
# The C int type.
sizeof_int=`grep '^const ___SIZEOF_INT__ = ' gen-sysinfo.go | sed -e 's/.*= //'`
if test "$sizeof_int" = "4"; then
echo "type _C_int int32" >> ${OUT}
echo "type _C_uint uint32" >> ${OUT}
elif test "$sizeof_int" = "8"; then
echo "type _C_int int64" >> ${OUT}
echo "type _C_uint uint64" >> ${OUT}
else
echo 1>&2 "mksysinfo.sh: could not determine size of int (got $sizeof_int)"
exit 1
fi
# The C long type, needed because that is the type that ptrace returns.
sizeof_long=`grep '^const ___SIZEOF_LONG__ = ' gen-sysinfo.go | sed -e 's/.*= //'`
if test "$sizeof_long" = "4"; then
echo "type _C_long int32" >> ${OUT}
echo "type _C_ulong uint32" >> ${OUT}
elif test "$sizeof_long" = "8"; then
echo "type _C_long int64" >> ${OUT}
echo "type _C_ulong uint64" >> ${OUT}
else
echo 1>&2 "mksysinfo.sh: could not determine size of long (got $sizeof_long)"
exit 1
fi
# The time_t type.
if grep '^type _time_t ' gen-sysinfo.go > /dev/null 2>&1; then
echo 'type Time_t _time_t' >> ${OUT}
fi
# The time structures need special handling: we need to name the
# types, so that we can cast integers to the right types when
# assigning to the structures.
timeval=`grep '^type _timeval ' gen-sysinfo.go`
timeval_sec=`echo $timeval | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'`
timeval_usec=`echo $timeval | sed -n -e 's/^.*tv_usec \([^ ]*\);.*$/\1/p'`
echo "type Timeval_sec_t = $timeval_sec" >> ${OUT}
echo "type Timeval_usec_t = $timeval_usec" >> ${OUT}
echo $timeval | \
sed -e 's/type _timeval /type Timeval /' \
-e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timeval_sec_t/' \
-e 's/tv_usec *[a-zA-Z0-9_]*/Usec Timeval_usec_t/' >> ${OUT}
timespec=`grep '^type _timespec ' gen-sysinfo.go || true`
if test "$timespec" = ""; then
# IRIX 6.5 has __timespec instead.
timespec=`grep '^type ___timespec ' gen-sysinfo.go || true`
fi
timespec_sec=`echo $timespec | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'`
timespec_nsec=`echo $timespec | sed -n -e 's/^.*tv_nsec \([^ ]*\);.*$/\1/p'`
echo "type Timespec_sec_t = $timespec_sec" >> ${OUT}
echo "type Timespec_nsec_t = $timespec_nsec" >> ${OUT}
echo $timespec | \
sed -e 's/^type ___timespec /type Timespec /' \
-e 's/^type _timespec /type Timespec /' \
-e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timespec_sec_t/' \
-e 's/tv_nsec *[a-zA-Z0-9_]*/Nsec Timespec_nsec_t/' >> ${OUT}
timestruc=`grep '^type _timestruc_t ' gen-sysinfo.go || true`
if test "$timestruc" = "type _timestruc_t _timespec"; then
echo "type Timestruc Timespec" >> ${OUT}
elif test "$timestruc" != ""; then
timestruc_sec=`echo $timestruc | sed -n -e 's/^.*tv_sec \([^ ]*\);.*$/\1/p'`
timestruc_nsec=`echo $timestruc | sed -n -e 's/^.*tv_nsec \([^ ]*\);.*$/\1/p'`
echo "type Timestruc_sec_t = $timestruc_sec" >> ${OUT}
echo "type Timestruc_nsec_t = $timestruc_nsec" >> ${OUT}
echo $timestruc | \
sed -e 's/^type _timestruc_t /type Timestruc /' \
-e 's/tv_sec *[a-zA-Z0-9_]*/Sec Timestruc_sec_t/' \
-e 's/tv_nsec *[a-zA-Z0-9_]*/Nsec Timestruc_nsec_t/' >> ${OUT}
fi
# The tms struct.
grep '^type _tms ' gen-sysinfo.go | \
sed -e 's/type _tms/type Tms/' \
-e 's/tms_utime/Utime/' \
-e 's/tms_stime/Stime/' \
-e 's/tms_cutime/Cutime/' \
-e 's/tms_cstime/Cstime/' \
>> ${OUT}
# AIX uses st_timespec struct for stat.
grep '^type _st_timespec ' gen-sysinfo.go | \
sed -e 's/type _st_timespec /type StTimespec /' \
-e 's/tv_sec/Sec/' \
-e 's/tv_nsec/Nsec/' >> ${OUT}
# Special treatment of struct stat st_dev for GNU/Hurd
# /usr/include/i386-gnu/bits/stat.h: #define st_dev st_fsid
st_dev='-e s/st_dev/Dev/'
if grep 'define st_dev st_fsid' gen-sysinfo.go > /dev/null 2>&1; then
st_dev='-e s/st_fsid/Dev/'
fi
# For historical reasons Go uses the suffix "timespec" instead of "tim" for
# stat_t's time fields on NetBSD.
st_times='-e s/st_atim/Atim/g -e s/st_mtim/Mtim/g -e s/st_ctim/Ctim/g'
if test "${GOOS}" = "netbsd"; then
st_times='-e s/st_atim/Atimespec/ -e s/st_mtim/Mtimespec/ -e s/st_ctim/Ctimespec/'
fi
# The stat type.
# Prefer largefile variant if available.
stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
if test "$stat" != ""; then
grep '^type _stat64 ' gen-sysinfo.go
else
grep '^type _stat ' gen-sysinfo.go
fi | sed -e 's/type _stat64/type Stat_t/' \
-e 's/type _stat/type Stat_t/' \
${st_dev} \
${st_times} \
-e 's/st_ino/Ino/g' \
-e 's/st_nlink/Nlink/' \
-e 's/st_mode/Mode/' \
-e 's/st_uid/Uid/' \
-e 's/st_gid/Gid/' \
-e 's/st_rdev/Rdev/' \
-e 's/st_size/Size/' \
-e 's/st_blksize/Blksize/' \
-e 's/st_blocks/Blocks/' \
-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_]\)_st_timespec_t\([^a-zA-Z0-9_]\)/\1StTimespec\2/g' \
-e 's/\([^a-zA-Z0-9_]\)_timespec\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
-e 's/\([^a-zA-Z0-9_]\)_timestruc_t\([^a-zA-Z0-9_]\)/\1Timestruc\2/g' \
-e 's/Godump_[0-9] struct { \([^;]*;\) };/\1/g' \
>> ${OUT}
# The directory searching types.
# Prefer largefile variant if available.
dirent=`grep '^type _dirent64 ' gen-sysinfo.go || true`
if test "$dirent" != ""; then
grep '^type _dirent64 ' gen-sysinfo.go
else
grep '^type _dirent ' gen-sysinfo.go
fi | sed -e 's/type _dirent64/type Dirent/' \
-e 's/type _dirent/type Dirent/' \
-e 's/d_name \[0+1\]/d_name [0+256]/' \
-e 's/d_name/Name/' \
-e 's/]int8/]byte/' \
-e 's/d_fileno/Fileno/' \
-e 's/d_ino/Ino/' \
-e 's/d_namlen/Namlen/' \
-e 's/d_off/Off/' \
-e 's/d_reclen/Reclen/' \
-e 's/d_type/Type/' \
>> ${OUT}
echo "type DIR _DIR" >> ${OUT}
# Values for d_type field in dirent.
grep '^const _DT_' gen-sysinfo.go |
sed -e 's/^\(const \)_\(DT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
# The rusage struct.
rusage=`grep '^type _rusage struct' gen-sysinfo.go`
if test "$rusage" != ""; then
# Remove anonymous unions from GNU/Linux <bits/resource.h>.
libgo: add s390 support From Dominik Vogt. * libgo/go/syscall/libcall_linux_s390.go: New file for s390 support. * libgo/go/syscall/syscall_linux_s390.go: Ditto. * libgo/go/syscall/libcall_linux_s390x.go: New file for s390x support. * libgo/go/syscall/syscall_linux_s390x.go: Ditto. * libgo/go/runtime/pprof/pprof.go (printStackRecord): Support s390 and s390x. * libgo/runtime/runtime.c (runtime_cputicks): Add support for s390 and s390x * libgo/mksysinfo.sh: Ditto. (upcase_fields): New helper function * libgo/go/debug/elf/file.go (applyRelocations): Implement relocations on s390x. (applyRelocationsS390x): Ditto. (DWARF): Ditto. * libgo/go/debug/elf/elf.go (R_390): New constants for S390 relocations. (r390Strings): Ditto. (String): Helper function for S390 relocations. (GoString): Ditto. * libgo/go/reflect/makefuncgo_s390.go: New file. (S390MakeFuncStubGo): Implementation of s390 abi. * libgo/go/reflect/makefuncgo_s390x.go: New file. (S390xMakeFuncStubGo): Implementation of s390x abi. * libgo/go/reflect/makefunc_s390.c: New file. (makeFuncStub): s390 and s390x specific implementation of function. * libgo/go/reflect/makefunc.go (MakeFunc): Add support for s390 and s390x. (makeMethodValue): Ditto. (makeValueMethod): Ditto. * libgo/Makefile.am (go_reflect_makefunc_s_file): Ditto. (go_reflect_makefunc_file): Ditto. * libgo/go/reflect/makefunc_dummy.c: Ditto. * libgo/runtime/runtime.h (__go_makefunc_can_recover): Export prototype for use in makefunc_s390.c. (__go_makefunc_returning): Ditto. * libgo/go/syscall/exec_linux.go (forkAndExecInChild): Fix order of the arguments of the clone system call for s390[x]. * libgo/configure.ac (is_s390): New variable. (is_s390x): Ditto (LIBGO_IS_S390): Ditto. (LIBGO_IS_S390X): Ditto. (GOARCH): Support s390 and s390x. * libgo/go/go/build/build.go (cgoEnabled): Ditto. * libgo/go/go/build/syslist.go (goarchList): Ditto. From-SVN: r217106
2014-11-05 06:39:30 +08:00
rusage=`echo $rusage | sed -e 's/Godump_[0-9][0-9]* struct {\([^}]*\)};/\1/g'`
rusage=`echo $rusage | sed -e 's/type _rusage struct //' -e 's/[{}]//g'`
rusage=`echo $rusage | sed -e 's/^ *//'`
nrusage=
while test -n "$rusage"; do
field=`echo $rusage | sed -e 's/^\([^;]*\);.*$/\1/'`
rusage=`echo $rusage | sed -e 's/^[^;]*; *\(.*\)$/\1/'`
# Drop the leading ru_, capitalize the next character.
field=`echo $field | sed -e 's/^ru_//'`
f=`echo $field | sed -e 's/^\(.\).*$/\1/'`
r=`echo $field | sed -e 's/^.\(.*\)$/\1/'`
f=`echo $f | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
# Fix _timeval _timespec, and _timestruc_t.
r=`echo $r | sed -e s'/ _timeval$/ Timeval/'`
r=`echo $r | sed -e s'/ _timespec$/ Timespec/'`
r=`echo $r | sed -e s'/ _timestruc_t$/ Timestruc/'`
field="$f$r"
nrusage="$nrusage $field;"
done
echo "type Rusage struct {$nrusage }" >> ${OUT}
else
echo "type Rusage struct {}" >> ${OUT}
fi
# The RUSAGE constants.
grep '^const _RUSAGE_' gen-sysinfo.go | \
sed -e 's/^\(const \)_\(RUSAGE_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
# The utsname struct.
grep '^type _utsname ' gen-sysinfo.go | \
sed -e 's/_utsname/Utsname/' \
-e 's/sysname/Sysname/' \
-e 's/nodename/Nodename/' \
-e 's/release/Release/' \
-e 's/version/Version/' \
-e 's/machine/Machine/' \
-e 's/domainname/Domainname/' \
>> ${OUT}
# The iovec struct.
iovec=`grep '^type _iovec ' gen-sysinfo.go`
iovec_len=`echo $iovec | sed -n -e 's/^.*iov_len \([^ ]*\);.*$/\1/p'`
echo "type Iovec_len_t $iovec_len" >> ${OUT}
echo $iovec | \
sed -e 's/_iovec/Iovec/' \
-e 's/iov_base/Base/' \
-e 's/iov_len *[a-zA-Z0-9_]*/Len Iovec_len_t/' \
>> ${OUT}
# The msghdr struct.
msghdr=`grep '^type _msghdr ' gen-sysinfo.go`
msghdr_controllen=`echo $msghdr | sed -n -e 's/^.*msg_controllen \([^ ]*\);.*$/\1/p'`
echo "type Msghdr_controllen_t $msghdr_controllen" >> ${OUT}
echo $msghdr | \
sed -e 's/_msghdr/Msghdr/' \
-e 's/msg_name/Name/' \
-e 's/msg_namelen/Namelen/' \
-e 's/msg_iov/Iov/' \
-e 's/msg_iovlen/Iovlen/' \
-e 's/_iovec/Iovec/' \
-e 's/msg_control/Control/' \
-e 's/msg_controllen *[a-zA-Z0-9_]*/Controllen Msghdr_controllen_t/' \
-e 's/msg_flags/Flags/' \
>> ${OUT}
# The MSG_ flags for Msghdr.
grep '^const _MSG_' gen-sysinfo.go | \
sed -e 's/^\(const \)_\(MSG_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
# The cmsghdr struct.
cmsghdr=`grep '^type _cmsghdr ' gen-sysinfo.go`
if test -n "$cmsghdr"; then
cmsghdr_len=`echo $cmsghdr | sed -n -e 's/^.*cmsg_len \([^ ]*\);.*$/\1/p'`
echo "type Cmsghdr_len_t $cmsghdr_len" >> ${OUT}
echo "$cmsghdr" | \
sed -e 's/_cmsghdr/Cmsghdr/' \
-e 's/cmsg_len *[a-zA-Z0-9_]*/Len Cmsghdr_len_t/' \
-e 's/cmsg_level/Level/' \
-e 's/cmsg_type/Type/' \
-e 's/\[\]/[0]/' \
>> ${OUT}
fi
# The SCM_ flags for Cmsghdr.
grep '^const _SCM_' gen-sysinfo.go | \
sed -e 's/^\(const \)_\(SCM_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
# The ucred struct.
upcase_fields "_ucred" "Ucred" >> ${OUT} || true
# The ip_mreq struct.
grep '^type _ip_mreq ' gen-sysinfo.go | \
sed -e 's/_ip_mreq/IPMreq/' \
-e 's/imr_multiaddr/Multiaddr/' \
-e 's/imr_interface/Interface/' \
-e 's/_in_addr/[4]byte/g' \
>> ${OUT}
# We need IPMreq to compile the net package.
if ! grep 'type IPMreq ' ${OUT} >/dev/null 2>&1; then
echo 'type IPMreq struct { Multiaddr [4]byte; Interface [4]byte; }' >> ${OUT}
fi
# The ipv6_mreq struct.
grep '^type _ipv6_mreq ' gen-sysinfo.go | \
sed -e 's/_ipv6_mreq/IPv6Mreq/' \
-e 's/ipv6mr_multiaddr/Multiaddr/' \
-e 's/ipv6mr_interface/Interface/' \
-e 's/_in6_addr/[16]byte/' \
>> ${OUT}
# We need IPv6Mreq to compile the net package.
if ! grep 'type IPv6Mreq ' ${OUT} >/dev/null 2>&1; then
echo 'type IPv6Mreq struct { Multiaddr [16]byte; Interface uint32; }' >> ${OUT}
fi
# The ip_mreqn struct.
grep '^type _ip_mreqn ' gen-sysinfo.go | \
sed -e 's/_ip_mreqn/IPMreqn/' \
-e 's/imr_multiaddr/Multiaddr/' \
-e 's/imr_address/Address/' \
-e 's/imr_ifindex/Ifindex/' \
-e 's/_in_addr/[4]byte/g' \
>> ${OUT}
# We need IPMreq to compile the net package.
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 icmp6_filter struct.
grep '^type _icmp6_filter ' gen-sysinfo.go | \
sed -e 's/_icmp6_filter/ICMPv6Filter/' \
-e 's/data/Data/' \
-e 's/filt/Filt/' \
>> ${OUT}
# We need ICMPv6Filter to compile the syscall package.
if ! grep 'type ICMPv6Filter ' ${OUT} > /dev/null 2>&1; then
echo 'type ICMPv6Filter struct { Data [8]uint32 }' >> ${OUT}
fi
# The ip6_mtuinfo struct.
grep '^type _ip6_mtuinfo ' gen-sysinfo.go | \
sed -e 's/_ip6_mtuinfo/IPv6MTUInfo/' \
-e 's/ip6m_addr/Addr/' \
-e 's/_sockaddr_in6/RawSockaddrInet6/' \
-e 's/ip6m_mtu/Mtu/' \
>> ${OUT}
# We need IPv6MTUInfo to compile the syscall package.
if ! grep 'type IPv6MTUInfo ' ${OUT} >/dev/null 2>&1; then
echo 'type IPv6MTUInfo struct { Addr RawSockaddrInet6; Mtu uint32; }' >> ${OUT}
fi
if ! grep 'const _sizeof_ip6_mtuinfo = ' ${OUT} >/dev/null 2>&1; then
echo 'const SizeofIPv6MTUInfo = 32' >> ${OUT}
fi
# 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"
if test "$fd_set" != ""; then
fds_bits_type=`echo $fd_set | sed -e 's/.*[]]\([^;]*\); }$/\1/'`
fi
echo "type fds_bits_type $fds_bits_type" >> ${OUT}
# The addrinfo struct.
grep '^type _addrinfo ' gen-sysinfo.go | \
sed -e 's/_addrinfo/Addrinfo/g' \
-e 's/ ai_/ Ai_/g' \
>> ${OUT}
# The addrinfo and nameinfo flags and errors.
grep '^const _AI_' gen-sysinfo.go | \
sed -e 's/^\(const \)_\(AI_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
grep '^const _EAI_' gen-sysinfo.go | \
sed -e 's/^\(const \)_\(EAI_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
grep '^const _NI_' gen-sysinfo.go | \
sed -e 's/^\(const \)_\(NI_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
Big merge of changes to gofrontend repo that were postponed due to the GCC release freeze. * go-backend.c: Include "go-c.h". * go-gcc.cc (Gcc_backend::write_export_data): New method. * go-gcc.cc (Gcc_backend::Gcc_backend): Declare __builtin_prefetch. * Make-lang.in (GO_OBJS): Add go/wb.o. commit 884c9f2cafb3fc1decaca70f1817ae269e4c6889 Author: Than McIntosh <thanm@google.com> Date: Mon Jan 23 15:07:07 2017 -0500 compiler: insert additional conversion for type desc ptr expr Change the method Type::type_descriptor_pointer to apply an additional type conversion to its result Bexpression, to avoid type clashes in the back end. The backend expression for a given type descriptor var is given a type of "_type", however the virtual calls that create the variable use types derived from _type, hence the need to force a conversion. Reviewed-on: https://go-review.googlesource.com/35506 commit 5f0647c71e3b29eddcd0eecc44e7ba44ae7fc8dd Author: Than McIntosh <thanm@google.com> Date: Mon Jan 23 15:22:26 2017 -0500 compiler: insure tree integrity in Call_expression::set_result Depending on the back end, it can be problematic to reuse Bexpressions (passing the same Bexpression to more than one Backend call to create additional Bexpressions or Bstatements). The Call_expression::set_result method was reusing its Bexpression input in more than one tree context; the fix is to pass in an Expression instead and generate multiple Bexpression references to it within the method. Reviewed-on: https://go-review.googlesource.com/35505 commit 7a8e49870885af898c3c790275e513d1764a2828 Author: Ian Lance Taylor <iant@golang.org> Date: Tue Jan 24 21:19:06 2017 -0800 runtime: copy more of the scheduler from the Go 1.8 runtime Copies mstart, newm, m0, g0, and friends. Reviewed-on: https://go-review.googlesource.com/35645 commit 3546e2f002d0277d805ec59c5403bc1d4eda4ed9 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Jan 26 19:47:37 2017 -0800 runtime: remove a few C functions that are no longer used Reviewed-on: https://go-review.googlesource.com/35849 commit a71b835254f6d3164a0e6beaf54f2b175d1a6a92 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Jan 26 16:51:16 2017 -0800 runtime: copy over more of the Go 1.8 scheduler In particular __go_go (aka newproc) and goexit[01]. Reviewed-on: https://go-review.googlesource.com/35847 commit c3ffff725adbe54d8283c373b6aa7dc95d6fc27f Author: Ian Lance Taylor <iant@golang.org> Date: Fri Jan 27 16:58:20 2017 -0800 runtime: copy syscall handling from Go 1.8 runtime Entering a syscall still has to start in C, to save the registers. Fix entersyscallblock to save them more reliably. This copies over the tracing code for syscalls, which we previously weren't doing, and lets us turn on runtime/trace/check. Reviewed-on: https://go-review.googlesource.com/35912 commit d5b921de4a28b04000fc4c8dac7f529a4a624dfc Author: Ian Lance Taylor <iant@golang.org> Date: Fri Jan 27 18:34:11 2017 -0800 runtime: copy SIGPROF handling from Go 1.8 runtime Also copy over Breakpoint. Fix Func.Name and Func.Entry to not crash on a nil Func. Reviewed-on: https://go-review.googlesource.com/35913 commit cc60235e55aef14b15c3d2114030245beb3adfef Author: Than McIntosh <thanm@google.com> Date: Mon Feb 6 11:12:12 2017 -0500 compiler: convert go_write_export_data to Backend method. Convert the helper function 'go_write_export_data' into a Backend class method, to allow for an implementation of this function that needs to access backend state. Reviewed-on: https://go-review.googlesource.com/36357 commit e387439bfd24d5e142874b8e68e7039f74c744d7 Author: Than McIntosh <thanm@google.com> Date: Wed Feb 8 11:13:46 2017 -0500 compiler: insert backend conversion in temporary statement init Insert an additional type conversion in Temporary_statement::do_get_backend when assigning a Bexpression initializer to the temporary variable, to avoid potential clashes in the back end. This can come up when assigning something of concrete pointer-to-function type to a variable of generic pointer-to-function type. Reviewed-on: https://go-review.googlesource.com/36591 commit c5acf0ce09e61ff623847a35a99da465b8571609 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 1 17:57:53 2017 +0100 libgo: build tags for aix Build tags for the libgo source files required to build libgo on AIX. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37633 commit 67ed19616898ea18a101ec9325b82d028cd395d9 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 2 15:41:31 2017 +0100 libgo: handle AIX tag in match.sh and gotest Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37638 commit 83ea2d694c10b2dd83fc8620c43da13d20db754e Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 1 17:48:16 2017 +0100 libgo: add AIX support in configure and Makefile - support for GOOS=aix - CFLAGS/GOCFLAGS/LDFLAGS for AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37632 commit 35d577fe22ffa16a3ccaadf5dae9f6f425c8ec8c Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Mon Mar 6 15:00:15 2017 +0100 runtime: adapt memory management to AIX mmap On AIX: * mmap does not allow to map an already mapped range, * mmap range start at 0x30000000 for 32 bits processes, * mmap range start at 0x70000000_00000000 for 64 bits processes Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37845 commit 4e49e56a5fd4072b4ca7fcefe4158d6885d9ee62 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Mon Mar 6 13:42:26 2017 +0100 runtime: add getproccount implementation for AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37844 commit ff626470294237ac664127894826614edc46a3d0 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Mon Mar 6 17:31:21 2017 +0100 runtime: handle ERESTART errno with AIX's wait4 On AIX, wait4 may return with errno set to ERESTART, which causes unexepected behavior (for instance, go build may exit with the message "wait: restart system call" after running a command, even if it was successfull). Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37846 commit 37daabbfc83d533b826ef9ab10e2dee7406e7198 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Mon Mar 6 11:02:58 2017 +0100 runtime: support for AIX's procfs tree On AIX, the process executable file is available under /proc/<pid>/object/a.out Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37842 commit a0275c039d56acf4bf48151978c1a4ec5758cc2c Author: Ian Lance Taylor <iant@golang.org> Date: Wed Mar 8 07:00:05 2017 -0800 libgo/Makefile.am: don't use nonportable \n or \t in sed expression The resulting zstdpktlist.go is less pretty, but it works. Reviewed-on: https://go-review.googlesource.com/37940 commit 29b190f76105aafa2b50b48249afdafecc97a4be Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 9 16:02:34 2017 +0100 runtime: netpoll and semaphores for AIX semaphore implementation based on Solaris implementation in libgo/go/runtime/os_solaris.go netpoll is just a stub to avoid build failure on AIX. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37966 commit 55ca6d3f3cddf0ff9ccb074b2694da9fc54de7ec Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 9 15:38:30 2017 +0100 libmain: ensure initfn is called when loading a go library AIX does not support .init_array. The alterative is to export the __go_init function and tell the linker it is an init function with the -Wl,-binitfini:__go_init option. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37965 commit 349a30d17d880ac8bc1a35e1a2ffee6d6e870ae9 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Mar 10 11:15:08 2017 +0100 libgo: use an import list for missing symbols libgo depends on symbols provided by Go programs at runtime. On AIX, this requires either to build libgo with -Wl,-berok linker option and the programs with -Wl,-brtl, or to provide a list of imported symbols when building libgo. The second options seems preferable, to avoid requiring an additional option for every Go program. There are also some symbols that are specific to GNU ld and do not exist when linking with AIX ld (__data_start, __edata, __etext and __bss_start). Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37969 commit 91db0ea1ff068ca1d97b9c99612100ea5b96ddb2 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 8 15:34:45 2017 +0100 crypto/x509: add certificate files locations for AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37952 commit 92e521c854e91709b949548c47e267377850f26a Author: Ian Lance Taylor <iant@golang.org> Date: Fri Mar 10 14:10:11 2017 -0800 compiler: fix check for pointer in Temporary_reference_expression The check for an unrepresentable pointer in Temporary_reference_expression::do_get_backend was incorrectly translated from C to Go in https://golang.org/cl/14346043. Fix the check to use points_to rather than has_pointer and deref. This should not make any difference in practice as either way the condition will only be true for a pointer to void, but points_to is correct and more efficient. Reviewed-on: https://go-review.googlesource.com/38009 commit 9a0b676e59e7171a630c48fdc3d4de6712bad0ca Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 16 16:51:53 2017 +0100 libgo: add missing _arpcom struct to *sysinfo.go This struct is filtered due to having a field of type _in6_addr, but other types exported to *sysinfo.go are depending on it. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38251 commit 61262a757bdd3d9a595ab6a90f68c0c4ebed7bc1 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 16 18:27:46 2017 +0100 syscall: raw_ptrace stub for AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38253 commit 8029632b50880fd9b5e39299c738b38e3386595f Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 15 16:58:37 2017 +0100 libgo: adapt runtime.inc to AIX * Two AIX types are wrongfully exported to runtime.inc as their names make them look like a Go type. * The sigset go type conflicts with a system sigset type. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38192 commit 25f3a90d14bc268479369ecc0eada72791612f86 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 15 16:58:37 2017 +0100 libgo: update Makefile.in, accidentally omitted from last change Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38310 commit d52b4895616b66f93b460366527e74336829aaa5 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 16 18:39:26 2017 +0100 syscall: TIOCSCTTY does not exist on AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38254 commit ff1ec3847a4472008e5d53a98b6694b1e54ca322 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 16 18:07:34 2017 +0100 syscall: syscall does not exist on AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38252 commit c1ee60dabf0b243a0b0286215481a5d326c34596 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Mar 17 17:18:18 2017 +0100 net: EAI_OVERFLOW does not exist on AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38266 commit ad4ad29aed9f70b14b39b488bfeb9ee745382ec4 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Mar 17 17:23:56 2017 +0100 net: sockopt/sockoptip stubs for AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38267 commit 5d7db2d7542fe7082f426d42f8c2ce14aad6df55 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Mar 17 16:35:05 2017 +0100 os/user: add listgroups stub for AIX This is required to build os/user. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38263 commit 4e57a7973e9fa4cb5ab977c6d792e62a8f7c5795 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 22 11:11:30 2017 +0100 os: fix readdirnames for AIX Largefile implementation should be used on AIX. readdir64_r function returns 9 and sets result to NULL when reaching end of directory, so this return code should not always be considered as an error. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38359 commit b34036967d1ec57b25e3debe077439b4210a1d4a Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Mar 17 17:39:31 2017 +0100 libgo: adapt sigtab.go to AIX On AIX, _NSIG is not directly defined to its integer value in gen-sysinfo.go. The real value is _SIGMAX32+1 or _SIGMAX64+1, depending if we are building a 32bit ligbo or a 64bit libgo, so we need to read one of those constants to set nsig value in mksigtab.sh This change also ensures that all signal numbers from 0 to nsig-1 are referenced in sigtable. Reviewed-on: https://go-review.googlesource.com/38268 commit 20991c32671a183ec859b4f285df37fdd4634247 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 23 17:28:09 2017 +0100 syscall: missing import in socket_bsd.go Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38369 commit c34754bd9adf5496c4c26257eaa50793553c11e8 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 22 17:57:01 2017 +0100 sycall: WCOREDUMP macro is not defined on AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38363 commit 4f38813482227b12ea0ac6ac1b981ff9ef9853ef Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 23 17:44:43 2017 +0100 libgo: additional build tags for AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38510 commit d117ede6ff5a7083e9c40eba28a0f94f3535d773 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 23 17:48:46 2017 +0100 go/build: add AIX to "go build" command known OS Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38511 commit 7b0ddaa6a6a71f9eb1c374122d29775b13c2cac5 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Mar 23 09:57:01 2017 -0700 compiler: don't crash if imported package imports this one When building a test it's OK if test code imports a package that imports this one. The go tool is supposed to catch cases where this creates an impossible initialization order. The compiler already has code to permit this in Gogo::add_import_init_fn. This CL avoids a compiler crash on a similar case when writing out the export data. I have no test case for this. Basically it pushes a compiler crash into an error reported elsewhere. Problem was reported by Tony Reix. Reviewed-on: https://go-review.googlesource.com/38462 commit 925636975d075e3e3353823b09db3f933f23cb03 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Mar 29 14:14:18 2017 -0700 runtime: copy finalizer support from Go 1.8 runtime Reviewed-on: https://go-review.googlesource.com/38794 commit 1ccb22b96cb3b1011db0e427877d9ddecb577fa9 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 30 15:21:06 2017 +0200 runtime: initcontext and setcontext stubs for AIX Further investigations are required to understand the clobbering issue and implement a proper fix. Until then, those stubs are required to allow the build to complete. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38930 commit 27db481f369b54256063c72b911d22390c59199c Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 29 18:07:25 2017 +0200 os: fix Readlink failure on AIX AIX readlink routine returns an error if the link is longer than the buffer, instead of truncating the link. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38700 commit c93babbf48eddd0bc34d4179ffb302dc60087299 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 29 17:26:35 2017 +0200 compiler: implement support for reading AIX big archives This is required to read go export from a Go library. Code courtesy of Damien Bergamini from Atos Infogérance. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38698 commit 930dd53482bdee3a9074850d168d0b9d7819c135 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 6 18:50:11 2017 -0700 compiler: fix whether conversions are static initializers The compiler was incorrectly treating type conversions from string to int or vice-versa as static initializers. That doesn't work, as those conversions are implemented via a function call. This case may never actually arise but it seems like the right thing to do. Reviewed-on: https://go-review.googlesource.com/39872 commit f02691e4195728dbf06f4dde0853c6bccc922183 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 6 17:24:08 2017 -0700 compiler, runtime: don't let slices point past end of memory block When Go code uses a slice expression like [:len(str)] or [:cap(slice)], it's natural for the resulting pointer to point just past the end of the memory block. If the next memory block is not live, we now have a live pointer to a dead block, which will unnecessarily keep the block alive. That wastes space, and with the new Go 1.8 GC (not yet committed) will trigger an error when using GODEBUG=gccheckmark=1. This changes the implementation of slice expressions to not move the pointer if the resulting string length or slice capacity is 0. When the length/capacity is zero, the pointer is never used anyhow. Reviewed-on: https://go-review.googlesource.com/39870 commit 17527c35b027e1afcc318faf5563909e1e9d44a6 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 6 15:30:11 2017 -0700 compiler: emit write barriers The Go 1.8 concurrent GC requires optional write barriers for all assignments that may change pointer values in the heap or in a global variable. For details see https://blog.golang.org/go15gc. This changes the gofrontend code to emit write barriers as needed. This is in preparation for future changes. At the moment the write barriers will do nothing. They test runtime.writeBarrier.enabled, which will never be non-zero. They call simple functions which just do a move without doing any of the other operations required by the write barrier. Reviewed-on: https://go-review.googlesource.com/39852 commit c0b00f072bf34b2c288e1271ec8118b88c4f6f6f Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Tue Apr 11 17:47:29 2017 +0200 libgo: allow building gox files from PIC objects libtool builds non-PIC objects in the same directory as .lo files and PIC objects in a .libs subdirectory. BUILDGOX rule uses the non-PIC objects to build the gox files, but on AIX only the PIC objects are built. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/40355 commit ea0f3da174c5503a209043f14ddda34871cfec52 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 6 19:06:14 2017 -0700 compiler: add code to generate a ptrmask for a type The Go 1.8 garbage collector uses a ptrmask for all types below a certain size. A ptrmask is simply a bit vector with a single bit for each pointer-sized word in the value. The bit is 1 if the type has a pointer in that position, 0 if it does not. This change adds code to the compiler to generate a ptrmask. The code is not used by anything yet, it is just compiled. It will be used when we switch over to the Go 1.8 garbage collector. The new Array_type::int_length method, and the new memory_size methods, will also be used by other patches coming later. Reviewed-on: https://go-review.googlesource.com/39873 commit 3029e1df3be3614d196a03c15e50e68ff850aa4c Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 7 10:31:39 2017 -0700 compiler: add code to generate a gcprog for a type The Go 1.8 garbage collector uses a gcprog for all types above a certain size. A gcprog describes where the pointers are in the type, using a simple bytecode machine that supports repeating bits. The effect is to permit using much less space to describe arrays. The format is described in runtime/mbitmap.go in the docs for runGCProg. This is not yet added to the gofrontend, but can be seen in the gc sources. This change adds code to the compiler to generate a gcprog. The code is not used by anything yet, it is just compiled. It will be used when we switch over to the Go 1.8 garbage collector. Reviewed-on: https://go-review.googlesource.com/39923 commit 8b01ef1e9176d20f4c9e667972fe031069a4d057 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 13 07:00:35 2017 -0700 compiler: add ptrdata computations and expressions For the upcoming Go 1.8 GC we need to compute the "ptrdata" of a type: the number of bytes in the type that can contain pointers. For types that do not contain pointers this number is zero. For many types it is a number larger than zero but smaller than the total size of the type. The Go 1.8 GC uses this number to make loops looking for pointers run faster by not scanning the suffix of a value that can not contain a pointer. Unfortunately there are two subtly different definitions of ptrdata, and we need both. The first is the simple one: the prefix that can contain pointers. The second is the number of bytes described by the gcprog for the type. Recall that we describe the exact position of pointers in a type using either a ptrmask or a gcprog. The ptrmask is simpler, the gcprog uses less space. We use the gcprog for large types, currently defined as types that are more than 2048 bytes. When the Go 1.8 runtime expands a gcprog, it verifies that the gcprog describes exactly the same number of bytes as the ptrdata field in the type descriptor. If the last pointer-containing portion of a type is an array, and if the elements of the array have a ptrdata that is less than the size of the element type, then the simple definition of the ptrdata will not include the final non-pointer-containing bytes of the last element of the array. However, the gcprog will define the array using a repeat count, and will therefore include the full size of the last element of the array. So for a type that needs a gcprog, the ptrdata field in the type descriptor must be the size of the data described by the gcprog, and that is not necessarily the same as the simple ptrdata. It might seem that we can always use the gcprog version of the ptrdata calculation, since that is what will appear in a type descriptor, but it turns out that for global variables we always use a ptrmask, not a gcprog, even if the global variable is large. This is because gcprogs are handled by expanding them into a ptrmask at runtime, and for a global variable there is no natural place to put the ptrmask. Simpler to always use the ptrmask. That means that we need to describe the size of the ptrmask, and that means that we need an expression for the simple form of the ptrdata. This CL implements the ptrdata calculation. This code is not actually used yet. It will be used later when the Go 1.8 GC is committed. Reviewed-on: https://go-review.googlesource.com/40573 commit 7a37331303b572412179a08141f1dd35339d40c8 Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 06:55:48 2017 -0700 compiler: zero length arrays never contain pointers Reviewed-on: https://go-review.googlesource.com/40696 commit c242f0508a64d3d74a28d498cbaeda785ff76258 Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 07:26:54 2017 -0700 bytes: disable allocations test on gccgo It turns out that testing.AllocsPerRun has not been producing correct results with the current gccgo memory allocator. When we update to the Go 1.8 memory allocator, testing.AllocsPerRun will work again, and this test will fail due to lack of escape analysis. Reviewed-on: https://go-review.googlesource.com/40700 commit 0dc369f1d63376a36bfb0999a1b0377fd444bfab Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Tue Apr 11 16:22:38 2017 +0200 os: alternative way to find executable path, using Args[0] AIX does not provide a proper way to find the original executable path from procfs, which contains just an hardlink. Executable path can be found using Args[0], Getcwd and $PATH. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/40353 commit f9bad1342569b338e3b2ea9f12ffc6d3d3fa3028 Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 08:01:19 2017 -0700 compiler: don't write struct with multiple sink fields to C header file When writing a struct to the C header file used by the C runtime code, a single sink field is fine: it will be called "_", which is valid C. There are structs with single sink fields that we want to write out, such as finblock. As it happens, though, the Go 1.8 runtime has a struct with two sink fields, gcControllerState, which will produce a C definition with two fields named "_", which will fail. Since we don't need to know that struct in C, rather than fix the general case, just punt if the struct has multiple sink fields. After the conversion to the Go 1.8 GC, we may be able to get rid of the C header file anyhow. I'm not sure yet. Reviewed-on: https://go-review.googlesource.com/40701 commit cfc28901a572aeb15b2f10a38f79eec04c64dfb2 Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 10:07:23 2017 -0700 runtime: disable allocations test on gccgo It turns out that testing.AllocsPerRun has not been producing correct results with the current gccgo memory allocator. When we update to the Go 1.8 memory allocator, testing.AllocsPerRun will work again, and these tests will fail due to lack of escape analysis. Reviewed-on: https://go-review.googlesource.com/40703 commit 36fedd76edaa48b9ec09709a70d9e4abaddf0caf Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 10:47:06 2017 -0700 runtime: remove unused size argument from hash/equal fns The size argument was removed from hash and equal functions in CL 34983. Somehow I missed removing them from three of the predefined functions. Reviewed-on: https://go-review.googlesource.com/40770 commit 90f6accb48d2e78cad8955b9292933f6ce3fe4c8 Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 13:23:05 2017 -0700 runtime: remove unused stack.go We're never going to use stack.go for gccgo. Although a build tag keeps it from being built, even having it around can be confusing. Remove it. Reviewed-on: https://go-review.googlesource.com/40774 commit befa71603fc66a214e01ac219f2bba36e19f136f Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 13:18:34 2017 -0700 runtime: build fastlog Take out the build tags which were preventing fastlog2 from being built. It's used by the upcoming Go 1.8 GC. Reviewed-on: https://go-review.googlesource.com/40773 commit b7e19e9be4ab4c3cd8f4c9506d79a8cd56bace40 Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 10:04:23 2017 -0700 runtime: add tests from Go 1.8 Some runtime package tests never made it into the gofrontend repo for some reason. Add them now. Reviewed-on: https://go-review.googlesource.com/40869 commit 1feef185aebd71bc2a09b9a04287461806096610 Author: Ian Lance Taylor <iant@golang.org> Date: Mon Apr 17 16:26:11 2017 -0700 runtime: change mcall to take a Go function value For future work in bringing in the Go 1.8 GC, change the mcall function to take a Go function value, which means that mcall can take a closure rather than just a straight C function pointer. As part of this change move kickoff from C to Go, which we want to do anyhow so that we run the write barriers that it generates. Reviewed-on: https://go-review.googlesource.com/40935 commit c3db34f4efc2d610f74a01dd2ad7775f48889b29 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Tue Apr 11 16:11:26 2017 +0200 runtime: netpoll implementation for AIX Code courtesy of Damien Bergamini from Atos Infogérance. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/40352 commit f5634dff40e53ad9ce61afd67fd07334e3af9d1f Author: Ian Lance Taylor <iant@golang.org> Date: Tue Apr 18 22:06:07 2017 -0700 runtime: move mstart from Go to C The assignments done in mstart must be done without write barriers, as mstart is running without an m or p. In the gc toolchain the equivalent code to intialize g and g->m is written in assembler; on GNU/Linux, it's in the clone function. Reviewed-on: https://go-review.googlesource.com/40989 commit 671d7c74592f4b6fe3665af279482ba0ea47ca2d Author: Ian Lance Taylor <iant@golang.org> Date: Tue Apr 18 17:47:28 2017 -0700 compiler: varargs slices do not escape in runtime Also, don't try to allocate an empty slice on the stack, as it will confuse the GCC backend. Also add a few trivial style, code formatting, and debug output fixes. Updates golang/go#17431 Reviewed-on: https://go-review.googlesource.com/40983 commit 94699d25f31353bf03419eda56b15993a39f3275 Author: Ian Lance Taylor <iant@golang.org> Date: Tue Apr 18 17:30:09 2017 -0700 compiler: add Ptrmask_symbol_expression Add an expression to evaluate to the ptrmask for a type. This will be used for global variables, which always use a ptrmask no matter how large they are. Reviewed-on: https://go-review.googlesource.com/40981 commit bfff1654eac5b9288fa6c431e66cba8c9da6a660 Author: Ian Lance Taylor <iant@golang.org> Date: Mon Apr 17 10:51:16 2017 -0700 runtime: change g's in systemstack The systemstack function in the gc toolchain changes to a different g. This is often used to get more stack space; the gofrontend uses a different stack growth mechanism that does not require changing g's, so we've been running with a version of systemstack that keeps the same g. However, the garbage collector has various tests to verify that it is running on g0 rather than on a normal g. For simplicity, change the gofrontend version of systemstack to change to a different g just as the gc toolchain does. This permits us to uncomment some sanity checks in notetsleep. Doing that requires us to fix up a couple of places where C code calls {start,stop}TheWorldWithSema while not on g0. Note that this does slow down some code in the runtime package unnecessarily. It may be useful to find some places where the runtime calls systemstack only to get more stack space and change it to use some other function. That other function would act like systemstack in the gc toolchain but simply call the argument in the gofrontend. Reviewed-on: https://go-review.googlesource.com/40973 commit b2ccc7601ce71a7c5732154cf9b2eeea64681469 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 10:36:12 2017 -0700 compiler, runtime: include ptrmask in GC roots Change the list of registered GC roots to include a ptrmask, and change the data structures to be easily used from Go code. The new ptrmask will be used by the Go 1.8 GC to only scan pointers. Tweak the current GC to use the new structures, but ignore the new ptrmask information for now. The new GC root data includes the size of the variable. The size is not currently used, but will be used later by the cgo checking code. Reviewed-on: https://go-review.googlesource.com/41075 commit 9e065149970bc180e4ca83bb99c74d9c4f43b47b Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 12:23:16 2017 -0700 compiler, runtime: don't pass size to __go_new There is no reason to pass the size to __go_new, as the type descriptor includes the size anyhow. This makes the function correspond to the Go 1.8 function runtime.newobject, which is what we will use when we update to the Go 1.8 memory allocator. Reviewed-on: https://go-review.googlesource.com/41080 commit c321de7b738c4a3387c1842919c9305acfa04c57 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 13:13:56 2017 -0700 compiler, runtime, reflect: make type descriptors more like Go 1.8 Change the type descriptor structure to be more like the one in the Go 1.8 runtime. Specifically we add the ptrdata field, rename the gc field to gcdata and change the type to *byte, and rearrange a few of the fields. The structure is still not identical to the Go 1.8 structure--we don't use any of the tricks to reduce overall executable size--but it is more similar. For now we don't use the new ptrdata field, and the gcdata field is still the old format rather than the new Go 1.8 ptrmask/gcprog format. Reviewed-on: https://go-review.googlesource.com/41081 commit 7b70c52cddeebea9ebeac003f8c6aad59497e5f0 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 14:54:29 2017 -0700 reflect: make sure to clear unusable hash/equal function Otherwise we wind up copying the one from the prototype, which is wrong. Also rewrite the hash/equal functions to look like the ones in Go 1.8, mainly a matter of changing names and using arrayAt. Reviewed-on: https://go-review.googlesource.com/41133 commit 84d26f467f7de8bdbb0d230458135fe1b6b2a99d Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 14:59:13 2017 -0700 runtime: remove duplicate declarations of SetFinalizer/KeepAlive These should have been removed in CL 38794. It's a bug that the compiler even permits these duplicate declarations. Reviewed-on: https://go-review.googlesource.com/41134 commit f85ff7e64c24031f6d0bd7c9c426b6176cb95160 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 15:56:32 2017 -0700 runtime: don't crash if panicstring called with no m It's possible for runtime_panicstring to be called with no m if a signal handler, or scheduler innards, do something wrong. If that happens carry on with the panic rather than crashing. Reviewed-on: https://go-review.googlesource.com/41137 commit 5b362b04f642afb8b20715930416fc3b7d91bb12 Author: Than McIntosh <thanm@google.com> Date: Fri Mar 31 14:35:48 2017 -0400 compiler: fix for expr sharing introduced by Order_eval::statement. When processing an expression statement with a top-level call that returns multiple results, Order_eval::statement can wind up creating a tree that has multiple references to the same call, which results in a confusing AST dump. Change the implementation to avoid introducing this unwanted sharing. Reviewed-on: https://go-review.googlesource.com/39210 commit b05b4260a68695bf9c9cc29e14ae86ca2699458a Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 16:00:28 2017 -0700 runtime: restore correct m in gtraceback If gtraceback is used to get a stack trace of a g running in the same m, as can happen if we collect a stack trace from a g0, then restore the old m value, don't clear it. Reviewed-on: https://go-review.googlesource.com/41138 commit ca8bbf4dfac19b3f4f7ce21a688b96a418c75031 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 16:03:24 2017 -0700 runtime: set startpc field when starting a new goroutine This puts the right value in a trace--previously it was always zero. Reviewed-on: https://go-review.googlesource.com/41139 commit ca8bbf4dfac19b3f4f7ce21a688b96a418c75031 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 16:03:24 2017 -0700 runtime: set startpc field when starting a new goroutine This puts the right value in a trace--previously it was always zero. Reviewed-on: https://go-review.googlesource.com/41139 commit 887690dce42d7bf8f711f8ea082e4928fb70f2a5 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 17:06:11 2017 -0700 runtime: add prefetch functions The Go 1.8 GC uses prefetch functions. Add versions for gccgo that call __builtin_prefetch. Uncomment the test for them in testAtomic64. Don't force the check function to return early, as now taking the address of a local variable in the runtime package does not force it onto the heap. Reviewed-on: https://go-review.googlesource.com/41144 commit 4269db69f9184e5a45c54aaee7352425a1f88bff Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 17:55:21 2017 -0700 runtime: split up ticks to get correct alignment On 32-bit x86 a uint64 variable by itself is aligned to an 8-byte boundary. A uint64 field in a struct is aligned to a 4-byte boundary. The runtime.ticks variable has a uint64 field that must be aligned to an 8-byte boundary. Rather than rely on luck, split up the struct into separate vars so that the required alignment happens reliably. It would be much nicer if issue golang/go#19057 were fixed somehow, but that is for another day. Reviewed-on: https://go-review.googlesource.com/41143 commit 66926cabdbdbf3431b4f172f7756e195c1c6c513 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Apr 20 17:15:38 2017 +0200 libgo: fix bad value for O_CLOEXEC on AIX 7.1 On AIX 7.1, O_CLOEXEC is defined as 0x0000001000000000, which creates an integer constant overflow error when building libgo. This affects only 7.1, O_CLOEXEC is not defined on 6.1 (and defaults to O in sysinfo.go) and is defined as 0x00800000 on AIX 7.2. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/41214 commit af288ff10aeafc47651f5def327ed56425d5be19 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 20 17:15:02 2017 -0700 runtime: preserve stack context in tracebackothers The tracebackothers function works by saving the current stack context in the goroutine's context field and then calling gogo to switch to a new goroutine. The new goroutine will collect its own stack trace and then call gogo to switch back to the original goroutine. This works fine, but if the original goroutine was called by mcall then the contents of its context field are needed to return from the mcall. Fix this by saving the stack context across the calls to the other goroutines. Reviewed-on: https://go-review.googlesource.com/41293 commit 43101e5956e793f1b4de05c15d7738c785e927df Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Apr 21 10:58:52 2017 +0200 os/user: use _posix_* libc functions libc getpwnam_r function has a different signature, we must use _posix_getpwnam_r instead (by default, the pwd.h system include file defines getpwnam_r as a static function calling _posix_getpwnam_r, so a C program calling getpwnam_r will indeed reference the _posix_getpwnam_r symbol). Idem for getpwuid_r, getgrnam_r and getgrgid_r. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/41334 commit 71e1fec4d2a536591ea6657a06916a17b5127071 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 21:24:48 2017 -0700 runtime: don't use pointers in g_ucontext_t or stackcontext The g_ucontext_t type holds registers saved for a goroutine. We have to scan it for pointers, but since registers don't necessarily hold pointers we have to scan it conservatively. That means that it should not have a pointer type, since the GC will always scan pointers. Instead it needs special treatment to be scanned conservatively. The current GC doesn't care when a pointer type holds a non-pointer, but the Go 1.8 GC does. For the current GC this means we have to explicitly scan the g_ucontext_t values in a G. While we're at it change stackcontext to be uintptr too. The entries in stackcontext never hold pointers that the Go GC cares about. Reviewed-on: https://go-review.googlesource.com/41270 commit eab2960aee91d3e3a6baa5b1bce01262d24c714f Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 20 17:08:19 2017 -0700 runtime/internal/sys: define Goexperiment The gc toolchain defines Goexperiment based on the environment variable GOEXPERIMENT when the toolchain is built. We just always set Goexperiment to the empty string. Reviewed-on: https://go-review.googlesource.com/41292 commit be4a751943265c0637da859d15a4faf162f5c478 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Apr 20 14:04:35 2017 +0200 net: sockopt implementation for AIX This is a copy of the Linux implementation, it allows to run some simple client/server applications on AIX, while the current sockopt stubs don't. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/41213 commit 46a669c4ca5b80fd6f6a0a42095804d9f704611d Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 29 17:55:06 2017 +0200 math: fix sign for atan/expm1/log1p(-0) AIX libc returns +0 for atan(-0), expm1(-0) and log1p(-0), while matching Go functions must return -0. Code courtesy of Tony Reix. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38699 commit 53b0e809130038a46f0a3d2870e3905f44ab888d Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Apr 26 17:29:22 2017 +0200 runtime: fix context clobbering on AIX On AIX 64-bits, r13 is a pointer to thread data. setcontext() overwrites r13 with the value saved by getcontext(). So, when a goroutine is scheduled on a new thread, r13 will point to the old thread data after calling setcontext(). Code courtesy of Damien Bergamini. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/41854 commit f8d5ebd71c71e6e777200530d8204b92619157f8 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Apr 26 18:01:19 2017 +0200 runtime: fix wrong time calculation in semasleep tv_nsec is added twice when calculating the sleep end time. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/41855 commit ef56097f4ea848d48fbf61eba1c757fe7fce99d3 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Apr 28 10:27:32 2017 +0200 libgo: pass $(NM) value when running benchmarks On AIX, we need to use "nm -B" instead of "nm", to have the epxected output format, so the configured $(NM) value from the Makefile should be exported before running gotest, which defaults to "nm" if $NM is not set. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/42051 commit 0fb550083ae474fb964435927b899ec8e4b62771 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Nov 16 21:12:53 2016 -0800 runtime: copy garbage collector from Go 1.8 runtime This giant patch replaces the old Go 1.4 memory allocator and garbage collector with the new Go 1.8 code. The memory allocator is fairly similar, though now written in Go rather than C. The garbage collector is completely different. It now uses ptrmask and gcprog information, which requires changes in the compiler and the reflect package as well as the runtime. And, of course, the garbage collector now runs concurrently with program execution. In the gc toolchain the garbage collector is strict and precise at all levels. In the gofrontend we do not have stack maps, so stacks, and register values, are collected conservatively. That means that an old, no longer used, pointer on a stack or in a register can cause a memory object to live longer than it should. That in turns means that we must disable some checks for invalid pointers in the garbage collection code. Not only can we get an invalid pointer on the stack; the concurrent nature of the collector means that we can in effect resurrect a block that was already unmarked but that the collector had not yet gotten around to freeing, and that block can in turn point to other blocks that the collector had managed to already free. So we must disable pointer checks in general. In effect we are relying on the fact that the strict pointer checks in the gc toolchain ensure that the garbage collector is correct, and we just assume that it is correct for the gofrontend since we are using the same code. Reviewed-on: https://go-review.googlesource.com/41307 commit a95078d501175240d095500a8c5fbfb21bec65cb Author: Ian Lance Taylor <iant@golang.org> Date: Mon Apr 24 16:33:47 2017 -0700 libgo/Makefile: clean more files Fix up the mostlyclean, clean, and distclean targets to better follow https://www.gnu.org/prep/standards/html_node/Standard-Targets.html. Reviewed-on: https://go-review.googlesource.com/41625 commit 5956bf1055451cf4239cdfeca259c23b1ded54d8 Author: Ian Lance Taylor <iant@golang.org> Date: Mon May 8 13:35:11 2017 -0700 libgo: delete goc2c The last .goc file has been removed, so remove goc2c. The goc2c program was my first contribution to the gc repository that was more than 100 lines: https://github.com/golang/go/commit/2b57a1124e87b0dc8bc1ff6899297b4d7d6e74f2 The program was used in gc for a few years under various guises but was finally removed in https://golang.org/cl/132680043. Now we can remove it from gofrontend as well. Reviewed-on: https://go-review.googlesource.com/42911 commit a222e35d041de0cd42506b61c93b8209e07702b9 Author: Than McIntosh <thanm@google.com> Date: Tue May 9 10:33:10 2017 -0400 compiler: set "need_init_fn" when adding gc root Variables that back slice initializers in certain cases have to be added to the gc roots list, since they can be modified at runtime. The code that was doing this addition did not update the flag that tracks whether the package being compiled needs an initializer function, which resulted in the call in question being left out of the final generated code in certain cases. Fix is to change Gogo::add_gc_root() to update the "needs init" flag. Reviewed-on: https://go-review.googlesource.com/43030 commit 822ab419bf7d1c705cdce1c12133e7a11f56be2e Author: Than McIntosh <thanm@google.com> Date: Tue May 9 11:36:51 2017 -0400 compiler: fix variable context nit in write barrier generation Update the write barrier generation code to insure that the "lvalue context" tag on the space var expression is set only in the case where the expr feeds directly into an assignment. This is somewhat counter-intuitive, but needed in the case where the backend looks at context tags. Reviewed-on: https://go-review.googlesource.com/43031 From-SVN: r247848
2017-05-11 01:26:09 +08:00
# If nothing else defined EAI_OVERFLOW, make sure it has a value.
if ! grep "const EAI_OVERFLOW " ${OUT} >/dev/null 2>&1; then
echo "const EAI_OVERFLOW = 0" >> ${OUT}
fi
# The passwd struct.
grep '^type _passwd ' gen-sysinfo.go | \
sed -e 's/_passwd/Passwd/' \
-e 's/ pw_/ Pw_/g' \
>> ${OUT}
# The group struct.
grep '^type _group ' gen-sysinfo.go | \
sed -e 's/_group/Group/' \
-e 's/ gr_/ Gr_/g' \
>> ${OUT}
# 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}
grep '^const _TUNSET' gen-sysinfo.go | \
grep -v '_val =' | \
sed -e 's/^\(const \)_\(TUNSET[^= ]*\)\(.*\)$/\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
if ! grep '^const TIOCSWINSZ' ${OUT} >/dev/null 2>&1; then
if grep '^const _TIOCSWINSZ_val' ${OUT} >/dev/null 2>&1; then
echo 'const TIOCSWINSZ = _TIOCSWINSZ_val' >> ${OUT}
fi
fi
if ! grep '^const TIOCNOTTY' ${OUT} >/dev/null 2>&1; then
if grep '^const _TIOCNOTTY_val' ${OUT} >/dev/null 2>&1; then
echo 'const TIOCNOTTY = _TIOCNOTTY_val' >> ${OUT}
fi
fi
if ! grep '^const TIOCSCTTY' ${OUT} >/dev/null 2>&1; then
if grep '^const _TIOCSCTTY_val' ${OUT} >/dev/null 2>&1; then
echo 'const TIOCSCTTY = _TIOCSCTTY_val' >> ${OUT}
fi
fi
if ! grep '^const TIOCGPGRP' ${OUT} >/dev/null 2>&1; then
if grep '^const _TIOCGPGRP_val' ${OUT} >/dev/null 2>&1; then
echo 'const TIOCGPGRP = _TIOCGPGRP_val' >> ${OUT}
fi
fi
if ! grep '^const TIOCSPGRP' ${OUT} >/dev/null 2>&1; then
if grep '^const _TIOCSPGRP_val' ${OUT} >/dev/null 2>&1; then
echo 'const TIOCSPGRP = _TIOCSPGRP_val' >> ${OUT}
fi
fi
if ! grep '^const TIOCGPTN' ${OUT} >/dev/null 2>&1; then
if grep '^const _TIOCGPTN_val' ${OUT} >/dev/null 2>&1; then
echo 'const TIOCGPTN = _TIOCGPTN_val' >> ${OUT}
fi
fi
if ! grep '^const TIOCSPTLCK' ${OUT} >/dev/null 2>&1; then
if grep '^const _TIOCSPTLCK_val' ${OUT} >/dev/null 2>&1; then
echo 'const TIOCSPTLCK = _TIOCSPTLCK_val' >> ${OUT}
fi
fi
if ! grep '^const TIOCGDEV' ${OUT} >/dev/null 2>&1; then
if grep '^const _TIOCGDEV_val' ${OUT} >/dev/null 2>&1; then
echo 'const TIOCGDEV = _TIOCGDEV_val' >> ${OUT}
fi
fi
if ! grep '^const TIOCSIG' ${OUT} >/dev/null 2>&1; then
if grep '^const _TIOCSIG_val' ${OUT} >/dev/null 2>&1; then
echo 'const TIOCSIG = _TIOCSIG_val' >> ${OUT}
fi
fi
if ! grep '^const TUNSETNOCSUM' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNSETNOCSUM_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNSETNOCSUM = _TUNSETNOCSUM_val' >> ${OUT}
fi
fi
if ! grep '^const TUNSETDEBUG' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNSETDEBUG_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNSETDEBUG = _TUNSETDEBUG_val' >> ${OUT}
fi
fi
if ! grep '^const TUNSETIFF' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNSETIFF_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNSETIFF = _TUNSETIFF_val' >> ${OUT}
fi
fi
if ! grep '^const TUNSETPERSIST' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNSETPERSIST_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNSETPERSIST = _TUNSETPERSIST_val' >> ${OUT}
fi
fi
if ! grep '^const TUNSETOWNER' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNSETOWNER_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNSETOWNER = _TUNSETOWNER_val' >> ${OUT}
fi
fi
if ! grep '^const TUNSETLINK' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNSETLINK_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNSETLINK = _TUNSETLINK_val' >> ${OUT}
fi
fi
if ! grep '^const TUNSETGROUP' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNSETGROUP_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNSETGROUP = _TUNSETGROUP_val' >> ${OUT}
fi
fi
if ! grep '^const TUNGETFEATURES' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNGETFEATURES_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNGETFEATURES = _TUNGETFEATURES_val' >> ${OUT}
fi
fi
if ! grep '^const TUNSETOFFLOAD' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNSETOFFLOAD_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNSETOFFLOAD = _TUNSETOFFLOAD_val' >> ${OUT}
fi
fi
if ! grep '^const TUNSETTXFILTER' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNSETTXFILTER_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNSETTXFILTER = _TUNSETTXFILTER_val' >> ${OUT}
fi
fi
if ! grep '^const TUNGETIFF' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNGETIFF_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNGETIFF = _TUNGETIFF_val' >> ${OUT}
fi
fi
if ! grep '^const TUNGETSNDBUF' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNGETSNDBUF_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNGETSNDBUF = _TUNGETSNDBUF_val' >> ${OUT}
fi
fi
if ! grep '^const TUNSETSNDBUF' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNSETSNDBUF_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNSETSNDBUF = _TUNSETSNDBUF_val' >> ${OUT}
fi
fi
if ! grep '^const TUNATTACHFILTER' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNATTACHFILTER_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNATTACHFILTER = _TUNATTACHFILTER_val' >> ${OUT}
fi
fi
if ! grep '^const TUNDETACHFILTER' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNDETACHFILTER_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNDETACHFILTER = _TUNDETACHFILTER_val' >> ${OUT}
fi
fi
if ! grep '^const TUNGETVNETHDRSZ' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNGETVNETHDRSZ_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNGETVNETHDRSZ = _TUNGETVNETHDRSZ_val' >> ${OUT}
fi
fi
if ! grep '^const TUNSETVNETHDRSZ' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNSETVNETHDRSZ_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNSETVNETHDRSZ = _TUNSETVNETHDRSZ_val' >> ${OUT}
fi
fi
if ! grep '^const TUNSETQUEUE' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNSETQUEUE_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNSETQUEUE = _TUNSETQUEUE_val' >> ${OUT}
fi
fi
if ! grep '^const TUNSETIFINDEX' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNSETIFINDEX_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNSETIFINDEX = _TUNSETIFINDEX_val' >> ${OUT}
fi
fi
if ! grep '^const TUNGETFILTER' ${OUT} >/dev/null 2>&1; then
if grep '^const _TUNGETFILTER_val' ${OUT} >/dev/null 2>&1; then
echo 'const TUNGETFILTER = _TUNGETFILTER_val' >> ${OUT}
fi
fi
# The ioctl flags for terminal control
grep '^const _TC[GS]ET' gen-sysinfo.go | grep -v _val | \
sed -e 's/^\(const \)_\(TC[GS]ET[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
if ! grep '^const TCGETS' ${OUT} >/dev/null 2>&1; then
if grep '^const _TCGETS_val' ${OUT} >/dev/null 2>&1; then
echo 'const TCGETS = _TCGETS_val' >> ${OUT}
fi
fi
if ! grep '^const TCSETS' ${OUT} >/dev/null 2>&1; then
if grep '^const _TCSETS_val' ${OUT} >/dev/null 2>&1; then
echo 'const TCSETS = _TCSETS_val' >> ${OUT}
fi
fi
# ioctl constants. Might fall back to 0 if TIOCNXCL is missing, too, but
# needs handling in syscalls.exec.go.
if ! grep '^const _TIOCSCTTY ' gen-sysinfo.go >/dev/null 2>&1; then
if grep '^const _TIOCNXCL ' gen-sysinfo.go >/dev/null 2>&1; then
echo "const TIOCSCTTY = TIOCNXCL" >> ${OUT}
fi
fi
Big merge of changes to gofrontend repo that were postponed due to the GCC release freeze. * go-backend.c: Include "go-c.h". * go-gcc.cc (Gcc_backend::write_export_data): New method. * go-gcc.cc (Gcc_backend::Gcc_backend): Declare __builtin_prefetch. * Make-lang.in (GO_OBJS): Add go/wb.o. commit 884c9f2cafb3fc1decaca70f1817ae269e4c6889 Author: Than McIntosh <thanm@google.com> Date: Mon Jan 23 15:07:07 2017 -0500 compiler: insert additional conversion for type desc ptr expr Change the method Type::type_descriptor_pointer to apply an additional type conversion to its result Bexpression, to avoid type clashes in the back end. The backend expression for a given type descriptor var is given a type of "_type", however the virtual calls that create the variable use types derived from _type, hence the need to force a conversion. Reviewed-on: https://go-review.googlesource.com/35506 commit 5f0647c71e3b29eddcd0eecc44e7ba44ae7fc8dd Author: Than McIntosh <thanm@google.com> Date: Mon Jan 23 15:22:26 2017 -0500 compiler: insure tree integrity in Call_expression::set_result Depending on the back end, it can be problematic to reuse Bexpressions (passing the same Bexpression to more than one Backend call to create additional Bexpressions or Bstatements). The Call_expression::set_result method was reusing its Bexpression input in more than one tree context; the fix is to pass in an Expression instead and generate multiple Bexpression references to it within the method. Reviewed-on: https://go-review.googlesource.com/35505 commit 7a8e49870885af898c3c790275e513d1764a2828 Author: Ian Lance Taylor <iant@golang.org> Date: Tue Jan 24 21:19:06 2017 -0800 runtime: copy more of the scheduler from the Go 1.8 runtime Copies mstart, newm, m0, g0, and friends. Reviewed-on: https://go-review.googlesource.com/35645 commit 3546e2f002d0277d805ec59c5403bc1d4eda4ed9 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Jan 26 19:47:37 2017 -0800 runtime: remove a few C functions that are no longer used Reviewed-on: https://go-review.googlesource.com/35849 commit a71b835254f6d3164a0e6beaf54f2b175d1a6a92 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Jan 26 16:51:16 2017 -0800 runtime: copy over more of the Go 1.8 scheduler In particular __go_go (aka newproc) and goexit[01]. Reviewed-on: https://go-review.googlesource.com/35847 commit c3ffff725adbe54d8283c373b6aa7dc95d6fc27f Author: Ian Lance Taylor <iant@golang.org> Date: Fri Jan 27 16:58:20 2017 -0800 runtime: copy syscall handling from Go 1.8 runtime Entering a syscall still has to start in C, to save the registers. Fix entersyscallblock to save them more reliably. This copies over the tracing code for syscalls, which we previously weren't doing, and lets us turn on runtime/trace/check. Reviewed-on: https://go-review.googlesource.com/35912 commit d5b921de4a28b04000fc4c8dac7f529a4a624dfc Author: Ian Lance Taylor <iant@golang.org> Date: Fri Jan 27 18:34:11 2017 -0800 runtime: copy SIGPROF handling from Go 1.8 runtime Also copy over Breakpoint. Fix Func.Name and Func.Entry to not crash on a nil Func. Reviewed-on: https://go-review.googlesource.com/35913 commit cc60235e55aef14b15c3d2114030245beb3adfef Author: Than McIntosh <thanm@google.com> Date: Mon Feb 6 11:12:12 2017 -0500 compiler: convert go_write_export_data to Backend method. Convert the helper function 'go_write_export_data' into a Backend class method, to allow for an implementation of this function that needs to access backend state. Reviewed-on: https://go-review.googlesource.com/36357 commit e387439bfd24d5e142874b8e68e7039f74c744d7 Author: Than McIntosh <thanm@google.com> Date: Wed Feb 8 11:13:46 2017 -0500 compiler: insert backend conversion in temporary statement init Insert an additional type conversion in Temporary_statement::do_get_backend when assigning a Bexpression initializer to the temporary variable, to avoid potential clashes in the back end. This can come up when assigning something of concrete pointer-to-function type to a variable of generic pointer-to-function type. Reviewed-on: https://go-review.googlesource.com/36591 commit c5acf0ce09e61ff623847a35a99da465b8571609 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 1 17:57:53 2017 +0100 libgo: build tags for aix Build tags for the libgo source files required to build libgo on AIX. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37633 commit 67ed19616898ea18a101ec9325b82d028cd395d9 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 2 15:41:31 2017 +0100 libgo: handle AIX tag in match.sh and gotest Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37638 commit 83ea2d694c10b2dd83fc8620c43da13d20db754e Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 1 17:48:16 2017 +0100 libgo: add AIX support in configure and Makefile - support for GOOS=aix - CFLAGS/GOCFLAGS/LDFLAGS for AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37632 commit 35d577fe22ffa16a3ccaadf5dae9f6f425c8ec8c Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Mon Mar 6 15:00:15 2017 +0100 runtime: adapt memory management to AIX mmap On AIX: * mmap does not allow to map an already mapped range, * mmap range start at 0x30000000 for 32 bits processes, * mmap range start at 0x70000000_00000000 for 64 bits processes Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37845 commit 4e49e56a5fd4072b4ca7fcefe4158d6885d9ee62 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Mon Mar 6 13:42:26 2017 +0100 runtime: add getproccount implementation for AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37844 commit ff626470294237ac664127894826614edc46a3d0 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Mon Mar 6 17:31:21 2017 +0100 runtime: handle ERESTART errno with AIX's wait4 On AIX, wait4 may return with errno set to ERESTART, which causes unexepected behavior (for instance, go build may exit with the message "wait: restart system call" after running a command, even if it was successfull). Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37846 commit 37daabbfc83d533b826ef9ab10e2dee7406e7198 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Mon Mar 6 11:02:58 2017 +0100 runtime: support for AIX's procfs tree On AIX, the process executable file is available under /proc/<pid>/object/a.out Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37842 commit a0275c039d56acf4bf48151978c1a4ec5758cc2c Author: Ian Lance Taylor <iant@golang.org> Date: Wed Mar 8 07:00:05 2017 -0800 libgo/Makefile.am: don't use nonportable \n or \t in sed expression The resulting zstdpktlist.go is less pretty, but it works. Reviewed-on: https://go-review.googlesource.com/37940 commit 29b190f76105aafa2b50b48249afdafecc97a4be Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 9 16:02:34 2017 +0100 runtime: netpoll and semaphores for AIX semaphore implementation based on Solaris implementation in libgo/go/runtime/os_solaris.go netpoll is just a stub to avoid build failure on AIX. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37966 commit 55ca6d3f3cddf0ff9ccb074b2694da9fc54de7ec Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 9 15:38:30 2017 +0100 libmain: ensure initfn is called when loading a go library AIX does not support .init_array. The alterative is to export the __go_init function and tell the linker it is an init function with the -Wl,-binitfini:__go_init option. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37965 commit 349a30d17d880ac8bc1a35e1a2ffee6d6e870ae9 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Mar 10 11:15:08 2017 +0100 libgo: use an import list for missing symbols libgo depends on symbols provided by Go programs at runtime. On AIX, this requires either to build libgo with -Wl,-berok linker option and the programs with -Wl,-brtl, or to provide a list of imported symbols when building libgo. The second options seems preferable, to avoid requiring an additional option for every Go program. There are also some symbols that are specific to GNU ld and do not exist when linking with AIX ld (__data_start, __edata, __etext and __bss_start). Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37969 commit 91db0ea1ff068ca1d97b9c99612100ea5b96ddb2 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 8 15:34:45 2017 +0100 crypto/x509: add certificate files locations for AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/37952 commit 92e521c854e91709b949548c47e267377850f26a Author: Ian Lance Taylor <iant@golang.org> Date: Fri Mar 10 14:10:11 2017 -0800 compiler: fix check for pointer in Temporary_reference_expression The check for an unrepresentable pointer in Temporary_reference_expression::do_get_backend was incorrectly translated from C to Go in https://golang.org/cl/14346043. Fix the check to use points_to rather than has_pointer and deref. This should not make any difference in practice as either way the condition will only be true for a pointer to void, but points_to is correct and more efficient. Reviewed-on: https://go-review.googlesource.com/38009 commit 9a0b676e59e7171a630c48fdc3d4de6712bad0ca Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 16 16:51:53 2017 +0100 libgo: add missing _arpcom struct to *sysinfo.go This struct is filtered due to having a field of type _in6_addr, but other types exported to *sysinfo.go are depending on it. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38251 commit 61262a757bdd3d9a595ab6a90f68c0c4ebed7bc1 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 16 18:27:46 2017 +0100 syscall: raw_ptrace stub for AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38253 commit 8029632b50880fd9b5e39299c738b38e3386595f Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 15 16:58:37 2017 +0100 libgo: adapt runtime.inc to AIX * Two AIX types are wrongfully exported to runtime.inc as their names make them look like a Go type. * The sigset go type conflicts with a system sigset type. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38192 commit 25f3a90d14bc268479369ecc0eada72791612f86 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 15 16:58:37 2017 +0100 libgo: update Makefile.in, accidentally omitted from last change Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38310 commit d52b4895616b66f93b460366527e74336829aaa5 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 16 18:39:26 2017 +0100 syscall: TIOCSCTTY does not exist on AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38254 commit ff1ec3847a4472008e5d53a98b6694b1e54ca322 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 16 18:07:34 2017 +0100 syscall: syscall does not exist on AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38252 commit c1ee60dabf0b243a0b0286215481a5d326c34596 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Mar 17 17:18:18 2017 +0100 net: EAI_OVERFLOW does not exist on AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38266 commit ad4ad29aed9f70b14b39b488bfeb9ee745382ec4 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Mar 17 17:23:56 2017 +0100 net: sockopt/sockoptip stubs for AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38267 commit 5d7db2d7542fe7082f426d42f8c2ce14aad6df55 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Mar 17 16:35:05 2017 +0100 os/user: add listgroups stub for AIX This is required to build os/user. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38263 commit 4e57a7973e9fa4cb5ab977c6d792e62a8f7c5795 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 22 11:11:30 2017 +0100 os: fix readdirnames for AIX Largefile implementation should be used on AIX. readdir64_r function returns 9 and sets result to NULL when reaching end of directory, so this return code should not always be considered as an error. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38359 commit b34036967d1ec57b25e3debe077439b4210a1d4a Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Mar 17 17:39:31 2017 +0100 libgo: adapt sigtab.go to AIX On AIX, _NSIG is not directly defined to its integer value in gen-sysinfo.go. The real value is _SIGMAX32+1 or _SIGMAX64+1, depending if we are building a 32bit ligbo or a 64bit libgo, so we need to read one of those constants to set nsig value in mksigtab.sh This change also ensures that all signal numbers from 0 to nsig-1 are referenced in sigtable. Reviewed-on: https://go-review.googlesource.com/38268 commit 20991c32671a183ec859b4f285df37fdd4634247 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 23 17:28:09 2017 +0100 syscall: missing import in socket_bsd.go Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38369 commit c34754bd9adf5496c4c26257eaa50793553c11e8 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 22 17:57:01 2017 +0100 sycall: WCOREDUMP macro is not defined on AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38363 commit 4f38813482227b12ea0ac6ac1b981ff9ef9853ef Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 23 17:44:43 2017 +0100 libgo: additional build tags for AIX Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38510 commit d117ede6ff5a7083e9c40eba28a0f94f3535d773 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 23 17:48:46 2017 +0100 go/build: add AIX to "go build" command known OS Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38511 commit 7b0ddaa6a6a71f9eb1c374122d29775b13c2cac5 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Mar 23 09:57:01 2017 -0700 compiler: don't crash if imported package imports this one When building a test it's OK if test code imports a package that imports this one. The go tool is supposed to catch cases where this creates an impossible initialization order. The compiler already has code to permit this in Gogo::add_import_init_fn. This CL avoids a compiler crash on a similar case when writing out the export data. I have no test case for this. Basically it pushes a compiler crash into an error reported elsewhere. Problem was reported by Tony Reix. Reviewed-on: https://go-review.googlesource.com/38462 commit 925636975d075e3e3353823b09db3f933f23cb03 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Mar 29 14:14:18 2017 -0700 runtime: copy finalizer support from Go 1.8 runtime Reviewed-on: https://go-review.googlesource.com/38794 commit 1ccb22b96cb3b1011db0e427877d9ddecb577fa9 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Mar 30 15:21:06 2017 +0200 runtime: initcontext and setcontext stubs for AIX Further investigations are required to understand the clobbering issue and implement a proper fix. Until then, those stubs are required to allow the build to complete. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38930 commit 27db481f369b54256063c72b911d22390c59199c Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 29 18:07:25 2017 +0200 os: fix Readlink failure on AIX AIX readlink routine returns an error if the link is longer than the buffer, instead of truncating the link. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38700 commit c93babbf48eddd0bc34d4179ffb302dc60087299 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 29 17:26:35 2017 +0200 compiler: implement support for reading AIX big archives This is required to read go export from a Go library. Code courtesy of Damien Bergamini from Atos Infogérance. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38698 commit 930dd53482bdee3a9074850d168d0b9d7819c135 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 6 18:50:11 2017 -0700 compiler: fix whether conversions are static initializers The compiler was incorrectly treating type conversions from string to int or vice-versa as static initializers. That doesn't work, as those conversions are implemented via a function call. This case may never actually arise but it seems like the right thing to do. Reviewed-on: https://go-review.googlesource.com/39872 commit f02691e4195728dbf06f4dde0853c6bccc922183 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 6 17:24:08 2017 -0700 compiler, runtime: don't let slices point past end of memory block When Go code uses a slice expression like [:len(str)] or [:cap(slice)], it's natural for the resulting pointer to point just past the end of the memory block. If the next memory block is not live, we now have a live pointer to a dead block, which will unnecessarily keep the block alive. That wastes space, and with the new Go 1.8 GC (not yet committed) will trigger an error when using GODEBUG=gccheckmark=1. This changes the implementation of slice expressions to not move the pointer if the resulting string length or slice capacity is 0. When the length/capacity is zero, the pointer is never used anyhow. Reviewed-on: https://go-review.googlesource.com/39870 commit 17527c35b027e1afcc318faf5563909e1e9d44a6 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 6 15:30:11 2017 -0700 compiler: emit write barriers The Go 1.8 concurrent GC requires optional write barriers for all assignments that may change pointer values in the heap or in a global variable. For details see https://blog.golang.org/go15gc. This changes the gofrontend code to emit write barriers as needed. This is in preparation for future changes. At the moment the write barriers will do nothing. They test runtime.writeBarrier.enabled, which will never be non-zero. They call simple functions which just do a move without doing any of the other operations required by the write barrier. Reviewed-on: https://go-review.googlesource.com/39852 commit c0b00f072bf34b2c288e1271ec8118b88c4f6f6f Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Tue Apr 11 17:47:29 2017 +0200 libgo: allow building gox files from PIC objects libtool builds non-PIC objects in the same directory as .lo files and PIC objects in a .libs subdirectory. BUILDGOX rule uses the non-PIC objects to build the gox files, but on AIX only the PIC objects are built. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/40355 commit ea0f3da174c5503a209043f14ddda34871cfec52 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 6 19:06:14 2017 -0700 compiler: add code to generate a ptrmask for a type The Go 1.8 garbage collector uses a ptrmask for all types below a certain size. A ptrmask is simply a bit vector with a single bit for each pointer-sized word in the value. The bit is 1 if the type has a pointer in that position, 0 if it does not. This change adds code to the compiler to generate a ptrmask. The code is not used by anything yet, it is just compiled. It will be used when we switch over to the Go 1.8 garbage collector. The new Array_type::int_length method, and the new memory_size methods, will also be used by other patches coming later. Reviewed-on: https://go-review.googlesource.com/39873 commit 3029e1df3be3614d196a03c15e50e68ff850aa4c Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 7 10:31:39 2017 -0700 compiler: add code to generate a gcprog for a type The Go 1.8 garbage collector uses a gcprog for all types above a certain size. A gcprog describes where the pointers are in the type, using a simple bytecode machine that supports repeating bits. The effect is to permit using much less space to describe arrays. The format is described in runtime/mbitmap.go in the docs for runGCProg. This is not yet added to the gofrontend, but can be seen in the gc sources. This change adds code to the compiler to generate a gcprog. The code is not used by anything yet, it is just compiled. It will be used when we switch over to the Go 1.8 garbage collector. Reviewed-on: https://go-review.googlesource.com/39923 commit 8b01ef1e9176d20f4c9e667972fe031069a4d057 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 13 07:00:35 2017 -0700 compiler: add ptrdata computations and expressions For the upcoming Go 1.8 GC we need to compute the "ptrdata" of a type: the number of bytes in the type that can contain pointers. For types that do not contain pointers this number is zero. For many types it is a number larger than zero but smaller than the total size of the type. The Go 1.8 GC uses this number to make loops looking for pointers run faster by not scanning the suffix of a value that can not contain a pointer. Unfortunately there are two subtly different definitions of ptrdata, and we need both. The first is the simple one: the prefix that can contain pointers. The second is the number of bytes described by the gcprog for the type. Recall that we describe the exact position of pointers in a type using either a ptrmask or a gcprog. The ptrmask is simpler, the gcprog uses less space. We use the gcprog for large types, currently defined as types that are more than 2048 bytes. When the Go 1.8 runtime expands a gcprog, it verifies that the gcprog describes exactly the same number of bytes as the ptrdata field in the type descriptor. If the last pointer-containing portion of a type is an array, and if the elements of the array have a ptrdata that is less than the size of the element type, then the simple definition of the ptrdata will not include the final non-pointer-containing bytes of the last element of the array. However, the gcprog will define the array using a repeat count, and will therefore include the full size of the last element of the array. So for a type that needs a gcprog, the ptrdata field in the type descriptor must be the size of the data described by the gcprog, and that is not necessarily the same as the simple ptrdata. It might seem that we can always use the gcprog version of the ptrdata calculation, since that is what will appear in a type descriptor, but it turns out that for global variables we always use a ptrmask, not a gcprog, even if the global variable is large. This is because gcprogs are handled by expanding them into a ptrmask at runtime, and for a global variable there is no natural place to put the ptrmask. Simpler to always use the ptrmask. That means that we need to describe the size of the ptrmask, and that means that we need an expression for the simple form of the ptrdata. This CL implements the ptrdata calculation. This code is not actually used yet. It will be used later when the Go 1.8 GC is committed. Reviewed-on: https://go-review.googlesource.com/40573 commit 7a37331303b572412179a08141f1dd35339d40c8 Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 06:55:48 2017 -0700 compiler: zero length arrays never contain pointers Reviewed-on: https://go-review.googlesource.com/40696 commit c242f0508a64d3d74a28d498cbaeda785ff76258 Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 07:26:54 2017 -0700 bytes: disable allocations test on gccgo It turns out that testing.AllocsPerRun has not been producing correct results with the current gccgo memory allocator. When we update to the Go 1.8 memory allocator, testing.AllocsPerRun will work again, and this test will fail due to lack of escape analysis. Reviewed-on: https://go-review.googlesource.com/40700 commit 0dc369f1d63376a36bfb0999a1b0377fd444bfab Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Tue Apr 11 16:22:38 2017 +0200 os: alternative way to find executable path, using Args[0] AIX does not provide a proper way to find the original executable path from procfs, which contains just an hardlink. Executable path can be found using Args[0], Getcwd and $PATH. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/40353 commit f9bad1342569b338e3b2ea9f12ffc6d3d3fa3028 Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 08:01:19 2017 -0700 compiler: don't write struct with multiple sink fields to C header file When writing a struct to the C header file used by the C runtime code, a single sink field is fine: it will be called "_", which is valid C. There are structs with single sink fields that we want to write out, such as finblock. As it happens, though, the Go 1.8 runtime has a struct with two sink fields, gcControllerState, which will produce a C definition with two fields named "_", which will fail. Since we don't need to know that struct in C, rather than fix the general case, just punt if the struct has multiple sink fields. After the conversion to the Go 1.8 GC, we may be able to get rid of the C header file anyhow. I'm not sure yet. Reviewed-on: https://go-review.googlesource.com/40701 commit cfc28901a572aeb15b2f10a38f79eec04c64dfb2 Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 10:07:23 2017 -0700 runtime: disable allocations test on gccgo It turns out that testing.AllocsPerRun has not been producing correct results with the current gccgo memory allocator. When we update to the Go 1.8 memory allocator, testing.AllocsPerRun will work again, and these tests will fail due to lack of escape analysis. Reviewed-on: https://go-review.googlesource.com/40703 commit 36fedd76edaa48b9ec09709a70d9e4abaddf0caf Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 10:47:06 2017 -0700 runtime: remove unused size argument from hash/equal fns The size argument was removed from hash and equal functions in CL 34983. Somehow I missed removing them from three of the predefined functions. Reviewed-on: https://go-review.googlesource.com/40770 commit 90f6accb48d2e78cad8955b9292933f6ce3fe4c8 Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 13:23:05 2017 -0700 runtime: remove unused stack.go We're never going to use stack.go for gccgo. Although a build tag keeps it from being built, even having it around can be confusing. Remove it. Reviewed-on: https://go-review.googlesource.com/40774 commit befa71603fc66a214e01ac219f2bba36e19f136f Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 13:18:34 2017 -0700 runtime: build fastlog Take out the build tags which were preventing fastlog2 from being built. It's used by the upcoming Go 1.8 GC. Reviewed-on: https://go-review.googlesource.com/40773 commit b7e19e9be4ab4c3cd8f4c9506d79a8cd56bace40 Author: Ian Lance Taylor <iant@golang.org> Date: Fri Apr 14 10:04:23 2017 -0700 runtime: add tests from Go 1.8 Some runtime package tests never made it into the gofrontend repo for some reason. Add them now. Reviewed-on: https://go-review.googlesource.com/40869 commit 1feef185aebd71bc2a09b9a04287461806096610 Author: Ian Lance Taylor <iant@golang.org> Date: Mon Apr 17 16:26:11 2017 -0700 runtime: change mcall to take a Go function value For future work in bringing in the Go 1.8 GC, change the mcall function to take a Go function value, which means that mcall can take a closure rather than just a straight C function pointer. As part of this change move kickoff from C to Go, which we want to do anyhow so that we run the write barriers that it generates. Reviewed-on: https://go-review.googlesource.com/40935 commit c3db34f4efc2d610f74a01dd2ad7775f48889b29 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Tue Apr 11 16:11:26 2017 +0200 runtime: netpoll implementation for AIX Code courtesy of Damien Bergamini from Atos Infogérance. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/40352 commit f5634dff40e53ad9ce61afd67fd07334e3af9d1f Author: Ian Lance Taylor <iant@golang.org> Date: Tue Apr 18 22:06:07 2017 -0700 runtime: move mstart from Go to C The assignments done in mstart must be done without write barriers, as mstart is running without an m or p. In the gc toolchain the equivalent code to intialize g and g->m is written in assembler; on GNU/Linux, it's in the clone function. Reviewed-on: https://go-review.googlesource.com/40989 commit 671d7c74592f4b6fe3665af279482ba0ea47ca2d Author: Ian Lance Taylor <iant@golang.org> Date: Tue Apr 18 17:47:28 2017 -0700 compiler: varargs slices do not escape in runtime Also, don't try to allocate an empty slice on the stack, as it will confuse the GCC backend. Also add a few trivial style, code formatting, and debug output fixes. Updates golang/go#17431 Reviewed-on: https://go-review.googlesource.com/40983 commit 94699d25f31353bf03419eda56b15993a39f3275 Author: Ian Lance Taylor <iant@golang.org> Date: Tue Apr 18 17:30:09 2017 -0700 compiler: add Ptrmask_symbol_expression Add an expression to evaluate to the ptrmask for a type. This will be used for global variables, which always use a ptrmask no matter how large they are. Reviewed-on: https://go-review.googlesource.com/40981 commit bfff1654eac5b9288fa6c431e66cba8c9da6a660 Author: Ian Lance Taylor <iant@golang.org> Date: Mon Apr 17 10:51:16 2017 -0700 runtime: change g's in systemstack The systemstack function in the gc toolchain changes to a different g. This is often used to get more stack space; the gofrontend uses a different stack growth mechanism that does not require changing g's, so we've been running with a version of systemstack that keeps the same g. However, the garbage collector has various tests to verify that it is running on g0 rather than on a normal g. For simplicity, change the gofrontend version of systemstack to change to a different g just as the gc toolchain does. This permits us to uncomment some sanity checks in notetsleep. Doing that requires us to fix up a couple of places where C code calls {start,stop}TheWorldWithSema while not on g0. Note that this does slow down some code in the runtime package unnecessarily. It may be useful to find some places where the runtime calls systemstack only to get more stack space and change it to use some other function. That other function would act like systemstack in the gc toolchain but simply call the argument in the gofrontend. Reviewed-on: https://go-review.googlesource.com/40973 commit b2ccc7601ce71a7c5732154cf9b2eeea64681469 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 10:36:12 2017 -0700 compiler, runtime: include ptrmask in GC roots Change the list of registered GC roots to include a ptrmask, and change the data structures to be easily used from Go code. The new ptrmask will be used by the Go 1.8 GC to only scan pointers. Tweak the current GC to use the new structures, but ignore the new ptrmask information for now. The new GC root data includes the size of the variable. The size is not currently used, but will be used later by the cgo checking code. Reviewed-on: https://go-review.googlesource.com/41075 commit 9e065149970bc180e4ca83bb99c74d9c4f43b47b Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 12:23:16 2017 -0700 compiler, runtime: don't pass size to __go_new There is no reason to pass the size to __go_new, as the type descriptor includes the size anyhow. This makes the function correspond to the Go 1.8 function runtime.newobject, which is what we will use when we update to the Go 1.8 memory allocator. Reviewed-on: https://go-review.googlesource.com/41080 commit c321de7b738c4a3387c1842919c9305acfa04c57 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 13:13:56 2017 -0700 compiler, runtime, reflect: make type descriptors more like Go 1.8 Change the type descriptor structure to be more like the one in the Go 1.8 runtime. Specifically we add the ptrdata field, rename the gc field to gcdata and change the type to *byte, and rearrange a few of the fields. The structure is still not identical to the Go 1.8 structure--we don't use any of the tricks to reduce overall executable size--but it is more similar. For now we don't use the new ptrdata field, and the gcdata field is still the old format rather than the new Go 1.8 ptrmask/gcprog format. Reviewed-on: https://go-review.googlesource.com/41081 commit 7b70c52cddeebea9ebeac003f8c6aad59497e5f0 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 14:54:29 2017 -0700 reflect: make sure to clear unusable hash/equal function Otherwise we wind up copying the one from the prototype, which is wrong. Also rewrite the hash/equal functions to look like the ones in Go 1.8, mainly a matter of changing names and using arrayAt. Reviewed-on: https://go-review.googlesource.com/41133 commit 84d26f467f7de8bdbb0d230458135fe1b6b2a99d Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 14:59:13 2017 -0700 runtime: remove duplicate declarations of SetFinalizer/KeepAlive These should have been removed in CL 38794. It's a bug that the compiler even permits these duplicate declarations. Reviewed-on: https://go-review.googlesource.com/41134 commit f85ff7e64c24031f6d0bd7c9c426b6176cb95160 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 15:56:32 2017 -0700 runtime: don't crash if panicstring called with no m It's possible for runtime_panicstring to be called with no m if a signal handler, or scheduler innards, do something wrong. If that happens carry on with the panic rather than crashing. Reviewed-on: https://go-review.googlesource.com/41137 commit 5b362b04f642afb8b20715930416fc3b7d91bb12 Author: Than McIntosh <thanm@google.com> Date: Fri Mar 31 14:35:48 2017 -0400 compiler: fix for expr sharing introduced by Order_eval::statement. When processing an expression statement with a top-level call that returns multiple results, Order_eval::statement can wind up creating a tree that has multiple references to the same call, which results in a confusing AST dump. Change the implementation to avoid introducing this unwanted sharing. Reviewed-on: https://go-review.googlesource.com/39210 commit b05b4260a68695bf9c9cc29e14ae86ca2699458a Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 16:00:28 2017 -0700 runtime: restore correct m in gtraceback If gtraceback is used to get a stack trace of a g running in the same m, as can happen if we collect a stack trace from a g0, then restore the old m value, don't clear it. Reviewed-on: https://go-review.googlesource.com/41138 commit ca8bbf4dfac19b3f4f7ce21a688b96a418c75031 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 16:03:24 2017 -0700 runtime: set startpc field when starting a new goroutine This puts the right value in a trace--previously it was always zero. Reviewed-on: https://go-review.googlesource.com/41139 commit ca8bbf4dfac19b3f4f7ce21a688b96a418c75031 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 16:03:24 2017 -0700 runtime: set startpc field when starting a new goroutine This puts the right value in a trace--previously it was always zero. Reviewed-on: https://go-review.googlesource.com/41139 commit 887690dce42d7bf8f711f8ea082e4928fb70f2a5 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 17:06:11 2017 -0700 runtime: add prefetch functions The Go 1.8 GC uses prefetch functions. Add versions for gccgo that call __builtin_prefetch. Uncomment the test for them in testAtomic64. Don't force the check function to return early, as now taking the address of a local variable in the runtime package does not force it onto the heap. Reviewed-on: https://go-review.googlesource.com/41144 commit 4269db69f9184e5a45c54aaee7352425a1f88bff Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 17:55:21 2017 -0700 runtime: split up ticks to get correct alignment On 32-bit x86 a uint64 variable by itself is aligned to an 8-byte boundary. A uint64 field in a struct is aligned to a 4-byte boundary. The runtime.ticks variable has a uint64 field that must be aligned to an 8-byte boundary. Rather than rely on luck, split up the struct into separate vars so that the required alignment happens reliably. It would be much nicer if issue golang/go#19057 were fixed somehow, but that is for another day. Reviewed-on: https://go-review.googlesource.com/41143 commit 66926cabdbdbf3431b4f172f7756e195c1c6c513 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Apr 20 17:15:38 2017 +0200 libgo: fix bad value for O_CLOEXEC on AIX 7.1 On AIX 7.1, O_CLOEXEC is defined as 0x0000001000000000, which creates an integer constant overflow error when building libgo. This affects only 7.1, O_CLOEXEC is not defined on 6.1 (and defaults to O in sysinfo.go) and is defined as 0x00800000 on AIX 7.2. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/41214 commit af288ff10aeafc47651f5def327ed56425d5be19 Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 20 17:15:02 2017 -0700 runtime: preserve stack context in tracebackothers The tracebackothers function works by saving the current stack context in the goroutine's context field and then calling gogo to switch to a new goroutine. The new goroutine will collect its own stack trace and then call gogo to switch back to the original goroutine. This works fine, but if the original goroutine was called by mcall then the contents of its context field are needed to return from the mcall. Fix this by saving the stack context across the calls to the other goroutines. Reviewed-on: https://go-review.googlesource.com/41293 commit 43101e5956e793f1b4de05c15d7738c785e927df Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Apr 21 10:58:52 2017 +0200 os/user: use _posix_* libc functions libc getpwnam_r function has a different signature, we must use _posix_getpwnam_r instead (by default, the pwd.h system include file defines getpwnam_r as a static function calling _posix_getpwnam_r, so a C program calling getpwnam_r will indeed reference the _posix_getpwnam_r symbol). Idem for getpwuid_r, getgrnam_r and getgrgid_r. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/41334 commit 71e1fec4d2a536591ea6657a06916a17b5127071 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Apr 19 21:24:48 2017 -0700 runtime: don't use pointers in g_ucontext_t or stackcontext The g_ucontext_t type holds registers saved for a goroutine. We have to scan it for pointers, but since registers don't necessarily hold pointers we have to scan it conservatively. That means that it should not have a pointer type, since the GC will always scan pointers. Instead it needs special treatment to be scanned conservatively. The current GC doesn't care when a pointer type holds a non-pointer, but the Go 1.8 GC does. For the current GC this means we have to explicitly scan the g_ucontext_t values in a G. While we're at it change stackcontext to be uintptr too. The entries in stackcontext never hold pointers that the Go GC cares about. Reviewed-on: https://go-review.googlesource.com/41270 commit eab2960aee91d3e3a6baa5b1bce01262d24c714f Author: Ian Lance Taylor <iant@golang.org> Date: Thu Apr 20 17:08:19 2017 -0700 runtime/internal/sys: define Goexperiment The gc toolchain defines Goexperiment based on the environment variable GOEXPERIMENT when the toolchain is built. We just always set Goexperiment to the empty string. Reviewed-on: https://go-review.googlesource.com/41292 commit be4a751943265c0637da859d15a4faf162f5c478 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Thu Apr 20 14:04:35 2017 +0200 net: sockopt implementation for AIX This is a copy of the Linux implementation, it allows to run some simple client/server applications on AIX, while the current sockopt stubs don't. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/41213 commit 46a669c4ca5b80fd6f6a0a42095804d9f704611d Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Mar 29 17:55:06 2017 +0200 math: fix sign for atan/expm1/log1p(-0) AIX libc returns +0 for atan(-0), expm1(-0) and log1p(-0), while matching Go functions must return -0. Code courtesy of Tony Reix. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/38699 commit 53b0e809130038a46f0a3d2870e3905f44ab888d Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Apr 26 17:29:22 2017 +0200 runtime: fix context clobbering on AIX On AIX 64-bits, r13 is a pointer to thread data. setcontext() overwrites r13 with the value saved by getcontext(). So, when a goroutine is scheduled on a new thread, r13 will point to the old thread data after calling setcontext(). Code courtesy of Damien Bergamini. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/41854 commit f8d5ebd71c71e6e777200530d8204b92619157f8 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Wed Apr 26 18:01:19 2017 +0200 runtime: fix wrong time calculation in semasleep tv_nsec is added twice when calculating the sleep end time. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/41855 commit ef56097f4ea848d48fbf61eba1c757fe7fce99d3 Author: Matthieu Sarter <matthieu.sarter.external@atos.net> Date: Fri Apr 28 10:27:32 2017 +0200 libgo: pass $(NM) value when running benchmarks On AIX, we need to use "nm -B" instead of "nm", to have the epxected output format, so the configured $(NM) value from the Makefile should be exported before running gotest, which defaults to "nm" if $NM is not set. Issue golang/go#19200 Reviewed-on: https://go-review.googlesource.com/42051 commit 0fb550083ae474fb964435927b899ec8e4b62771 Author: Ian Lance Taylor <iant@golang.org> Date: Wed Nov 16 21:12:53 2016 -0800 runtime: copy garbage collector from Go 1.8 runtime This giant patch replaces the old Go 1.4 memory allocator and garbage collector with the new Go 1.8 code. The memory allocator is fairly similar, though now written in Go rather than C. The garbage collector is completely different. It now uses ptrmask and gcprog information, which requires changes in the compiler and the reflect package as well as the runtime. And, of course, the garbage collector now runs concurrently with program execution. In the gc toolchain the garbage collector is strict and precise at all levels. In the gofrontend we do not have stack maps, so stacks, and register values, are collected conservatively. That means that an old, no longer used, pointer on a stack or in a register can cause a memory object to live longer than it should. That in turns means that we must disable some checks for invalid pointers in the garbage collection code. Not only can we get an invalid pointer on the stack; the concurrent nature of the collector means that we can in effect resurrect a block that was already unmarked but that the collector had not yet gotten around to freeing, and that block can in turn point to other blocks that the collector had managed to already free. So we must disable pointer checks in general. In effect we are relying on the fact that the strict pointer checks in the gc toolchain ensure that the garbage collector is correct, and we just assume that it is correct for the gofrontend since we are using the same code. Reviewed-on: https://go-review.googlesource.com/41307 commit a95078d501175240d095500a8c5fbfb21bec65cb Author: Ian Lance Taylor <iant@golang.org> Date: Mon Apr 24 16:33:47 2017 -0700 libgo/Makefile: clean more files Fix up the mostlyclean, clean, and distclean targets to better follow https://www.gnu.org/prep/standards/html_node/Standard-Targets.html. Reviewed-on: https://go-review.googlesource.com/41625 commit 5956bf1055451cf4239cdfeca259c23b1ded54d8 Author: Ian Lance Taylor <iant@golang.org> Date: Mon May 8 13:35:11 2017 -0700 libgo: delete goc2c The last .goc file has been removed, so remove goc2c. The goc2c program was my first contribution to the gc repository that was more than 100 lines: https://github.com/golang/go/commit/2b57a1124e87b0dc8bc1ff6899297b4d7d6e74f2 The program was used in gc for a few years under various guises but was finally removed in https://golang.org/cl/132680043. Now we can remove it from gofrontend as well. Reviewed-on: https://go-review.googlesource.com/42911 commit a222e35d041de0cd42506b61c93b8209e07702b9 Author: Than McIntosh <thanm@google.com> Date: Tue May 9 10:33:10 2017 -0400 compiler: set "need_init_fn" when adding gc root Variables that back slice initializers in certain cases have to be added to the gc roots list, since they can be modified at runtime. The code that was doing this addition did not update the flag that tracks whether the package being compiled needs an initializer function, which resulted in the call in question being left out of the final generated code in certain cases. Fix is to change Gogo::add_gc_root() to update the "needs init" flag. Reviewed-on: https://go-review.googlesource.com/43030 commit 822ab419bf7d1c705cdce1c12133e7a11f56be2e Author: Than McIntosh <thanm@google.com> Date: Tue May 9 11:36:51 2017 -0400 compiler: fix variable context nit in write barrier generation Update the write barrier generation code to insure that the "lvalue context" tag on the space var expression is set only in the case where the expr feeds directly into an assignment. This is somewhat counter-intuitive, but needed in the case where the backend looks at context tags. Reviewed-on: https://go-review.googlesource.com/43031 From-SVN: r247848
2017-05-11 01:26:09 +08:00
# If nothing else defined TIOCSCTTY, make sure it has a value.
if ! grep "const TIOCSCTTY " ${OUT} >/dev/null 2>&1; then
echo "const TIOCSCTTY = 0" >> ${OUT}
fi
# The nlmsghdr struct.
grep '^type _nlmsghdr ' gen-sysinfo.go | \
sed -e 's/_nlmsghdr/NlMsghdr/' \
-e 's/nlmsg_len/Len/' \
-e 's/nlmsg_type/Type/' \
-e 's/nlmsg_flags/Flags/' \
-e 's/nlmsg_seq/Seq/' \
-e 's/nlmsg_pid/Pid/' \
>> ${OUT}
# The nlmsg flags and operators.
grep '^const _NLM' gen-sysinfo.go | \
sed -e 's/^\(const \)_\(NLM[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
# NLMSG_HDRLEN is defined as an expression using sizeof.
if ! grep '^const NLMSG_HDRLEN' ${OUT} > /dev/null 2>&1; then
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
# The rtmsg struct.
grep '^type _rtmsg ' gen-sysinfo.go | \
sed -e 's/_rtmsg/RtMsg/' \
-e 's/rtm_family/Family/' \
-e 's/rtm_dst_len/Dst_len/' \
-e 's/rtm_src_len/Src_len/' \
-e 's/rtm_tos/Tos/' \
-e 's/rtm_table/Table/' \
-e 's/rtm_protocol/Protocol/' \
-e 's/rtm_scope/Scope/' \
-e 's/rtm_type/Type/' \
-e 's/rtm_flags/Flags/' \
>> ${OUT}
# The rtgenmsg struct.
grep '^type _rtgenmsg ' gen-sysinfo.go | \
sed -e 's/_rtgenmsg/RtGenmsg/' \
-e 's/rtgen_family/Family/' \
>> ${OUT}
# The rt_msghdr struct.
grep '^type _rt_msghdr ' gen-sysinfo.go | \
sed -e 's/_rt_msghdr/RtMsghdr/g' \
-e 's/rtm_msglen/Msglen/' \
-e 's/rtm_version/Version/' \
-e 's/rtm_type/Type/' \
-e 's/rtm_index/Index/' \
-e 's/rtm_flags/Flags/' \
-e 's/rtm_addrs/Addrs/' \
-e 's/rtm_pid/Pid/' \
-e 's/rtm_seq/Seq/' \
-e 's/rtm_errno/Errno/' \
-e 's/rtm_use/Use/' \
-e 's/rtm_inits/Inits/' \
-e 's/rtm_rmx/Rmx/' \
-e 's/_rt_metrics/RtMetrics/' \
>> ${OUT}
# The rt_metrics struct.
grep '^type _rt_metrics ' gen-sysinfo.go | \
sed -e 's/_rt_metrics/RtMetrics/g' \
-e 's/rmx_locks/Locks/' \
-e 's/rmx_mtu/Mtu/' \
-e 's/rmx_hopcount/Hopcount/' \
-e 's/rmx_recvpipe/Recvpipe/' \
-e 's/rmx_sendpipe/Sendpipe/' \
-e 's/rmx_ssthresh/Ssthresh/' \
-e 's/rmx_rtt/Rtt/' \
-e 's/rmx_rttvar/Rttvar/' \
-e 's/rmx_expire/Expire/' \
-e 's/rmx_pksent/Pksent/' \
>> ${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 | \
sed -e 's/^\(const \)_\(RTF[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
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}
if test "${GOOS}" = "netbsd"; then
if ! grep "RTM_RESOLVE" ${OUT} >/dev/null 2>&1; then
# NetBSD 8.0 removed RTM_RESOLVE, but it is part of the syscall package's
# stable API, so add it manually.
echo "const RTM_RESOLVE = 0xb" >> ${OUT}
fi
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 | \
sed -e 's/_ifinfomsg/IfInfomsg/' \
-e 's/ifi_family/Family/' \
-e 's/ifi_type/Type/' \
-e 's/ifi_index/Index/' \
-e 's/ifi_flags/Flags/' \
-e 's/ifi_change/Change/' \
>> ${OUT}
# The if_msghdr struct. Upstream uses inconsistent capitalization for this type
# on AIX, so we do too.
ifmsghdr_name=IfMsghdr
if test "${GOOS}" = "aix"; then
ifmsghdr_name=IfMsgHdr
fi
grep '^type _if_msghdr ' gen-sysinfo.go | \
sed -e "s/_if_msghdr/${ifmsghdr_name}/" \
-e 's/ifm_msglen/Msglen/' \
-e 's/ifm_version/Version/' \
-e 's/ifm_type/Type/' \
-e 's/ifm_addrs/Addrs/' \
-e 's/ifm_flags/Flags/' \
-e 's/ifm_index/Index/' \
-e 's/ifm_addrlen/Addrlen/' \
>> ${OUT}
# The if_announcemsghdr struct.
grep '^type _if_announcemsghdr ' gen-sysinfo.go | \
sed -e 's/_if_announcemsghdr/IfAnnounceMsghdr/g' \
-e 's/ifan_msglen/Msglen/' \
-e 's/ifan_version/Version/' \
-e 's/ifan_type/Type/' \
-e 's/ifan_index/Index/' \
-e 's/ifan_name/Name/' \
-e 's/ifan_what/What/' \
>> ${OUT}
# The interface information types and flags.
grep '^const _IFA' gen-sysinfo.go | \
sed -e 's/^\(const \)_\(IFA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
grep '^const _IFLA' gen-sysinfo.go | \
sed -e 's/^\(const \)_\(IFLA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
grep '^const _IFF' gen-sysinfo.go | \
sed -e 's/^\(const \)_\(IFF[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
grep '^const _IFNAMSIZ' gen-sysinfo.go | \
sed -e 's/^\(const \)_\(IFNAMSIZ[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
grep '^const _SIOC' gen-sysinfo.go | \
grep -v '_val =' | \
sed -e 's/^\(const \)_\(SIOC[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
if ! grep '^const SIOCGIFMTU' ${OUT} >/dev/null 2>&1; then
if grep '^const _SIOCGIFMTU_val' ${OUT} >/dev/null 2>&1; then
echo 'const SIOCGIFMTU = _SIOCGIFMTU_val' >> ${OUT}
fi
fi
# The ifaddrmsg struct.
grep '^type _ifaddrmsg ' gen-sysinfo.go | \
sed -e 's/_ifaddrmsg/IfAddrmsg/' \
-e 's/ifa_family/Family/' \
-e 's/ifa_prefixlen/Prefixlen/' \
-e 's/ifa_flags/Flags/' \
-e 's/ifa_scope/Scope/' \
-e 's/ifa_index/Index/' \
>> ${OUT}
# The ifa_msghdr struct.
grep '^type _ifa_msghdr ' gen-sysinfo.go | \
sed -e 's/_ifa_msghdr/IfaMsghdr/g' \
-e 's/ifam_msglen/Msglen/' \
-e 's/ifam_version/Version/' \
-e 's/ifam_type/Type/' \
-e 's/ifam_addrs/Addrs/' \
-e 's/ifam_flags/Flags/' \
-e 's/ifam_metric/Metric/' \
-e 's/ifam_index/Index/' \
>> ${OUT}
# The rtattr struct.
grep '^type _rtattr ' gen-sysinfo.go | \
sed -e 's/_rtattr/RtAttr/' \
-e 's/rta_len/Len/' \
-e 's/rta_type/Type/' \
>> ${OUT}
# The bpf_version struct.
grep '^type _bpf_version ' gen-sysinfo.go | \
sed -e 's/_bpf_version/BpfVersion/g' \
-e 's/bv_major/Major/' \
-e 's/bv_minor/Minor/' \
>> ${OUT}
# The bpf_stat struct.
grep '^type _bpf_stat ' gen-sysinfo.go | \
sed -e 's/_bpf_stat/BpfStat/g' \
-e 's/bs_recv/Recv/' \
-e 's/bs_drop/Drop/' \
-e 's/bs_capt/Capt/' \
-e 's/bs_padding/Padding/' \
>> ${OUT}
# The bpf_insn struct.
grep '^type _bpf_insn ' gen-sysinfo.go | \
sed -e 's/_bpf_insn/BpfInsn/g' \
-e 's/code/Code/' \
-e 's/jt/Jt/' \
-e 's/jf/Jf/' \
-e 's/k/K/' \
>> ${OUT}
# The bpf_program struct.
grep '^type _bpf_program ' gen-sysinfo.go | \
sed -e 's/_bpf_program/BpfProgram/g' \
-e 's/bf_len/Len/' \
-e 's/bf_insns/Insns/' \
-e 's/_bpf_insn/BpfInsn/' \
>> ${OUT}
# The BPF ioctl constants.
grep '^const _BIOC' gen-sysinfo.go | \
grep -v '_val =' | \
sed -e 's/^\(const \)_\(BIOC[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
for c in BIOCFLUSH BIOCGBLEN BIOCGDLT BIOCGETIF BIOCGHDRCMPLT BIOCGRTIMEOUT \
BIOCGSTATS BIOCIMMEDIATE BIOCPROMISC BIOCSBLEN BIOCSDLT BIOCSETF \
BIOCSETIF BIOCSHDRCMPLT BIOCSRTIMEOUT BIOCVERSION
do
if ! grep "^const ${c}" ${OUT} >/dev/null 2>&1; then
if grep "^const _${c}_val" ${OUT} >/dev/null 2>&1; then
echo "const ${c} = _${c}_val" >> ${OUT}
fi
fi
done
# 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 | \
sed -e 's/_termios/Termios/' \
-e 's/c_iflag/Iflag/' \
-e 's/c_oflag/Oflag/' \
-e 's/c_cflag/Cflag/' \
-e 's/c_lflag/Lflag/' \
-e 's/c_line/Line/' \
-e 's/c_cc/Cc/' \
-e 's/c_ispeed/Ispeed/' \
-e 's/c_ospeed/Ospeed/' \
>> ${OUT}
# The termios constants.
for n in IGNBRK BRKINT IGNPAR PARMRK INPCK ISTRIP INLCR IGNCR ICRNL IUCLC \
IXON IXANY IXOFF IMAXBEL IUTF8 OPOST OLCUC ONLCR OCRNL ONOCR ONLRET \
OFILL OFDEL NLDLY NL0 NL1 CRDLY CR0 CR1 CR2 CR3 CS5 CS6 CS7 CS8 TABDLY \
BSDLY VTDLY FFDLY CBAUD CBAUDEX CSIZE CSTOPB CREAD PARENB PARODD HUPCL \
CLOCAL LOBLK CIBAUD CMSPAR CRTSCTS ISIG ICANON XCASE ECHO ECHOE ECHOK \
ECHONL ECHOCTL ECHOPRT ECHOKE DEFECHO FLUSHO NOFLSH TOSTOP PENDIN IEXTEN \
VINTR VQUIT VERASE VKILL VEOF VMIN VEOL VTIME VEOL2 VSWTCH VSTART VSTOP \
VSUSP VDSUSP VLNEXT VWERASE VREPRINT VDISCARD VSTATUS TCSANOW TCSADRAIN \
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 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}
# The fallocate flags.
grep '^const _FALLOC_' gen-sysinfo.go |
sed -e 's/^\(const \)_\(FALLOC_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
# The statfs struct.
# Prefer largefile variant if available.
# CentOS 5 does not have f_flags, so pull from f_spare.
statfs=`grep '^type _statfs64 ' gen-sysinfo.go || true`
if test "$statfs" = ""; then
statfs=`grep '^type _statfs ' gen-sysinfo.go || true`
fi
if ! echo "$statfs" | grep f_flags >/dev/null 2>&1; then
statfs=`echo "$statfs" | sed -e 's/f_spare \[4+1\]\([^ ;]*\)/f_flags \1; f_spare [3+1]\1/'`
fi
echo "$statfs" | sed -e 's/type _statfs64/type Statfs_t/' \
-e 's/type _statfs/type Statfs_t/' \
-e 's/f_type/Type/' \
-e 's/f_bsize/Bsize/' \
-e 's/f_blocks/Blocks/' \
-e 's/f_bfree/Bfree/' \
-e 's/f_bavail/Bavail/' \
-e 's/f_files/Files/' \
-e 's/f_ffree/Ffree/' \
-e 's/f_fsid/Fsid/' \
-e 's/f_namelen/Namelen/' \
-e 's/f_frsize/Frsize/' \
-e 's/f_flags/Flags/' \
-e 's/f_spare/Spare/' \
>> ${OUT}
# The timex struct.
timex=`grep '^type _timex ' gen-sysinfo.go || true`
if test "$timex" = ""; then
timex=`grep '^// type _timex ' gen-sysinfo.go || true`
if test "$timex" != ""; then
timex=`echo $timex | sed -e 's|// ||' -e 's/INVALID-bit-field/int32/g'`
fi
fi
if test "$timex" != ""; then
echo "$timex" | \
sed -e 's/_timex/Timex/' \
-e 's/modes/Modes/' \
-e 's/offset/Offset/' \
-e 's/freq/Freq/' \
-e 's/maxerror/Maxerror/' \
-e 's/esterror/Esterror/' \
-e 's/status/Status/' \
-e 's/constant/Constant/' \
-e 's/precision/Precision/' \
-e 's/tolerance/Tolerance/' \
-e 's/ time / Time /' \
-e 's/tick/Tick/' \
-e 's/ppsfreq/Ppsfreq/' \
-e 's/jitter/Jitter/' \
-e 's/shift/Shift/' \
-e 's/stabil/Stabil/' \
-e 's/jitcnt/Jitcnt/' \
-e 's/calcnt/Calcnt/' \
-e 's/errcnt/Errcnt/' \
-e 's/stbcnt/Stbcnt/' \
-e 's/tai/Tai/' \
-e 's/_timeval/Timeval/' \
>> ${OUT}
fi
# The rlimit struct.
# On systems that use syscall/libcall_posix_largefile.go, use rlimit64
# if it exists.
rlimit="_rlimit"
if test "${GOOS}" = "aix" || test "${GOOS}" = "linux" || (test "${GOOS}" = "solaris" && (test "${GOARCH}" = "386" || test "${GOARCH}" = "sparc")); then
if grep '^type _rlimit64 ' gen-sysinfo.go > /dev/null 2>&1; then
rlimit="_rlimit64"
fi
fi
grep "^type ${rlimit} " gen-sysinfo.go | \
sed -e "s/${rlimit}/Rlimit/" \
-e 's/rlim_cur/Cur/' \
-e 's/rlim_max/Max/' \
>> ${OUT}
# The RLIMIT constants.
grep '^const _RLIMIT_' gen-sysinfo.go |
sed -e 's/^\(const \)_\(RLIMIT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
grep '^const _RLIM_' gen-sysinfo.go |
grep -v '^const _RLIM_INFINITY ' |
sed -e 's/^\(const \)_\(RLIM_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
rliminf=""
if test "${rlimit}" = "_rlimit64" && grep '^const _RLIM64_INFINITY ' gen-sysinfo.go > /dev/null 2>&1; then
rliminf=`grep '^const _RLIM64_INFINITY ' gen-sysinfo.go | sed -e 's/.* //'`
else
rliminf=`grep '^const _RLIM_INFINITY ' gen-sysinfo.go | sed -e 's/.* //'`
fi
# For compatibility with the gc syscall package, treat 0xffffffffffffffff as -1.
if test "$rliminf" = "0xffffffffffffffff"; then
echo "const RLIM_INFINITY = -1" >> ${OUT}
elif test -n "$rliminf"; then
echo "const RLIM_INFINITY = $rliminf" >> ${OUT}
fi
# The sysinfo struct.
grep '^type _sysinfo ' gen-sysinfo.go | \
sed -e 's/_sysinfo/Sysinfo_t/' \
-e 's/uptime/Uptime/' \
-e 's/loads/Loads/' \
-e 's/totalram/Totalram/' \
-e 's/freeram/Freeram/' \
-e 's/sharedram/Sharedram/' \
-e 's/bufferram/Bufferram/' \
-e 's/totalswap/Totalswap/' \
-e 's/freeswap/Freeswap/' \
-e 's/procs/Procs/' \
-e 's/totalhigh/Totalhigh/' \
-e 's/freehigh/Freehigh/' \
-e 's/mem_unit/Unit/' \
>> ${OUT}
# The utimbuf struct.
grep '^type _utimbuf ' gen-sysinfo.go | \
sed -e 's/_utimbuf/Utimbuf/' \
-e 's/actime/Actime/' \
-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 PRIO constants.
grep '^const _PRIO_' gen-sysinfo.go | \
sed -e 's/^\(const \)_\(PRIO_[^= ]*\)\(.*\)$/\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}
# The GNU/Linux sock_filter struct.
grep '^type _sock_filter ' gen-sysinfo.go | \
sed -e 's/_sock_filter/SockFilter/' \
-e 's/code/Code/' \
-e 's/jt/Jt/' \
-e 's/jf/Jf/' \
-e 's/k /K /' \
>> ${OUT}
# The GNU/Linux sock_fprog struct.
grep '^type _sock_fprog ' gen-sysinfo.go | \
sed -e 's/_sock_fprog/SockFprog/' \
-e 's/len/Len/' \
-e 's/filter/Filter/' \
-e 's/_sock_filter/SockFilter/' \
>> ${OUT}
# The GNU/Linux filter flags.
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 | grep -v '_val =' | \
sed -e 's/^\(const \)_\(NLA_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
if ! grep '^const NLA_HDRLEN' ${OUT} >/dev/null 2>&1; then
if grep '^const _NLA_HDRLEN_val' ${OUT} >/dev/null 2>&1; then
echo 'const NLA_HDRLEN = _NLA_HDRLEN_val' >> ${OUT}
fi
fi
# 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 GNU/Linux CLONE flags.
grep '^const _CLONE_' gen-sysinfo.go | \
sed -e 's/^\(const \)_\(CLONE_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
# We need some CLONE constants that are not defined in older versions
# of glibc.
if ! grep '^const CLONE_NEWUSER ' ${OUT} > /dev/null 2>&1; then
echo "const CLONE_NEWUSER = 0x10000000" >> ${OUT}
fi
if ! grep '^const CLONE_NEWNET ' ${OUT} > /dev/null 2>&1; then
echo "const CLONE_NEWNET = 0x40000000" >> ${OUT}
fi
# Struct sizes.
set cmsghdr Cmsghdr ip_mreq IPMreq ip_mreqn IPMreqn ipv6_mreq IPv6Mreq \
ifaddrmsg IfAddrmsg ifa_msghdr IfaMsghdr ifinfomsg IfInfomsg \
if_msghdr IfMsghdr in_pktinfo Inet4Pktinfo in6_pktinfo Inet6Pktinfo \
inotify_event InotifyEvent linger Linger msghdr Msghdr nlattr NlAttr \
nlmsgerr NlMsgerr nlmsghdr NlMsghdr rtattr RtAttr rt_msghdr RtMsghdr \
rtgenmsg RtGenmsg rtmsg RtMsg rtnexthop RtNexthop \
sock_filter SockFilter sock_fprog SockFprog ucred Ucred \
icmp6_filter ICMPv6Filter ip6_mtuinfo IPv6MTUInfo
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
if ! grep 'const SizeofICMPv6Filter ' ${OUT} >/dev/null 2>&1; then
echo 'const SizeofICMPv6Filter = 32' >> ${OUT}
fi
# Type 'uint128' is needed in a couple of type definitions on arm64,such
# as _user_fpsimd_struct, _elf_fpregset_t, etc.
if ! grep '^type uint128' ${OUT} > /dev/null 2>&1; then
echo "type uint128 [16]byte" >> ${OUT}
fi
exit $?