]> Cypherpunks repositories - gostls13.git/log
gostls13.git
10 years agoruntime: provide a dummy value of _SIGPROF on plan9 and windows
Shenghou Ma [Thu, 1 Jan 2015 01:55:47 +0000 (20:55 -0500)]
runtime: provide a dummy value of _SIGPROF on plan9 and windows

Fixes build on plan9 and windows.

Change-Id: Ic9b02c641ab84e4f6d8149de71b9eb495e3343b2
Reviewed-on: https://go-review.googlesource.com/2233
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
10 years agoruntime/cgo: remove unused variable
Shenghou Ma [Thu, 1 Jan 2015 02:58:02 +0000 (21:58 -0500)]
runtime/cgo: remove unused variable

I missed this one in golang.org/cl/2232 and only tested the patch
on openbsd/amd64.

Change-Id: I4ff437ae0bfc61c989896c01904b6d33f9bdf0ec
Reviewed-on: https://go-review.googlesource.com/2234
Reviewed-by: Minux Ma <minux@golang.org>
10 years agoruntime/cgo: initialize our pthread_create wrapper earlier on openbsd
Shenghou Ma [Thu, 1 Jan 2015 01:30:57 +0000 (20:30 -0500)]
runtime/cgo: initialize our pthread_create wrapper earlier on openbsd

This is a genuine bug exposed by our test for issue 9456: our wrapper
for pthread_create is not initialized until we initialize cgo itself,
but it is possible that a static constructor could call pthread_create,
and in that case, it will be calling a nil function pointer.

Fix that by also initializing the sys_pthread_create function pointer
inside our pthread_create wrapper function, and use a pthread_once to
make sure it is only initialized once.

Fix build for openbsd.

Change-Id: Ica4da2c21fcaec186fdd3379128ef46f0e767ed7
Reviewed-on: https://go-review.googlesource.com/2232
Reviewed-by: David Crawshaw <crawshaw@golang.org>
10 years agocmd/gc: fix filename output format verb for -s
Shenghou Ma [Wed, 31 Dec 2014 00:48:26 +0000 (19:48 -0500)]
cmd/gc: fix filename output format verb for -s

%lL will prepend the current directory to the filename, which is not
what we want here (as the file name is already absolute).

Fixes #9150.

Change-Id: I4c9386be6baf421393b92d9401a264b4692986d0
Reviewed-on: https://go-review.googlesource.com/2231
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agoruntime: ignore SIGPROF to foreign threads before cgocallback is fully initialized
Shenghou Ma [Sun, 28 Dec 2014 00:15:38 +0000 (19:15 -0500)]
runtime: ignore SIGPROF to foreign threads before cgocallback is fully initialized

Some libraries, for example, OpenBLAS, create work threads in a global constructor.
If we're doing cpu profiling, it's possible that SIGPROF might come to some of the
worker threads before we make our first cgo call. Cgocallback used to terminate the
process when that happens, but it's better to miss a couple profiling signals than
to abort in this case.

Fixes #9456.

Change-Id: I112b8e1a6e10e6cc8ac695a4b518c0f577309b6b
Reviewed-on: https://go-review.googlesource.com/2141
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agodoc: 2015 will be the Year of the Gopher.
David Symonds [Wed, 31 Dec 2014 13:00:00 +0000 (00:00 +1100)]
doc: 2015 will be the Year of the Gopher.

Change-Id: Ic2e34f84596b56715d5f41c9a5250f7c9f8e671b
Reviewed-on: https://go-review.googlesource.com/2087
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
10 years agostrconv: optimize decimal to string conversion
Martin Möhrmann [Thu, 25 Dec 2014 18:30:53 +0000 (19:30 +0100)]
strconv: optimize decimal to string conversion

Avoid the decimal lookup in digits array and compute the decimal character value directly.
Reduce calls to 64bit division on 32bit plattforms by splitting conversion into smaller blocks.
Convert value to uintptr type when it can be represented by uintptr.

on darwin/386

benchmark               old ns/op     new ns/op     delta
BenchmarkFormatInt      8352          7466          -10.61%
BenchmarkAppendInt      4281          3401          -20.56%
BenchmarkFormatUint     2785          2251          -19.17%
BenchmarkAppendUint     1770          1223          -30.90%

on darwin/amd64

benchmark               old ns/op     new ns/op     delta
BenchmarkFormatInt      5531          5492          -0.71%
BenchmarkAppendInt      2435          2295          -5.75%
BenchmarkFormatUint     1628          1569          -3.62%
BenchmarkAppendUint     726           750           +3.31%

Change-Id: Ifca281cbdd62ab7d7bd4b077a96da99eb12cf209
Reviewed-on: https://go-review.googlesource.com/2105
Reviewed-by: Robert Griesemer <gri@golang.org>
10 years agogo/parser: add {map,chan,interface} to expression lookahead tokens
Alan Donovan [Tue, 30 Dec 2014 19:44:41 +0000 (14:44 -0500)]
go/parser: add {map,chan,interface} to expression lookahead tokens

+ tests that these parse:
  map[int]int{}[0]++
  interface{f()}(x).f()
  chan int(x) <- 0

Fixes #9474

Change-Id: If9fa57b3ab415ae7e93aa9935ec63edda8fe9d4f
Reviewed-on: https://go-review.googlesource.com/2178
Reviewed-by: Robert Griesemer <gri@golang.org>
10 years agoarchive/tar: document Reader.Next's behavior at the end
Brad Fitzpatrick [Tue, 30 Dec 2014 06:28:02 +0000 (22:28 -0800)]
archive/tar: document Reader.Next's behavior at the end

Change-Id: I72f6d0fc66dbee3f832d2d960b99a166a5bb10c3
Reviewed-on: https://go-review.googlesource.com/2191
Reviewed-by: David Symonds <dsymonds@golang.org>
10 years agodoc: add http server trailers support to go1.5.txt
Brad Fitzpatrick [Tue, 30 Dec 2014 18:01:49 +0000 (10:01 -0800)]
doc: add http server trailers support to go1.5.txt

Change-Id: Ic15e40bb1ae0bf3a4e8c43a44daf7cc35a18da87
Reviewed-on: https://go-review.googlesource.com/2192
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime: consolidate arch-specific signal handlers on Plan 9
Anthony Martin [Thu, 18 Dec 2014 13:05:44 +0000 (05:05 -0800)]
runtime: consolidate arch-specific signal handlers on Plan 9

Change-Id: I4379418853c523fc9aaeb5d6f37bc96117841418
Reviewed-on: https://go-review.googlesource.com/1786
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
10 years agodoc: update links in FAQ
Emil Hessman [Tue, 30 Dec 2014 05:45:24 +0000 (06:45 +0100)]
doc: update links in FAQ

Vitess and protobuf has moved to GitHub; update the links.

Change-Id: I2d90bde1a7f2b590c8b7b08ce73d6faa13b51da0
Reviewed-on: https://go-review.googlesource.com/2166
Reviewed-by: Andrew Gerrand <adg@golang.org>
10 years agonet/http: support for setting trailers from a server Handler
Brad Fitzpatrick [Tue, 30 Dec 2014 03:32:07 +0000 (19:32 -0800)]
net/http: support for setting trailers from a server Handler

We already had client support for trailers, but no way for a server to
set them short of hijacking the connection.

Fixes #7759

Change-Id: Ic83976437739ec6c1acad5f209ed45e501dbb93a
Reviewed-on: https://go-review.googlesource.com/2157
Reviewed-by: Andrew Gerrand <adg@golang.org>
10 years agocmd/gc: logical operators should produce untyped bool for untyped
Chris Manghane [Tue, 9 Dec 2014 15:16:38 +0000 (07:16 -0800)]
cmd/gc: logical operators should produce untyped bool for untyped
operands

Fixes #6671 for cmd/gc.

Change-Id: I4907655b6e243960f2ceb544c63ea16513c7bd68
Reviewed-on: https://go-review.googlesource.com/1251
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agotest: add fixed GoSmith bugs reported on the gcc Bugzilla
Chris Manghane [Thu, 18 Dec 2014 17:54:32 +0000 (09:54 -0800)]
test: add fixed GoSmith bugs reported on the gcc Bugzilla

Change-Id: I36b57f3e299a4f96b8b5aa55c9c224d888229684
Reviewed-on: https://go-review.googlesource.com/1790
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agotesting/iotest: fix copy/paste error in comment
Robert Griesemer [Mon, 29 Dec 2014 18:54:42 +0000 (10:54 -0800)]
testing/iotest: fix copy/paste error in comment

Reported via unsupported GitHub pull request:
https://github.com/golang/go/pull/9436/

Change-Id: I12b00e8ccac700bb36b200196e2867fcc863fdf1
Reviewed-on: https://go-review.googlesource.com/2139
Reviewed-by: Alan Donovan <adonovan@google.com>
10 years agoruntime: rename atoi to _atoi on Plan 9
David du Colombier [Mon, 29 Dec 2014 16:35:42 +0000 (17:35 +0100)]
runtime: rename atoi to _atoi on Plan 9

Following change 2154, the goatoi function
was renamed atoi.

However, this definition conflicts with the
atoi function defined in the Plan 9 runtime,
which takes a []byte instead of a string.

This change fixes the build on Plan 9.

Change-Id: Ia0f7ca2f965bd5e3cce3177bba9c806f64db05eb
Reviewed-on: https://go-review.googlesource.com/2165
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime: remove go prefix from a few routines
Keith Randall [Mon, 29 Dec 2014 07:16:32 +0000 (23:16 -0800)]
runtime: remove go prefix from a few routines

They are no longer needed now that C is gone.

goatoi -> atoi
gofuncname/funcname -> funcname/cfuncname
goroundupsize -> already existing roundupsize

Change-Id: I278bc33d279e1fdc5e8a2a04e961c4c1573b28c7
Reviewed-on: https://go-review.googlesource.com/2154
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
10 years agoliblink, cmd/ld, runtime: remove stackguard1
Shenghou Ma [Mon, 29 Dec 2014 06:08:40 +0000 (01:08 -0500)]
liblink, cmd/ld, runtime: remove stackguard1

Now that we've removed all the C code in runtime and the C compilers,
there is no need to have a separate stackguard field to check for C
code on Go stack.

Remove field g.stackguard1 and rename g.stackguard0 to g.stackguard.
Adjust liblink and cmd/ld as necessary.

Change-Id: I54e75db5a93d783e86af5ff1a6cd497d669d8d33
Reviewed-on: https://go-review.googlesource.com/2144
Reviewed-by: Keith Randall <khr@golang.org>
10 years agodoc: add net/smtp TLSConnectionState note in go1.5.txt
Brad Fitzpatrick [Sun, 28 Dec 2014 21:37:44 +0000 (13:37 -0800)]
doc: add net/smtp TLSConnectionState note in go1.5.txt

Change-Id: Ia18f6ed0fa38dac297fc5fe1ca56e38ec37518ef
Reviewed-on: https://go-review.googlesource.com/2152
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agonet/smtp: add TLSConnectionState accessor
Brad Fitzpatrick [Sun, 28 Dec 2014 19:18:59 +0000 (11:18 -0800)]
net/smtp: add TLSConnectionState accessor

Fixes #9451

Change-Id: I0540e398b30c10779ac9d5a67a01d44bb6054a92
Reviewed-on: https://go-review.googlesource.com/2151
Reviewed-by: David Symonds <dsymonds@golang.org>
10 years agoencoding/gob: address go vet report
Emil Hessman [Sun, 28 Dec 2014 07:21:58 +0000 (08:21 +0100)]
encoding/gob: address go vet report

Use Fatalf for formatting directive rather than plain Fatal.

Change-Id: Iebd30cd6326890e9501746113a6d97480949e3d2
Reviewed-on: https://go-review.googlesource.com/2161
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime: get rid of goalg, no longer needed
Keith Randall [Sun, 28 Dec 2014 04:32:11 +0000 (20:32 -0800)]
runtime: get rid of goalg, no longer needed

The goalg function was a holdover from when we had algorithm
tables in both C and Go.  It is no longer needed.

Change-Id: Ia0c1af35bef3497a899f22084a1a7b42daae72a0
Reviewed-on: https://go-review.googlesource.com/2099
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoencoding/json: address go vet reports
Emil Hessman [Sat, 27 Dec 2014 19:52:17 +0000 (20:52 +0100)]
encoding/json: address go vet reports

The error message for decoding a unquoted value into a struct field with
the ,string option specified has two arguments when one is needed.
Make the error message take one argument and add a test in order to cover
the case when a unquoted value is specified.

Also add error value as the missing argument for Fatalf call in test.

Fixes the following go vet reports:

decode.go:602: wrong number of args for format in Errorf call: 1 needed but 2 args
decode_test.go:1088: missing argument for Fatalf("%v"): format reads arg 1, have only 0 args

Change-Id: Id036e10c54c4a7c1ee9952f6910858ecc2b84134
Reviewed-on: https://go-review.googlesource.com/2109
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
10 years agocmd/pack: address go vet reports
Emil Hessman [Sun, 28 Dec 2014 05:12:19 +0000 (06:12 +0100)]
cmd/pack: address go vet reports

Use log.Fatalf for formatting directives instead of log.Fatal

Change-Id: Ia207b320f5795c63cdfa71f92c19ca6d05cc833f
Reviewed-on: https://go-review.googlesource.com/2160
Reviewed-by: Minux Ma <minux@golang.org>
10 years agoruntime: rename gothrow to throw
Keith Randall [Sun, 28 Dec 2014 04:58:00 +0000 (20:58 -0800)]
runtime: rename gothrow to throw

Rename "gothrow" to "throw" now that the C version of "throw"
is no longer needed.

This change is purely mechanical except in panic.go where the
old version of "throw" has been deleted.

sed -i "" 's/[[:<:]]gothrow[[:>:]]/throw/g' runtime/*.go

Change-Id: Icf0752299c35958b92870a97111c67bcd9159dc3
Reviewed-on: https://go-review.googlesource.com/2150
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
10 years agonet/http: use t.Fatalf rather than t.Fatal in cookie_test.go
Guobiao Mei [Sat, 27 Dec 2014 23:28:07 +0000 (18:28 -0500)]
net/http: use t.Fatalf rather than t.Fatal in cookie_test.go

Change-Id: I60bbb7deb7462d1ca884677b4f86bd54b20b3f35
Reviewed-on: https://go-review.googlesource.com/2140
Reviewed-by: Minux Ma <minux@golang.org>
10 years agostrconv/itoa: add test to generate the longest output string possible by formatBits
Martin Möhrmann [Sat, 27 Dec 2014 10:53:09 +0000 (11:53 +0100)]
strconv/itoa: add test to generate the longest output string possible by formatBits

The new test case produces the longest string representation possible and thereby uses
all of the 65 bytes in the buffer array used by the formatBits function.

Change-Id: I11320c4de56ced5ff098b7e37f1be08e456573e2
Reviewed-on: https://go-review.googlesource.com/2108
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agodoc: mention the crypto/cipher.Stream clarification in go1.5.txt
Shenghou Ma [Fri, 26 Dec 2014 21:00:49 +0000 (16:00 -0500)]
doc: mention the crypto/cipher.Stream clarification in go1.5.txt

Change-Id: Ie95c86d222b230a2e69f4141e3372bf94dee3e91
Reviewed-on: https://go-review.googlesource.com/2129
Reviewed-by: Minux Ma <minux@golang.org>
10 years agocrypto/cipher: update docs for the Stream interface
Shenghou Ma [Thu, 18 Dec 2014 08:18:23 +0000 (03:18 -0500)]
crypto/cipher: update docs for the Stream interface

Specify what will happen if len(dst) != len(src).

Change-Id: I66afa3730f637753b825189687418f14ddec3629
Reviewed-on: https://go-review.googlesource.com/1754
Reviewed-by: Adam Langley <agl@golang.org>
10 years agodoc/go_spec: fix typo
Shenghou Ma [Fri, 26 Dec 2014 07:50:33 +0000 (02:50 -0500)]
doc/go_spec: fix typo

Fixes #9445

Change-Id: If7abd4d4d41cdfd5cf677f03533c930c8b965a01
Reviewed-on: https://go-review.googlesource.com/2128
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoreflect, runtime: gofmt
mattn [Fri, 26 Dec 2014 02:44:55 +0000 (11:44 +0900)]
reflect, runtime: gofmt

Change-Id: I5437b3a36181373d8ff33225d7520ab321459de9
Reviewed-on: https://go-review.googlesource.com/2084
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agocmd/ld: put .bss from external objects into real .bss section
Shenghou Ma [Sun, 21 Dec 2014 07:48:01 +0000 (02:48 -0500)]
cmd/ld: put .bss from external objects into real .bss section

Fixes #9359.

Change-Id: Iba62935b5a14de23d914f433a09a40417d7e88ed
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/1889
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agoruntime: simplify procresize
Dmitry Vyukov [Mon, 22 Dec 2014 15:14:00 +0000 (18:14 +0300)]
runtime: simplify procresize

Currently we do very a complex rebalancing of runnable goroutines
between queues, which tries to preserve scheduling fairness.
Besides being complex and error-prone, it also destroys all locality
of scheduling.

This change uses simpler scheme: leave runnable goroutines where
they are, during starttheworld start all Ps with local work,
plus start one additional P in case we have excessive runnable
goroutines in local queues or in the global queue.

The schedler must be able to operate efficiently w/o the rebalancing,
because garbage collections do not have to happen frequently.

The immediate need is execution tracing support: handling of
garabage collection which does stoptheworld/starttheworld several
times becomes exceedingly complex if the current execution can
jump between Ps during starttheworld.

Change-Id: I4fdb7a6d80ca4bd08900d0c6a0a252a95b1a2c90
Reviewed-on: https://go-review.googlesource.com/1951
Reviewed-by: Rick Hudson <rlh@golang.org>
10 years agoregexp: fix typo in comment: s/onpass/onepass/
Michael Matloob [Wed, 24 Dec 2014 07:19:08 +0000 (23:19 -0800)]
regexp: fix typo in comment: s/onpass/onepass/

Change-Id: Idff57050a34d09e7fa9b77e9b53d61bb5ea2a71c
Reviewed-on: https://go-review.googlesource.com/2095
Reviewed-by: Minux Ma <minux@golang.org>
10 years agoreflect: fix func layout test for nacl build
Keith Randall [Tue, 23 Dec 2014 21:45:58 +0000 (13:45 -0800)]
reflect: fix func layout test for nacl build

This test code is ugly.  There must be a better way.
But for now, fix the build.

Change-Id: I33064145ea37f11abf040ec97caa87669be1a9fa
Reviewed-on: https://go-review.googlesource.com/2114
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agodatabase/sql: Remove unnecessary call to maybeOpenNewConnections
Marko Tiikkaja [Sun, 14 Dec 2014 02:57:14 +0000 (03:57 +0100)]
database/sql: Remove unnecessary call to maybeOpenNewConnections

numCanOpen will never be larger than 0 in maybeOpenNewConnections() when this
code path is taken, so no new connections can ever be opened.

Change-Id: Id1302e8d9afb3a67be61b5e738fe07ef81d20fe0
Reviewed-on: https://go-review.googlesource.com/1550
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agomisc/cgo/test: get rid of the backdoor package
Shenghou Ma [Sat, 20 Dec 2014 19:13:44 +0000 (14:13 -0500)]
misc/cgo/test: get rid of the backdoor package

For Go 1.5, we can use go:linkname rather than assembly thunk for gc.
Gccgo already has support for //extern.

Change-Id: I5505aa247dd5b555112f7261ed2f192c81cf0bdf
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/1888
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agotest/fixedbugs/issue9355: fix build on arm and power64
Shenghou Ma [Fri, 19 Dec 2014 05:36:26 +0000 (00:36 -0500)]
test/fixedbugs/issue9355: fix build on arm and power64

Change-Id: I1ef770184ad1d42bcb58714d559f2cc866a919ab
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/1880
Reviewed-by: Keith Randall <khr@golang.org>
10 years agosort: simplify rotate and reduce calls to it
Martin Möhrmann [Tue, 23 Dec 2014 19:44:10 +0000 (20:44 +0100)]
sort: simplify rotate and reduce calls to it

Move the checks for empty rotate changes
from the beginning of rotate to the callers.

Remove additional variable p used instead of existing m with same value.

Remove special casing of equal ranges (i==j) to exit early as no
work is saved vs checking (i!=j) and  making a single
swapRange call if this is false.

benchmark                   old ns/op      new ns/op      delta
BenchmarkStableString1K     417195         425218         +1.92%
BenchmarkStableInt1K        126661         124498         -1.71%
BenchmarkStableInt64K       10365014       10417438       +0.51%
BenchmarkStable1e2          132151         130648         -1.14%
BenchmarkStable1e4          42027428       40812649       -2.89%
BenchmarkStable1e6          8524772364     8430192391     -1.11%

Change-Id: Ia7642e9d31408496970c700f5843d53cc3ebe817
Reviewed-on: https://go-review.googlesource.com/2100
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agogo/build: add variable expansion to cgo lines
Carlos Castillo [Mon, 8 Dec 2014 15:28:40 +0000 (07:28 -0800)]
go/build: add variable expansion to cgo lines

When go parses #cgo lines, expand ${SRCDIR} into the path to the
source directory. This allows options to be passed to the
compiler and linker that involve file paths relative to the
source code directory. Without the expansion the paths would be
invalid when the current working directory changes.

Fixes #7891
Fixes #5428

Change-Id: I343a145a9771a5ccbaa958e4a1ecd1716fcae52d
Reviewed-on: https://go-review.googlesource.com/1756
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agoreflect: more function layout tests
Keith Randall [Tue, 23 Dec 2014 18:57:37 +0000 (10:57 -0800)]
reflect: more function layout tests

Test more stuff:
1) flagNoPointers, an incorrect value was the cause of #9425
2) Total function layout size
3) gc program

Change-Id: I73f65fe740215938fa930d2f096febd9db0a0021
Reviewed-on: https://go-review.googlesource.com/2090
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agomime/multipart: moved some code to mime/internal/quotedprintable
Alexandre Cesaro [Thu, 18 Dec 2014 20:33:34 +0000 (21:33 +0100)]
mime/multipart: moved some code to mime/internal/quotedprintable

The code concerning quoted-printable encoding (RFC 2045) and its
variant for MIME headers (RFC 2047) is currently spread in
mime/multipart and net/mail. It is also not exported.

This commit is the first step to fix that issue. It moves the
quoted-printable decoding code from mime/multipart to
mime/internal/quotedprintable. The exposed API is unchanged.

Concerns #4943.

Change-Id: I11352afbb2edb4d6ef62870b9bc5c87c639eff12
Reviewed-on: https://go-review.googlesource.com/1810
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime: fix exit on Plan 9
David du Colombier [Tue, 23 Dec 2014 10:09:15 +0000 (11:09 +0100)]
runtime: fix exit on Plan 9

Add a nil byte at the end of the itoa buffer,
before calling gostringnocopy. This prevents
gostringnocopy to read past the buffer size.

Change-Id: I87494a8dd6ea45263882536bf6c0f294eda6866d
Reviewed-on: https://go-review.googlesource.com/2033
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
10 years agomath/rand: fix example_test to show with the correct method
Guobiao Mei [Tue, 23 Dec 2014 15:47:12 +0000 (10:47 -0500)]
math/rand: fix example_test to show with the correct method

Originally it used r.Int63() to show "Uint32", and now we use the correct r.Uint32() method.

Fixes #9429

Change-Id: I8a1228f1ca1af93b0e3104676fc99000257c456f
Reviewed-on: https://go-review.googlesource.com/2069
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agotest: disable bug248 and bug345 tests on Plan 9
David du Colombier [Tue, 23 Dec 2014 08:05:28 +0000 (09:05 +0100)]
test: disable bug248 and bug345 tests on Plan 9

These tests were enabled as part of change 1774.
They depend on the errchk tool, which is a Perl
script. However, Perl is not available on Plan 9.

Change-Id: I82707aae16013acc9a3800d39b0084588b852b53
Reviewed-on: https://go-review.googlesource.com/2031
Reviewed-by: Minux Ma <minux@golang.org>
10 years agocmd/dist: fatal shouldn't print errstr on Plan 9
David du Colombier [Mon, 22 Dec 2014 21:33:39 +0000 (22:33 +0100)]
cmd/dist: fatal shouldn't print errstr on Plan 9

During change 1864 discussion, Russ Cox pointed out
the fatal function shouldn't print errstr.

Change-Id: Icd71ec04be9c944bc235b8b198158465172e4fde
Reviewed-on: https://go-review.googlesource.com/2030
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime: remove thunk_windows.s
Alex Brainman [Tue, 23 Dec 2014 04:33:51 +0000 (15:33 +1100)]
runtime: remove thunk_windows.s

Change-Id: I171298e7942093e9cc82e3a0c4fcbb5b10298816
Reviewed-on: https://go-review.googlesource.com/1998
Reviewed-by: Minux Ma <minux@golang.org>
10 years agoruntime: add comments for blank import of "unsafe"
Shenghou Ma [Tue, 23 Dec 2014 05:03:40 +0000 (00:03 -0500)]
runtime: add comments for blank import of "unsafe"

Change-Id: Iaad548ea90d3b70341a723450d5e4d4c2b88856f
Reviewed-on: https://go-review.googlesource.com/2063
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agocmd/api: work around Windows rename issue on the builders
Brad Fitzpatrick [Tue, 23 Dec 2014 02:28:16 +0000 (18:28 -0800)]
cmd/api: work around Windows rename issue on the builders

More cmd/api/run.go hell.

Fixes #9407

Change-Id: If8fb446a2471d6372beb0534c9ab6824029b404c
Reviewed-on: https://go-review.googlesource.com/2054
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Minux Ma <minux@golang.org>
10 years agoruntime: fix build for arm and ppc64/ppc64le
Shenghou Ma [Tue, 23 Dec 2014 04:44:41 +0000 (23:44 -0500)]
runtime: fix build for arm and ppc64/ppc64le

Change-Id: I17ddcb541dfac8b1e48e01ee005563031b6ade2a
Reviewed-on: https://go-review.googlesource.com/2062
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agobuild: give freebsd longer to run tests
Andrew Gerrand [Tue, 23 Dec 2014 01:09:38 +0000 (12:09 +1100)]
build: give freebsd longer to run tests

The freebsd-386 and freebsd-amd64 builders are timing out sometimes.
This will give them some more breathing room.

Change-Id: Ib65bd172cca046a52861759a4232d7b4b6514fa8
Reviewed-on: https://go-review.googlesource.com/1994
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agoruntime: import unsafe in os_windows.go (fixes windows build)
Alex Brainman [Tue, 23 Dec 2014 04:00:04 +0000 (15:00 +1100)]
runtime: import unsafe in os_windows.go (fixes windows build)

Change-Id: I55419cb580e6d18cf1c17c3e7bb8777ed6d794e7
Reviewed-on: https://go-review.googlesource.com/1995
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agoreflect: add kindNoPointers if a function layout has no pointers.
Keith Randall [Tue, 23 Dec 2014 03:07:05 +0000 (19:07 -0800)]
reflect: add kindNoPointers if a function layout has no pointers.

malloc checks kindNoPointers and if it is not set and the object
is one pointer in size, it assumes it contains a pointer.  So we
must set kindNoPointers correctly; it isn't just a hint.

Fixes #9425

Change-Id: Ia43da23cc3298d6e3d6dbdf66d32e9678f0aedcf
Reviewed-on: https://go-review.googlesource.com/2055
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: remove thunk.s
Russ Cox [Mon, 22 Dec 2014 18:27:53 +0000 (13:27 -0500)]
runtime: remove thunk.s

Replace with uses of //go:linkname in Go files, direct use of name in .s files.
The only one that really truly needs a jump is reflect.call; the jump is now
next to the runtime.reflectcall assembly implementations.

Change-Id: Ie7ff3020a8f60a8e4c8645fe236e7883a3f23f46
Reviewed-on: https://go-review.googlesource.com/1962
Reviewed-by: Austin Clements <austin@google.com>
10 years agomisc/cgo: fix issue 9400 test on 386
Austin Clements [Tue, 23 Dec 2014 02:18:09 +0000 (21:18 -0500)]
misc/cgo: fix issue 9400 test on 386

issue9400_linux.go did not build on 386 because it used a constant
that was larger than a 32-bit int in a ... argument.  Fix this by
casting the constant to uint64 (to match how the constant is being
used).

Change-Id: Ie8cb64c3910382a41c7852be7734a62f0b2d5a21
Reviewed-on: https://go-review.googlesource.com/2060
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agoruntime: correct ptrSize test in Linux version of sysReserve
Ian Lance Taylor [Sun, 14 Dec 2014 15:59:11 +0000 (07:59 -0800)]
runtime: correct ptrSize test in Linux version of sysReserve

Change-Id: I90a8ca51269528a307e0d6f52436fc7913cd7900
Reviewed-on: https://go-review.googlesource.com/1541
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: run libc SIGSETXID and SIGCANCEL handlers on signal stack
Austin Clements [Fri, 19 Dec 2014 21:16:17 +0000 (16:16 -0500)]
runtime: run libc SIGSETXID and SIGCANCEL handlers on signal stack

These signals are used by glibc to broadcast setuid/setgid to all
threads and to send pthread cancellations.  Unlike other signals, the
Go runtime does not intercept these because they must invoke the libc
handlers (see issues #3871 and #6997).  However, because 1) these
signals may be issued asynchronously by a thread running C code to
another thread running Go code and 2) glibc does not set SA_ONSTACK
for its handlers, glibc's signal handler may be run on a Go stack.
Signal frames range from 1.5K on amd64 to many kilobytes on ppc64, so
this may overflow the Go stack and corrupt heap (or other stack) data.

Fix this by ensuring that these signal handlers have the SA_ONSTACK
flag (but not otherwise taking over the handler).

This has been a problem since Go 1.1, but it's likely that people
haven't encountered it because it only affects setuid/setgid and
pthread_cancel.

Fixes #9600.

Change-Id: I6cf5f5c2d3aa48998d632f61f1ddc2778dcfd300
Reviewed-on: https://go-review.googlesource.com/1887
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agonet/http/cgi: Correctly pass down the REMOTE_PORT value for CGI requests.
George Shammas [Thu, 18 Dec 2014 04:22:49 +0000 (23:22 -0500)]
net/http/cgi: Correctly pass down the REMOTE_PORT value for CGI requests.

Currently when we get a CGI or FCGI request, the remote port of the client
is hard coded to zero, despite nearly every webserver passing down the
REMOTE_PORT variable.

This was likely originally excluded because the CGI RFC (rfc3875) does not
mention anything about the remote port of the client. However every webserver
tested does pass REMOTE_PORT down. This includes Apache 2.2, Apache 2.4,
nginx and lighttpd.

Fixes #8351

Change-Id: I4c6366cb39f0ccc05e038bd31d85f93b76e8d0c8
Reviewed-on: https://go-review.googlesource.com/1750
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agotest: fix windows build
Josh Bleecher Snyder [Mon, 22 Dec 2014 23:26:21 +0000 (15:26 -0800)]
test: fix windows build

Broken by e7173dfdfd1c74b1d301da9b6f295ef99b9cc11c

Fix by simply disabling the relevant tests.

* bug248 and bug345 require errchk, but we can't
  rely on perl being available.
* bug369 is disabled anyway.

Change-Id: Idf73ebccb066943e3fe17c2f662b37238ec74dfe
Reviewed-on: https://go-review.googlesource.com/2052
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
10 years agoruntime: make stack frames fixed size by modifying goproc/deferproc.
Keith Randall [Mon, 8 Dec 2014 22:18:58 +0000 (14:18 -0800)]
runtime: make stack frames fixed size by modifying goproc/deferproc.

Calls to goproc/deferproc used to push & pop two extra arguments,
the argument size and the function to call.  Now, we allocate space
for those arguments in the outargs section so we don't have to
modify the SP.

Defers now use the stack pointer (instead of the argument pointer)
to identify which frame they are associated with.

A followon CL might simplify funcspdelta and some of the stack
walking code.

Fixes issue #8641

Change-Id: I835ec2f42f0392c5dec7cb0fe6bba6f2aed1dad8
Reviewed-on: https://go-review.googlesource.com/1601
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/9l: improve R_CALLPOWER error messages
Austin Clements [Tue, 16 Dec 2014 19:08:39 +0000 (14:08 -0500)]
cmd/9l: improve R_CALLPOWER error messages

Change-Id: I8670540a2a9647efbd8b072a54272a04c530e54b
Reviewed-on: https://go-review.googlesource.com/2001
Reviewed-by: Minux Ma <minux@golang.org>
10 years agosyscall: fix the deprecated way of parsing routing message on openbsd
Mikio Hara [Mon, 22 Dec 2014 03:30:16 +0000 (12:30 +0900)]
syscall: fix the deprecated way of parsing routing message on openbsd

OpenBSD 5.5 changed its kernel ABI and OpenBSD 5.6 enabled it.
This CL works on both 5.5 and 5.6.

Fixes #9102.

Change-Id: I4a295be9ab8acbc99e550d8cb7e8f8dacf3a03c5
Reviewed-on: https://go-review.googlesource.com/1932
Reviewed-by: Ian Lance Taylor <iant@golang.org>
10 years agoruntime: fix nacl build, hashmap overflow field offset was incorrect.
Keith Randall [Mon, 22 Dec 2014 23:24:30 +0000 (15:24 -0800)]
runtime: fix nacl build, hashmap overflow field offset was incorrect.

Change-Id: Ieb305b2a4d4ef28d70a8b8ece703f495c5af0529
Reviewed-on: https://go-review.googlesource.com/2051
Reviewed-by: Keith Randall <khr@golang.org>
10 years agotest: add test case that gccgo failed to link
Ian Lance Taylor [Tue, 16 Dec 2014 22:54:20 +0000 (14:54 -0800)]
test: add test case that gccgo failed to link

Gccgo creates a struct to hold the arguments for the deferred
function.  In this example the struct holds a type defined in a
different package.  The bug was that gccgo tried to create an equality
function for this struct, and it implemented that function by calling
the equality function for the type defined in the other package.
Since that type is not exported, the reference to the equality
function failed at link time.  Normally it is impossible for a struct
to directly contain a member that is an unexported type from another
package, but in this specific case it was possible.  Fixed in gccgo
with https://codereview.appspot.com/183500043 .

Change-Id: I8ec3a33631225b9ac2a4ac060cb4d10b4635e60b
Reviewed-on: https://go-review.googlesource.com/1690
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
10 years agocmd/5l,6l,8l: remove bogus dynsym section indexes
Austin Clements [Tue, 16 Dec 2014 20:59:05 +0000 (15:59 -0500)]
cmd/5l,6l,8l: remove bogus dynsym section indexes

Previously, this code generated bogus section indexes for dynamic
symbols.  It turns out this didn't matter, since we only emit these
when generating an executable and in an executable it only matters
whether a symbol is defined or undefined, but it leads to perplexing
code full of mysterious constants.

Unfortunately, this happens too early to put in real section indexes,
so just use section index 1 to distinguish the symbol from an
undefined symbol.

Change-Id: I0e514604bf31f21683598ebd3e020b66acf767ef
Reviewed-on: https://go-review.googlesource.com/1720
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/ld: add a text generation pass
Austin Clements [Wed, 17 Dec 2014 17:13:47 +0000 (12:13 -0500)]
cmd/ld: add a text generation pass

This will be used by ppc64 to add call stubs to the .text section.
ARM needs a similar pass to generate veneers for arm->thumb
transitions.

Change-Id: Iaee74036e60643a56fab15b564718f359c5910eb
Reviewed-on: https://go-review.googlesource.com/2004
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoliblink: code for debugging bad returns
Austin Clements [Mon, 22 Dec 2014 21:46:25 +0000 (16:46 -0500)]
liblink: code for debugging bad returns

Disabled by default, but invaluable when you need it.

Change-Id: If4a75d11d14f70b6840d339aaec4b940dc406493
Reviewed-on: https://go-review.googlesource.com/2012
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agotest: migrate remaining tests to run.go
Josh Bleecher Snyder [Thu, 18 Dec 2014 18:34:12 +0000 (10:34 -0800)]
test: migrate remaining tests to run.go

* bug248, bug345, bug369, and bug429 were ported from bash commands to run scripts. bug369 remains disabled.
* bug395 is a test for issue 1909, which is still open. It is marked as skip now and will be usable with compile with run.go when issue 1909 is fixed.

Fixes #4139

Updates #1909

Change-Id: Ibb5fbfb5cf72ddc285829245318eeacd3fb5a636
Reviewed-on: https://go-review.googlesource.com/1774
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agosyscall: update go.sys doc reference to golang.org/x/sys
Joe Shaw [Mon, 22 Dec 2014 20:27:46 +0000 (15:27 -0500)]
syscall: update go.sys doc reference to golang.org/x/sys

Change-Id: Ie5a36dbcd809fc165f4198d47641d5a95878460c
Reviewed-on: https://go-review.googlesource.com/2000
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: a better fallback hash
Keith Randall [Thu, 11 Dec 2014 01:02:58 +0000 (17:02 -0800)]
runtime: a better fallback hash

For arm and powerpc, as well as x86 without aes instructions.
Contains a mixture of ideas from cityhash and xxhash.

Compared to our old fallback on ARM, it's ~no slower on
small objects and up to ~50% faster on large objects.  More
importantly, it is a much better hash function and thus has
less chance of bad behavior.

Fixes #8737

benchmark                         old ns/op     new ns/op     delta
BenchmarkHash5                    173           181           +4.62%
BenchmarkHash16                   252           212           -15.87%
BenchmarkHash64                   575           419           -27.13%
BenchmarkHash1024                 7173          3995          -44.31%
BenchmarkHash65536                516940        313173        -39.42%
BenchmarkHashStringSpeed          300           279           -7.00%
BenchmarkHashBytesSpeed           478           424           -11.30%
BenchmarkHashInt32Speed           217           207           -4.61%
BenchmarkHashInt64Speed           262           231           -11.83%
BenchmarkHashStringArraySpeed     609           631           +3.61%

Change-Id: I0a9335028f32b10ad484966e3019987973afd3eb
Reviewed-on: https://go-review.googlesource.com/1360
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoruntime: hashmap: move overflow pointer to end of bucket
Keith Randall [Sat, 20 Dec 2014 04:44:18 +0000 (20:44 -0800)]
runtime: hashmap: move overflow pointer to end of bucket

Pointers to zero-sized values may end up pointing to the next
object in memory, and possibly off the end of a span.  This
can cause memory leaks and/or confuse the garbage collector.

By putting the overflow pointer at the end of the bucket, we
make sure that pointers to any zero-sized keys or values don't
accidentally point to the next object in memory.

fixes #9384

Change-Id: I5d434df176984cb0210b4d0195dd106d6eb28f73
Reviewed-on: https://go-review.googlesource.com/1869
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/gc: update hashmap code location in comments
Josh Bleecher Snyder [Mon, 22 Dec 2014 19:23:43 +0000 (11:23 -0800)]
cmd/gc: update hashmap code location in comments

Change-Id: I3b81f2e9eb29ee6349d758b68fe7951b34f15a81
Reviewed-on: https://go-review.googlesource.com/1974
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agogo/build: fix test on Windows
Brad Fitzpatrick [Mon, 22 Dec 2014 21:59:17 +0000 (13:59 -0800)]
go/build: fix test on Windows

Change-Id: Icba46194bcbfd86b512eef2599242c715ad4e7d3
Reviewed-on: https://go-review.googlesource.com/2041
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
10 years agogo/build: fix field mismatch in unkeyed struct literal
Brad Fitzpatrick [Mon, 22 Dec 2014 21:40:28 +0000 (13:40 -0800)]
go/build: fix field mismatch in unkeyed struct literal

Fixes #9409

Change-Id: I2404cd8bf3ebb07f4b6a2b3e1d58ab69b9f1e8d8
Reviewed-on: https://go-review.googlesource.com/2040
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
10 years agosyscall: check recorded version of ppid instead of 1
David Crawshaw [Thu, 11 Dec 2014 15:25:32 +0000 (10:25 -0500)]
syscall: check recorded version of ppid instead of 1

Handles the case where the parent is pid 1 (common in docker
containers).

Attempted and failed to write a test for this.

Fixes #9263.

Change-Id: I5c6036446c99e66259a4fab1660b6a594f875020
Reviewed-on: https://go-review.googlesource.com/1372
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agosort: reduce leaf calls in Stable
Josh Bleecher Snyder [Thu, 18 Dec 2014 21:11:08 +0000 (13:11 -0800)]
sort: reduce leaf calls in Stable

Move the symMerge recursion stopping condition
from the beginning of symMerge to the callers.

This halves the number of calls to symMerge
while running 'go test sort'.

benchmark                   old ns/op      new ns/op      delta
BenchmarkStable1e6          8358117060     7954143849     -4.83%
BenchmarkStable1e4          40116117       38583285       -3.82%
BenchmarkStableInt1K        119150         115182         -3.33%
BenchmarkStableInt64K       9799845        9515475        -2.90%
BenchmarkStableString1K     388901         393516         +1.19%
BenchmarkStable1e2          124917         123618         -1.04%

Change-Id: I7ba2ca277f213b076fe6830e1139edb47ac53800
Reviewed-on: https://go-review.googlesource.com/1820
Reviewed-by: Robert Griesemer <gri@golang.org>
10 years agoencoding/binary: check for unsigned integers in intDataSize.
Stan Schwertly [Thu, 18 Dec 2014 19:32:40 +0000 (19:32 +0000)]
encoding/binary: check for unsigned integers in intDataSize.

intDataSize ignores unsigned integers, forcing reads/writes to miss the fast path.

Fixes #8956

Change-Id: Ie79b565b037db3c469aa1dc6d0a8a5a9252d5f0a
Reviewed-on: https://go-review.googlesource.com/1777
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/ld: clean up nested if when loading bind local syms
Austin Clements [Thu, 18 Dec 2014 20:28:58 +0000 (15:28 -0500)]
cmd/ld: clean up nested if when loading bind local syms

Change-Id: I15269722ca3d2654a9dd7a3f8a89ad375dc9bee0
Reviewed-on: https://go-review.googlesource.com/1759
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agocmd/api: fix race in run.go with multiple builders on a machine
Brad Fitzpatrick [Mon, 22 Dec 2014 19:16:04 +0000 (11:16 -0800)]
cmd/api: fix race in run.go with multiple builders on a machine

Fixes #9407

Change-Id: I765e8009c7ee22473ac8c2d81c7f6c8ec9866c51
Reviewed-on: https://go-review.googlesource.com/1980
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
10 years agosyscall: fs_nacl: Unlock() should be deferred.
Peter Armitage [Tue, 16 Dec 2014 14:12:48 +0000 (14:12 +0000)]
syscall: fs_nacl: Unlock() should be deferred.

Change-Id: Iea08b8f4e74a8cd4b4d317273046457c8db956a1
Reviewed-on: https://go-review.googlesource.com/1640
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agoliblink: remove class from %#D formatter on 6l
Austin Clements [Mon, 15 Dec 2014 15:51:31 +0000 (10:51 -0500)]
liblink: remove class from %#D formatter on 6l

This was a copy-paste error from 9l.  Besides incorrectly referring to
cnames9, 6l doesn't even use a->class, so simply remove this.

Fixes #9320

Change-Id: I0e3440c9dae1c3408eb795b3645f9f1dd8f50aed
Reviewed-on: https://go-review.googlesource.com/1516
Reviewed-by: Russ Cox <rsc@golang.org>
10 years agodoc: fix comment type typo
Brad Fitzpatrick [Mon, 22 Dec 2014 15:58:26 +0000 (07:58 -0800)]
doc: fix comment type typo

Fixes #9418

Change-Id: I044fa1d26d972f012f00388a84c4d0f143cf4f63
Reviewed-on: https://go-review.googlesource.com/1970
Reviewed-by: Robert Griesemer <gri@golang.org>
10 years agodoc: note encoding/base64 unpadded encodings in go1.5.txt
Josh Bleecher Snyder [Mon, 22 Dec 2014 17:32:34 +0000 (09:32 -0800)]
doc: note encoding/base64 unpadded encodings in go1.5.txt

Change-Id: I04d2e83f86f021464190f0b0fe0e450cb4662ad9
Reviewed-on: https://go-review.googlesource.com/1971
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
10 years agoencoding/base64: add unpadded encodings, and test all encodings.
Bryan Ford [Sat, 13 Dec 2014 18:54:39 +0000 (13:54 -0500)]
encoding/base64: add unpadded encodings, and test all encodings.

Some applications use unpadded base64 format, omitting the trailing
'=' padding characters from the standard base64 format, either to
minimize size or (more justifiably) to avoid use of the '=' character.
Unpadded flavors are standard and documented in section 3.2 of RFC 4648.

To support these unpadded flavors, this change adds two predefined
encoding variables, RawStdEncoding and RawURLEncoding, for unpadded
encodings using the standard and URL character set, respectively.
The change also adds a function WithPadding() to customize the padding
character or disable padding in a custom Encoding.

Finally, I noticed that the existing base64 test-suite was only
exercising the StdEncoding, and not referencing URLEncoding at all.
This change adds test-suite functionality to exercise all four encodings
(the two existing ones and the two new unpadded flavors),
although it still doesn't run *every* test on all four encodings.

Naming: I used the "Raw" prefix because it's more concise than "Unpadded"
and seemed just as expressive, but I have no strong preferences here.
Another short alternative prefix would be "Min" ("minimal" encoding).

Change-Id: Ic0423e02589b39a6b2bb7d0763bd073fd244f469
Reviewed-on: https://go-review.googlesource.com/1511
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agofmt: fix bug in scanning of hex strings
Rob Pike [Mon, 15 Dec 2014 00:52:06 +0000 (09:52 +0900)]
fmt: fix bug in scanning of hex strings
Couldn't handle a hex string terminated by anything
other than spaces. Easy to fix.

Fixes #9124.

Change-Id: I18f89a0bd99a105c9110e1ede641873bf9daf3af
Reviewed-on: https://go-review.googlesource.com/1538
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agosyscall: clean up TestStdcallAndCDeclCallbacks to have no warnings
Alex Brainman [Sun, 21 Dec 2014 23:30:43 +0000 (10:30 +1100)]
syscall: clean up TestStdcallAndCDeclCallbacks to have no warnings

Fixes #9188

Change-Id: Ifbf5d9fa78a4f4ceb7f92d42494fe37fa7878c45
Reviewed-on: https://go-review.googlesource.com/1930
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoflag: Check for Set error
Michalis Kargakis [Sun, 21 Dec 2014 22:03:11 +0000 (23:03 +0100)]
flag: Check for Set error

Check for Set error when a boolean flag isn't explicitly given a value.

Fixes #9345

Change-Id: I97a1289f8cf27567d1a726ebe5ef167c800f357c
Reviewed-on: https://go-review.googlesource.com/1897
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
10 years agoencoding/pem: eliminate allocations for newlines during encoding
Ben Burkert [Sun, 21 Dec 2014 21:31:23 +0000 (13:31 -0800)]
encoding/pem: eliminate allocations for newlines during encoding

benchmark           old MB/s     new MB/s     speedup
BenchmarkEncode     243.20       279.89       1.15x

benchmark           old allocs     new allocs     delta
BenchmarkEncode     1370           4              -99.71%

Change-Id: I3920bcc04b6dd89efa5da89db5594d4434426d74
Reviewed-on: https://go-review.googlesource.com/1924
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoflag: Some idiomatic fixes
Michalis Kargakis [Fri, 19 Dec 2014 16:53:21 +0000 (17:53 +0100)]
flag: Some idiomatic fixes

Make golint a bit happier

Change-Id: I8a14342f3e492e92bf5efa611f9ef91176624031
Reviewed-on: https://go-review.googlesource.com/1891
Reviewed-by: Minux Ma <minux@golang.org>
10 years agonet/http: Fix Range off-by-one error
Jed Denlea [Tue, 16 Dec 2014 08:24:19 +0000 (00:24 -0800)]
net/http: Fix Range off-by-one error

Given a file of size N, a request for "Range: bytes=N-*" should
return a 416 [1].  Currently, it returns a 206 and a body of 0
bytes, with the illegal Content-Range of "bytes N-(N-1)/N" [2].

[1]: RFC 7233, sec 2.1: "If a valid byte-range-set includes at least one
byte-range-spec with a first-byte-pos that is less than the current
length of the representation, [...]".  sec 3.1: "If all of the
preconditions are true, the server supports the Range header field for
the target resource, and the specified range(s) are invalid or
unsatisfiable, the server SHOULD send a 416 (Range Not Satisfiable)
response."

[2]: RFC 7233, sec 4.2: "A Content-Range field value is invalid if it
contains a byte-range-resp that has a last-byte-pos value less than its
first-byte-pos value, [...]"

Fixes #8988

Change-Id: If3e1134e7815f5d361efea01873b29aafe3de817
Reviewed-on: https://go-review.googlesource.com/1862
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agoruntime: fix brk_ signature for plan9
mischief [Mon, 15 Dec 2014 20:55:00 +0000 (12:55 -0800)]
runtime: fix brk_ signature for plan9

with uintptr, the check for < 0 will never succeed in mem_plan9.go's
sbrk() because the brk_ syscall returns -1 on failure. fixes the plan9/amd64 build.

this failed on plan9/amd64 because of the attempt to allocate 136GB in mallocinit(),
which failed. it was just by chance that on plan9/386 allocations never failed.

Change-Id: Ia3059cf5eb752e20d9e60c9619e591b80e8fb03c
Reviewed-on: https://go-review.googlesource.com/1590
Reviewed-by: Anthony Martin <ality@pbrane.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
10 years agoimage/draw: fix crash in clip
Dave Cheney [Sat, 20 Dec 2014 05:57:02 +0000 (16:57 +1100)]
image/draw: fix crash in clip

Fixes #9177

Change-Id: I1c7e57f0f0a9b00fb3ddc7fa4844ac53ea6df46f
Reviewed-on: https://go-review.googlesource.com/1876
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agonet/http: make Client.Timeout return net.Error errors indicating timeout
Brad Fitzpatrick [Sat, 20 Dec 2014 04:46:09 +0000 (15:46 +1100)]
net/http: make Client.Timeout return net.Error errors indicating timeout

Co-hacking with Dave Cheney.

Fixes #9405

Change-Id: I14fc3b6a47dcdb5e514e93d062b804bb24e89f47
Reviewed-on: https://go-review.googlesource.com/1875
Reviewed-by: Dave Cheney <dave@cheney.net>
10 years agomisc/cgo/test: skip test7978 when using gccgo
Ian Lance Taylor [Sat, 20 Dec 2014 02:17:02 +0000 (18:17 -0800)]
misc/cgo/test: skip test7978 when using gccgo

Gccgo can only get a backtrace for the currently running thread, which
means that it can only get a backtrace for goroutines currently running
Go code.  When a goroutine is running C code, gccgo has no way to stop
it and get the backtrace.  This test is all about getting a backtrace
of goroutines running C code, so it can't work for gccgo.

Change-Id: I2dff4403841fb544da7396562ab1193875fc14c3
Reviewed-on: https://go-review.googlesource.com/1904
Reviewed-by: Minux Ma <minux@golang.org>
10 years agomisc/cgo/test/backdoor: add gc build tag for thunk.s
Ian Lance Taylor [Sat, 20 Dec 2014 01:38:46 +0000 (17:38 -0800)]
misc/cgo/test/backdoor: add gc build tag for thunk.s

Change-Id: I6be5f610af5c56131a9d887569919372bab1d02c
Reviewed-on: https://go-review.googlesource.com/1903
Reviewed-by: Minux Ma <minux@golang.org>
10 years agocmd/cgo: don't #include cgo_export.h in gccgo _cgo_main.c
Ian Lance Taylor [Sat, 20 Dec 2014 01:21:14 +0000 (17:21 -0800)]
cmd/cgo: don't #include cgo_export.h in gccgo _cgo_main.c

Instead of relying on the asm names declared in the gccgo version of
cgo_export.h, just emit a dummy symbol with the right asm name.  This
is enough to let the _cgo_main link succeed, which is all that matters
here.

Fixes #9294.

Change-Id: I803990705b6b226ed0adf17dc57b58a9f501b213
Reviewed-on: https://go-review.googlesource.com/1901
Reviewed-by: Minux Ma <minux@golang.org>
10 years agotesting: style change: omit unnecessary new
Ian Lance Taylor [Sat, 20 Dec 2014 01:31:16 +0000 (17:31 -0800)]
testing: style change: omit unnecessary new

This was brought to my attention because a user thought that because
the file was named "example.go" it served as an example of good coding
practice.  It's not an example, of course, but may as well use a more
idiomatic style anyhow.

Change-Id: I7aa720f603f09f7d597fb7536dbf46ef09144e28
Reviewed-on: https://go-review.googlesource.com/1902
Reviewed-by: Minux Ma <minux@golang.org>
10 years agosort: deduplicate inner loop of Stable
Josh Bleecher Snyder [Thu, 18 Dec 2014 21:22:53 +0000 (13:22 -0800)]
sort: deduplicate inner loop of Stable

benchmark                   old ns/op      new ns/op      delta
BenchmarkStableInt1K        117212         116287         -0.79%
BenchmarkStableInt64K       9632002        9587872        -0.46%
BenchmarkStable1e4          40044309       39865644       -0.45%
BenchmarkStable1e2          126985         126456         -0.42%
BenchmarkStableString1K     389774         391052         +0.33%
BenchmarkStable1e6          8183202516     8157693442     -0.31%

Change-Id: I14e518ad49ecce3d1fc2b056e1acd5e5a2de8144
Reviewed-on: https://go-review.googlesource.com/1821
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
10 years agodoc: fix typo in gccgo contribute
Emil Hessman [Fri, 19 Dec 2014 07:37:52 +0000 (08:37 +0100)]
doc: fix typo in gccgo contribute

Change-Id: Ib9699fc9c45f61e9d75e9d9ae69167f039a66dfc
Reviewed-on: https://go-review.googlesource.com/1890
Reviewed-by: Minux Ma <minux@golang.org>