1
0
mirror of https://github.com/golang/go synced 2024-10-04 10:21:21 -06:00
Commit Graph

13884 Commits

Author SHA1 Message Date
Ian Lance Taylor
4aa521a77d net: use DialTimeout in TestSelfConnect
This avoids problems with systems that take a long time to
find out nothing is listening, while still testing for the
self-connect misfeature since a self-connect should be fast.
With this we may be able to remove the test for non-Linux
systems.

Tested (on GNU/Linux) by editing selfConnect in
tcpsock_posix.go to always return false and verifying that
TestSelfConnect then fails with and without this change.

Idea from Uros Bizjak.

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/39200044
2013-12-27 08:49:47 -08:00
Shawn Smith
d1a9143669 strconv: add tests for FormatBool and AppendBool
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/42480043
2013-12-27 08:40:14 -08:00
Shawn Smith
f485e9859a strconv: remove unused atof32int function
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/44200044
2013-12-27 08:40:03 -08:00
Shawn Smith
4133407061 crypto/cipher: remove unused shift1 function
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/38990045
2013-12-27 08:39:54 -08:00
Brad Fitzpatrick
2ccc9a965b net/http: quiet distracting test spam
Capture log output (and test it while at it),
and quiet unnecessary t.Logf.

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/45850043
2013-12-26 13:03:30 -08:00
Brad Fitzpatrick
1fa0206024 net/http: fix data race in benchmark
Fixes #7006

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/44940044
2013-12-26 12:16:11 -08:00
John Newlin
92b5e16147 net/http: Release reference to chunkWriter's bufio.Writer on hijack
When a connection is hijacked, release the reference to the bufio.Writer
that is used with the chunkWriter.  The chunkWriter is not used after
the connection is hijacked.

Also add a test to check that double Hijack calls do something sensible.

benchmark                old ns/op    new ns/op    delta
BenchmarkServerHijack        24137        20629  -14.53%

benchmark               old allocs   new allocs    delta
BenchmarkServerHijack           21           19   -9.52%

benchmark                old bytes    new bytes    delta
BenchmarkServerHijack        11774         9667  -17.90%

R=bradfitz, dave, chris.cahoon
CC=golang-codereviews
https://golang.org/cl/39440044
2013-12-26 11:52:14 -08:00
Marko Tiikkaja
0d12e24ebb database/sql: Use all connections in pool
The last connection in the pool was not being handed out correctly.

R=golang-codereviews, gobot, bradfitz
CC=golang-codereviews
https://golang.org/cl/40410043
2013-12-26 11:27:18 -08:00
Ian Lance Taylor
59583b09f3 runtime/cgo: include <signal.h> to fix build
R=golang-codereviews
TBR=dfc
CC=golang-codereviews
https://golang.org/cl/43120044
2013-12-24 08:24:32 -08:00
Ian Lance Taylor
699dbb60b7 runtime/cgo: always set signal mask before calling pthread_create
This was done correctly for most targets but was missing from
FreeBSD/ARM and Linux/ARM.

R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/45180043
2013-12-24 08:08:15 -08:00
S.Çağlar Onur
41183d015d cgo/runtime: replace sigprocmask with pthread_sigmask.
sigprocmask use in a multithreaded environment is undefined so replace it with pthread_sigmask.

Fixes #6811.

R=jsing, iant
CC=golang-codereviews, golang-dev
https://golang.org/cl/30460043
2013-12-22 08:55:29 -08:00
Shawn Smith
7054890715 bytes, strings: improve Title test coverage by adding cases with underscore and unicode line separator
R=golang-codereviews, gobot, r
CC=golang-codereviews
https://golang.org/cl/42310045
2013-12-20 23:19:32 -08:00
David du Colombier
4237ffe5ea os: reimplement HasPrefix and LastIndex to not depend on strings
R=golang-codereviews, rsc
CC=golang-codereviews, jas
https://golang.org/cl/44790043
2013-12-21 01:22:10 +01:00
Russ Cox
145edc283f cmd/gc: do not compute dead value maps if they will not be used
Reduces 6g big.go memory usage from 251 MB to 242 MB.
Reduces 6g slow.go memory usage from 529 MB to 453 MB.

Mostly a memory savings; 6g slow.go is only about 5% faster.

The test programs are at
https://rsc.googlecode.com/hg/testdata/big.go (36k lines, 276kB)
https://rsc.googlecode.com/hg/testdata/slow.go (7k lines, 352kB)

R=golang-codereviews, bradfitz, iant
CC=golang-codereviews
https://golang.org/cl/42280045
2013-12-20 19:14:42 -05:00
Jakub Ryszard Czarnowicz
57e27a879e net/http: empty contenty-type treated as application/octet-stream
RFC 2616, section 7.2.1 - empty type SHOULD be treated as
application/octet-stream.
Fixes #6616.

R=golang-codereviews, gobot, bradfitz, josharian
CC=golang-codereviews
https://golang.org/cl/31810043
2013-12-20 11:49:42 -08:00
Russ Cox
0e97f4187e cmd/gc: address 1½ liveness bottlenecks
As much as 7x speedup on some programs, cuts all.bash time by 20%.

Change splicebefore function from O(n) to O(1).
The approach was suggested by Carl during the code's review
but apparently did not make it into the tree.
It makes a huge difference on huge programs.

Make twobitwalktype1 slightly faster by using & instead of %.
Really it needs to be cached; left a note to that effect.
(Not a complete fix, hence the ½.)

big.go (output of test/chan/select5.go)
 47.53u   0.50s  48.14r before this CL
  7.09u   0.47s   7.59r with splicebefore change (6.7x speedup)
  6.15u   0.42s   6.59r with twobitwalktype1 change (1.15x speedup; total 7.7x)

slow.go (variant of program in go.text, by mpvl)
 77.75u   2.11s  80.03r before this CL
 24.40u   1.97s  26.44r with splicebefore change (3.2x speedup)
 18.12u   2.19s  20.38r with twobitwalktype1 change (1.35x speedup; total 4.3x)

test/run
150.63u  49.57s  81.08r before this CL
 88.01u  45.60s  46.65r after this CL (1.7x speedup)

all.bash
369.70u 115.64s 256.21r before this CL
298.52u 110.35s 214.67r after this CL (1.24x speedup)

The test programs are at
https://rsc.googlecode.com/hg/testdata/big.go (36k lines, 276kB)
https://rsc.googlecode.com/hg/testdata/slow.go (7k lines, 352kB)

R=golang-codereviews, gobot, r
CC=cshapiro, golang-codereviews
https://golang.org/cl/43210045
2013-12-20 14:24:48 -05:00
Russ Cox
4acb70d377 cmd/gc: bypass DATA instruction for data initialized to integer constant
Eventually we will want to bypass DATA for everything,
but the relocations are not standardized well enough across
architectures to make that possible.

This did not help as much as I expected, but it is definitely better.
It shaves maybe 1-2% off all.bash depending on how much you
trust the timings of a single run:

Before: 241.139r 362.702u 112.967s
After:  234.339r 359.623u 111.045s

R=golang-codereviews, gobot, r, iant
CC=golang-codereviews
https://golang.org/cl/44650043
2013-12-20 14:24:39 -05:00
Rob Pike
dc8572c3fe sync: explain Pool's intentions
Expand the type's doc comment to make its purpose clear
and discourage misuse.

R=golang-codereviews, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/44680043
2013-12-20 11:15:50 -08:00
Brad Fitzpatrick
568a449bd1 io/ioutil: use sync.Pool in Discard
And merge the blackhole.go file back into ioutil,
where it once was. It was only in a separate file
because it used to have race-vs-!race versions.

R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/44060044
2013-12-20 09:38:35 -08:00
Russ Cox
1334b794b7 libmach: remove old object file readers
These no longer work; removing them makes other refactoring easier.
The code for pack P being deleted in this CL does not work either.
I created issue 6989 to track restoring this functionality (probably not
until pack is written in Go).

R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/44300043
2013-12-20 12:10:53 -05:00
Adam Langley
6f149492bf crypto/tls: rework reference tests.
The practice of storing reference connections for testing has worked
reasonably well, but the large blocks of literal data in the .go files
is ugly and updating the tests is a real problem because their number
has grown.

This CL changes the way that reference tests work. It's now possible to
automatically update the tests and the test data is now stored in
testdata/. This should make it easier to implement changes that affect
all connections, like implementing the renegotiation extension.

R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/42060044
2013-12-20 11:37:05 -05:00
Alex A Skinner
487dff1852 net: ParseIP should return nil if :: doesn't expand in an IPv6 address.
Per RFC 4291, 'The use of "::" indicates one or more groups of 16 bits of zeros.'
Fixes #6628

R=golang-dev, rsc, minux.ma, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/15990043
2013-12-20 21:29:28 +09:00
Shenghou Ma
eb7ed0d626 runtime: fix build for OpenBSD
R=golang-dev
CC=golang-dev
https://golang.org/cl/38030045
2013-12-19 21:12:18 -05:00
Shenghou Ma
0097d30c97 runtime: unblock signals when we try to core dump
Fixes #6988.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/44070046
2013-12-19 20:45:05 -05:00
Keith Randall
cbc565a801 reflect: rewrite Value to separate out pointer vs. nonpointer info.
Needed for precise gc and copying stacks.

reflect.Value now takes 4 words instead of 3.

Still to do:
 - un-iword-ify channel ops.
 - un-iword-ify method receivers.

R=golang-dev, iant, rsc, khr
CC=golang-dev
https://golang.org/cl/43040043
2013-12-19 15:15:24 -08:00
Russ Cox
c9f12d2289 liblink: allow either of a pair of conflicting symbols to say dupok
This makes the linker's -X flag work again.

R=iant
CC=bradfitz, golang-codereviews, golang-dev
https://golang.org/cl/44360043
2013-12-19 16:52:47 -05:00
Brad Fitzpatrick
cbf6ff3b90 net/http: add Hihack benchmark
Notably, to show allocs. Currently: 11766 B/op, 21 allocs/op,
at least one alloc of which is in the benchmark loop itself.

R=golang-dev, jnewlin
CC=golang-dev
https://golang.org/cl/40370057
2013-12-19 13:24:42 -08:00
Rémy Oudompheng
e6b023473e runtime: reduce delays in finalizer test.
The runtime tests are executed 4 times in all.bash
and there is currently a 5-second delay each time.

R=golang-dev, minux.ma, khr, bradfitz
CC=golang-dev
https://golang.org/cl/42450043
2013-12-19 21:37:44 +01:00
David du Colombier
16dcef80d4 os: rename only works as part of the same directory on Plan 9
R=golang-dev, lucio.dere, rsc
CC=golang-dev
https://golang.org/cl/44080046
2013-12-19 21:20:03 +01:00
Rob Pike
6f6ff95183 go/build: mention 'tag' as an alias for 'build constraint'
The code is all about tags, and the cmd/go documentation
said to look in the go/build documentation for information
about tags, but the documentation said nothing about tags,
only build constraints. Make things clearer.

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/44100043
2013-12-19 11:43:34 -08:00
Adam Langley
9144ef3321 crypto/x509: import crypto/sha256
Since SHA-256 is now the default hash function, x509 should import it
otherwise some programs may fail because it hasn't been linked in.

R=golang-dev, dave, minux.ma
CC=golang-dev
https://golang.org/cl/44010047
2013-12-19 14:06:28 -05:00
ChaiShushan
0b26ba8af3 cmd/yacc: expr example support windows
1. expr append executable extension.
2. support '\r' character.

Fixes #6851.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/35330043
2013-12-19 12:14:07 -05:00
Joel Sing
0eaabf6452 cmd/ld: make hostobj work on newer openbsd
Make hostobj work on OpenBSD 5.3/5.4/-current - these have PIE
enabled by default and linking fails since the Go linker generates
objects that are neither PIC nor PIE.

Fixes #5067

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7572049
2013-12-20 03:58:27 +11:00
Mikio Hara
efd1d05023 net: rename TestReadConfig to TestDNSReadConfig
To make it possible to type "go test -run=DNS".
Also removes unnecessary parens.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/43470051
2013-12-19 13:02:06 +09:00
Alex Brainman
7f8a5057dd syscall: add NewCallbackCDecl again
Fixes #6338

R=golang-dev, kin.wilson.za, rsc
CC=golang-dev
https://golang.org/cl/36180044
2013-12-19 14:38:50 +11:00
Alex Brainman
f18e2a3271 runtime/pprof: skip tests that fail on windows-amd64-race builder
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/44180043
2013-12-19 14:15:57 +11:00
Brad Fitzpatrick
0594f89489 compress/flate: use io.ByteReader in docs
We did this elsewhere when io.ByteReader was added
but forgot this one.

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/43480052
2013-12-18 18:24:55 -08:00
Keith Randall
2d20c0d625 runtime: mark objects in free lists as allocated and unscannable.
On the plus side, we don't need to change the bits when mallocing
pointerless objects.  On the other hand, we need to mark objects in the
free lists during GC.  But the free lists are small at GC time, so it
should be a net win.

benchmark                    old ns/op    new ns/op    delta
BenchmarkMalloc8                    40           33  -17.65%
BenchmarkMalloc16                   45           38  -15.72%
BenchmarkMallocTypeInfo8            58           59   +0.85%
BenchmarkMallocTypeInfo16           63           64   +1.10%

R=golang-dev, rsc, dvyukov
CC=cshapiro, golang-dev
https://golang.org/cl/41040043
2013-12-18 17:13:59 -08:00
Mikio Hara
7eb45d3c4a net: don't return a nested error when happy eyeballs dialing
Also removes an unused variable.

Fixes #6795.

R=adg, dave, bradfitz, gobot
CC=golang-dev
https://golang.org/cl/29440043
2013-12-19 10:00:15 +09:00
Brad Fitzpatrick
b682f6de5a regexp: use sync.Pool
For machines, not threads.

Update #4720

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/44150043
2013-12-18 16:43:19 -08:00
Russ Cox
4890502af6 liblink: use explicit field for globl duplicate detection
Overloading size leads to problems if clients
try to set up an LSym by hand.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/44140043
2013-12-18 19:36:14 -05:00
Russ Cox
2404b7f168 debug/goobj: expand package prefix correctly
R=r, bradfitz
CC=golang-dev
https://golang.org/cl/43480049
2013-12-18 19:00:52 -05:00
David du Colombier
674606503e syscall: disallow slashes in file names on Plan 9
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/43480050
2013-12-19 00:58:23 +01:00
Brad Fitzpatrick
93e4a9d84c net/http: use sync.Pool
Update #4720

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/44080043
2013-12-18 15:52:20 -08:00
Brad Fitzpatrick
46b4ed2cf0 encoding/json: use sync.Pool
Benchmark is within the noise. I had to run this a dozen times
each before & after (on wall power, without a browser running)
before I could get halfway consistent numbers, and even then
they jumped all over the place, with the new one sometimes
being better. But these are the best of a dozen each.

Slowdown is expected anyway, since I imagine channels are
optimized more.

benchmark                 old ns/op    new ns/op    delta
BenchmarkCodeEncoder       26556987     27291072   +2.76%
BenchmarkEncoderEncode         1069         1071   +0.19%

benchmark                  old MB/s     new MB/s  speedup
BenchmarkCodeEncoder          73.07        71.10    0.97x

benchmark                old allocs   new allocs    delta
BenchmarkEncoderEncode            2            2    0.00%

benchmark                 old bytes    new bytes    delta
BenchmarkEncoderEncode          221          221    0.00%

Update #4720

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/37720047
2013-12-18 15:52:05 -08:00
Dave Cheney
3f6dbfc44c liblink, cmd/gc: resolve several shift warnings
Address several warnings generated by clang -fsanitize=undefined

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/43050043
2013-12-19 10:34:33 +11:00
Shenghou Ma
8606b97690 cmd/go: show testflag help for "go test -h"
Fixes #6576.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/14502065
2013-12-18 17:40:31 -05:00
Mikio Hara
2b3ad827a6 net: add test cases for the both of netgo, cgo DNS lookups
Update #4078

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/14638043
2013-12-19 07:40:10 +09:00
Jakob Borg
2b693b7c19 encoding/asn1: Fix parsing of non-printable strings in
sequences.

Use the same criteria for when to modify the tag type when
parsing a string in a sequence as when parsing a bare string
field.

Fixes #6726.

R=golang-dev, bradfitz, gobot, agl
CC=golang-dev
https://golang.org/cl/22460043
2013-12-18 17:06:17 -05:00
Jeff R. Allen
17dc712c18 math/rand: Float32/64 must only return values in [0,1)
Float32 and Float64 are now both created by taking the ratio
of two integers which are chosen to fit entirely into the
precision of the desired float type. The previous code
could cast a Float64 with more than 23 bits of ".99999"
into a Float32 of 1.0, which is not in [0,1).

Float32 went from 15 to 21 ns/op (but is now correct).

Fixes #6721.

R=golang-dev, iant, rsc
CC=golang-dev
https://golang.org/cl/22730043
2013-12-18 15:38:53 -05:00
ChaiShushan
3d2c4df983 cmd/yacc: gofmt y.go
R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/36950043
2013-12-18 15:17:08 -05:00
Nigel Tao
ff6b922361 image/gif: respect local color table transparency.
Fixes #6441.

R=r
CC=andybons, golang-dev
https://golang.org/cl/13829043
2013-12-18 15:10:40 -05:00
David du Colombier
9607255760 cmd/6g, cmd/gc, cmd/ld: fix Plan 9 amd64 warnings
warning: src/cmd/6g/reg.c:671 format mismatch d VLONG, arg 4
warning: src/cmd/gc/pgen.c:230 set and not used: oldstksize
warning: src/cmd/gc/plive.c:877 format mismatch lx UVLONG, arg 2
warning: src/cmd/gc/walk.c:2878 set and not used: cbv
warning: src/cmd/gc/walk.c:2885 set and not used: hbv
warning: src/cmd/ld/data.c:198 format mismatch s IND FUNC(IND CHAR) INT, arg 2
warning: src/cmd/ld/data.c:230 format mismatch s IND FUNC(IND CHAR) INT, arg 2
warning: src/cmd/ld/dwarf.c:1517 set and not used: pc
warning: src/cmd/ld/elf.c:1507 format mismatch d VLONG, arg 2
warning: src/cmd/ld/ldmacho.c:509 set and not used: dsymtab

R=golang-dev, gobot, rsc
CC=golang-dev
https://golang.org/cl/36740045
2013-12-18 20:20:46 +01:00
David du Colombier
ef0100c7d7 libmach, cmd/8l: fix Plan 9 warnings
warning: src/libmach/sym.c:1861 non-interruptable temporary
warning: src/cmd/8l/../ld/pcln.c:29 set and not used: p

R=golang-dev, gobot, rsc
CC=golang-dev
https://golang.org/cl/40500043
2013-12-18 20:19:59 +01:00
David du Colombier
6e97513012 liblink: fix Plan 9 warnings
warning: src/liblink/asm5.c:485 non-interruptable temporary
warning: src/liblink/asm5.c:565 set and not used: c
warning: src/liblink/asm5.c:622 format mismatch ux VLONG, arg 2
warning: src/liblink/asm5.c:1218 overspecified class: asmout GLOBL STATIC
warning: src/liblink/asm5.c:2088 overspecified class: oprrr GLOBL STATIC
warning: src/liblink/asm5.c:2202 overspecified class: opbra GLOBL STATIC
warning: src/liblink/asm5.c:2237 overspecified class: olr GLOBL STATIC
warning: src/liblink/asm5.c:2266 overspecified class: olhr GLOBL STATIC
warning: src/liblink/asm5.c:2291 overspecified class: osr GLOBL STATIC
warning: src/liblink/asm5.c:2302 overspecified class: oshr GLOBL STATIC
warning: src/liblink/asm5.c:2312 overspecified class: osrr GLOBL STATIC
warning: src/liblink/asm5.c:2319 overspecified class: oshrr GLOBL STATIC
warning: src/liblink/asm5.c:2325 overspecified class: olrr GLOBL STATIC
warning: src/liblink/asm5.c:2332 overspecified class: olhrr GLOBL STATIC
warning: src/liblink/asm5.c:2338 overspecified class: ofsr GLOBL STATIC
warning: src/liblink/asm5.c:2375 overspecified class: omvl GLOBL STATIC
warning: src/liblink/asm8.c:1261 format mismatch d VLONG, arg 3
warning: src/liblink/asm8.c:1274 format mismatch +d VLONG, arg 5
warning: src/liblink/list5.c:153 format mismatch d VLONG, arg 3
warning: src/liblink/list5.c:310 format mismatch d VLONG, arg 3
warning: src/liblink/obj6.c:665 set and not used: q
warning: src/liblink/pcln.c:32 set and not used: p

R=golang-dev, jas, gobot, rsc
CC=golang-dev
https://golang.org/cl/40370043
2013-12-18 20:19:29 +01:00
Brad Fitzpatrick
0f9311811c fmt: use sync.Pool
Update #4720

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/43990043
2013-12-18 11:09:07 -08:00
Brad Fitzpatrick
8c6ef061e3 sync: add Pool type
Adds the Pool type and docs, and use it in fmt.
This is a temporary implementation, until Dmitry
makes it fast.

Uses the API proposal from Russ in http://goo.gl/cCKeb2 but
adds an optional New field, as used in fmt and elsewhere.
Almost all callers want that.

Update #4720

R=golang-dev, rsc, cshapiro, iant, r, dvyukov, khr
CC=golang-dev
https://golang.org/cl/41860043
2013-12-18 11:08:34 -08:00
Ian Lance Taylor
0830f64bf0 liblink: don't search for an import file with an absolute path
This restores the old behaviour, and makes it possible to
continue to use 6g and 6l directly, rather than the go tool,
with dot imports.

R=rsc
CC=golang-dev
https://golang.org/cl/43710043
2013-12-18 10:33:47 -08:00
Russ Cox
f48120ef51 cmd/nm: minor cleanup from previous CL
I forgot to apply Ian's suggestions before submitting CL 40600043.

R=iant
CC=golang-dev
https://golang.org/cl/43560045
2013-12-18 13:29:40 -05:00
Shawn Smith
b758d8703a encoding/csv: remove unused unreadRune function
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/37720046
2013-12-18 13:29:27 -05:00
Shawn Smith
a025e1caac html: add tests for UnescapeString edge cases
R=golang-dev, gobot, bradfitz
CC=golang-dev
https://golang.org/cl/40810044
2013-12-18 10:20:25 -08:00
Shawn Smith
c22e79b37b encoding/asn1: add more test cases for BitString.At and TestUTCTime, add test for ObjectIdentifier.Equal
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/42740043
2013-12-18 10:19:07 -08:00
Shawn Smith
aa20d26292 encoding/json: add test for HTMLEscape
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/38220044
2013-12-18 10:18:35 -08:00
Robert Griesemer
108d35bd8e go/ast: added example illustrating CommentMap use.
R=bradfitz
CC=golang-dev
https://golang.org/cl/43930043
2013-12-18 10:10:40 -08:00
Shawn Smith
9d1832f227 encoding/ascii85: add empty string case for Encode test
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/36830046
2013-12-18 08:33:59 -08:00
Anfernee Yongkun Gui
b3f38b4630 net: test dnsconfig_unix with sample resolv.conf
R=golang-dev, adg, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/21580043
2013-12-18 08:26:36 -08:00
Adam Langley
ca3ff9251d crypto/x509: set default signature hash to SHA256 and allow override.
Previously the hash used when signing an X.509 certificate was fixed
and, for RSA, it was fixed to SHA1. Since Microsoft have announced the
deprecation of SHA1 in X.509 certificates, this change switches the
default to SHA256.

It also allows the hash function to be controlled by the caller by
setting the SignatureAlgorithm field of the template.

[1] http://blogs.technet.com/b/pki/archive/2013/11/12/sha1-deprecation-policy.aspx

Fixes #5302.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/40720047
2013-12-18 10:57:56 -05:00
Josh Bleecher Snyder
4f23481483 crypto/x509: add non-cgo darwin system anchor certs
The set of certs fetched via exec'ing `security` is not quite identical
to the certs fetched via the cgo call. The cgo fetch includes
any trusted root certs that the user may have added; exec does not.
The exec fetch includes an Apple-specific root cert; the cgo fetch
does not. Other than that, they appear to be the same.

Unfortunately, os/exec depends on crypto/x509, via net/http. Break the
circular dependency by moving the exec tests to their own package.

This will not work in iOS; we'll cross that bridge when we get to it.

R=golang-dev, minux.ma, agl
CC=golang-dev
https://golang.org/cl/22020045
2013-12-18 10:57:07 -05:00
Brad Fitzpatrick
626da8d737 encoding/json: speed up decoding
Don't make copies of keys while decoding, and don't use the
expensive strings.EqualFold when it's not necessary. Instead,
note in the existing field cache what algorithm to use to
check fold equality... most keys are just ASCII letters.

benchmark               old ns/op    new ns/op    delta
BenchmarkCodeDecoder    137074314    103974418  -24.15%

benchmark                old MB/s     new MB/s  speedup
BenchmarkCodeDecoder        14.16        18.66    1.32x

Update #6496

R=golang-dev, rsc, adg, r, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/13894045
2013-12-18 07:30:21 -08:00
Andrew Gerrand
9f2b2dfa86 log: fix example (fix build)
R=golang-dev
CC=golang-dev
https://golang.org/cl/43780043
2013-12-18 17:25:23 +11:00
ChaiShushan
8c530becaf log: add example
Fixes #6028.

R=golang-dev, bradfitz, adg, r
CC=golang-dev
https://golang.org/cl/43320043
2013-12-18 16:24:11 +11:00
ChaiShushan
8eb508dd08 flag: remove unused FlagSet.exitOnError field
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/14279043
2013-12-17 23:18:12 -05:00
Mikio Hara
f439e07b1b net: make TestDNSThreadLimit execute at the end of tests
Because TestDNSThreadLimit consumes tons of file descriptors and
makes other tests flaky when CGO_ENABLE=0 or being with netgo tag.

Fixes #6580.

R=golang-dev, bradfitz, adg, minux.ma
CC=golang-dev
https://golang.org/cl/14639044
2013-12-18 13:05:47 +09:00
Shenghou Ma
8ce584c2aa liblink: rewrite '\\' in paths to '/' on windows
At least three Go tests rely on that (log, runtime/{pprof,debug}).

Fixes #6972.
Fixes #6974.
Fixes #6975.

R=alex.brainman, mattn.jp, rsc
CC=golang-dev
https://golang.org/cl/43150043
2013-12-17 22:40:13 -05:00
Alex Brainman
ae9e4db07c runtime: skip broken TestRuntimeGogoBytes on windows
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/43730043
2013-12-18 14:17:47 +11:00
Russ Cox
c86fc68ac6 cmd/go: avoid use of 'go tool pack'
All packages now use the -pack option to the compiler.
For a pure Go package, that's enough.
For a package with additional C and assembly files, the extra
archive entries can be added directly (by concatenation)
instead of by invoking go tool pack.

These changes make it possible to rewrite cmd/pack in Go.

R=iant, r
CC=golang-dev
https://golang.org/cl/42910043
2013-12-17 21:44:36 -05:00
Russ Cox
b2d43caa7a cmd/dist: avoid use of 'go tool pack'
All packages now use the -pack option to the compiler.
For a pure Go package, that's enough.
For a package with additional C and assembly files, the extra
archive entries can be added directly (by concatenation)
instead of by invoking go tool pack.

These changes make it possible to rewrite cmd/pack in Go.

R=iant, r
CC=golang-dev
https://golang.org/cl/42890043
2013-12-17 21:44:18 -05:00
Russ Cox
b022334029 cmd/gc: implement -pack flag
The -pack flag causes 5g, 6g, 8g to write a Go archive directly,
instead of requiring the use of 'go tool pack' to convert the .5/.6/.8
to .a format.

Writing directly avoids the copy and also avoids having the
export data stored twice in the archive (once in __.PKGDEF,
once in .5/.6/.8).

A separate CL will enable the use of this flag by cmd/go.

Other build systems that do not know about -pack will be unaffected.

The changes to cmd/ld handle a minor simplification to the format:
an unused section is removed.

R=iant, r
CC=golang-dev
https://golang.org/cl/42880043
2013-12-17 21:43:33 -05:00
Keith Randall
deb554934c runtime, gc: call interface conversion routines by reference.
Part of getting rid of vararg C calls.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/23310043
2013-12-17 16:55:06 -08:00
David du Colombier
bccf029fc0 net: rewrite toLower more clearly
Rob suggested this change.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/43670044
2013-12-17 16:32:27 -08:00
Keith Randall
9aae6c1a8b runtime: don't store evacuate bit as low bit of hashtable overflow pointer.
Hash tables currently store an evacuated bit in the low bit
of the overflow pointer.  That's probably not sustainable in the
long term as GC wants correctly typed & aligned pointers.  It is
also a pain to move any of this code to Go in the current state.

This change moves the evacuated bit into the tophash entries.

Performance change is negligable.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/14412043
2013-12-17 15:23:31 -08:00
Marko Tiikkaja
ab05a855c6 database/sql: Fix inaccurate comment
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/40370051
2013-12-17 14:53:31 -08:00
Michael Hudson-Doyle
0a6ad46b4f reflect: Add tests for Call with functions taking and returning structs.
gccgo has problems using reflect.Call with functions that take and
return structs with no members.  Prior to fixing that problem there, I
thought it sensible to add some tests of this situation.

Update #6761

First contribution to Go, apologies in advance if I'm doing it wrong.

R=golang-dev, dave, minux.ma, iant, khr, bradfitz
CC=golang-dev
https://golang.org/cl/26570046
2013-12-17 14:49:51 -08:00
Caleb Spare
e9895d92e0 container/list: Add missing period to doc comment for Front
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/38540046
2013-12-17 14:21:11 -08:00
David du Colombier
e87b171013 net: reimplement toLower to not depend on strings
R=golang-dev, r, bradfitz
CC=golang-dev, jas
https://golang.org/cl/43610043
2013-12-17 14:19:11 -08:00
Brad Fitzpatrick
4b76a31c6d runtime: don't crash in SetFinalizer if sizeof *x is zero
And document it explicitly, even though it already said
it wasn't guaranteed.

Fixes #6857

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/43580043
2013-12-17 14:18:58 -08:00
Arne Hormann
a1a3d21355 database/sql: fix typo in comment
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/43300043
2013-12-18 08:17:43 +11:00
Brad Fitzpatrick
ff8e45828c os: avoid a string concat in readdir
R=golang-dev, crawshaw
CC=golang-dev
https://golang.org/cl/37690045
2013-12-17 12:25:32 -08:00
Brad Fitzpatrick
6a1a2170bc os, path/filepath: don't ignore Lstat errors in Readdir
os: don't ignore LStat errors in Readdir. If it's ENOENT,
on the second pass, just treat it as missing. If it's another
error, it's real.

path/filepath: use ReaddirNames instead of Readdir in Walk,
in order to obey the documented WalkFunc contract of returning
each walked item's LStat error, if any.

Fixes #6656
Fixes #6680

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/43530043
2013-12-17 12:19:01 -08:00
Julien Schmidt
762a9d934e database/sql: fix auto-reconnect in prepared statements
This also fixes several connection leaks.
Fixes #5718

R=bradfitz, adg
CC=alberto.garcia.hierro, golang-dev
https://golang.org/cl/14920046
2013-12-17 11:57:30 -08:00
Rob Pike
a075fdbaa6 image: roll back 13239051 (add RGB and RGB48)
They cause too much bloat in the internals as we find ourselves adding
special case code for all the cross-connections. It's better to use RGBA
and just max out the alpha. We lose a little memory but reduce the number
of special cases the encoders, decoders, and drawers need to provide.

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/42910045
2013-12-17 10:49:45 -08:00
David du Colombier
2784a3ea85 ld: fix Plan 9 build
R=golang-dev, jas, bradfitz
CC=golang-dev
https://golang.org/cl/43420043
2013-12-17 08:46:07 -08:00
ChaiShushan
64379b854f all: add missing copyright
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/43290043
2013-12-17 06:52:32 -08:00
Shenghou Ma
d35b22d128 cmd/ld: maintain correct headstring needed by windows port.
Fixes build for go_bootstrap.
Fixes #6971.

R=alex.brainman, mattn.jp, rsc
CC=golang-dev
https://golang.org/cl/43130043
2013-12-17 07:36:01 -05:00
Dmitriy Vyukov
d24019f0fe race.bat: set exit status
R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/43340043
2013-12-17 15:09:42 +04:00
Dmitriy Vyukov
830f9ac030 race.bat: fix env setup
Currently it fails as:
go tool dist: $GOROOT is not set correctly or not exported
GOROOT=c:\go
c:\go\include\u.h does not exist
Fail.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/42550044
2013-12-17 12:59:13 +04:00
Shenghou Ma
98f16ad112 time: fix test error in Chinese edition of Windows
On the Chinese Windows XP system that I'm using, GetTimeZoneInformation returns a struct containing "中国标准时间" (China Standard Time in Chinese) in both StandardName and DaylightName (which is correct, because China does not use DST). However, in registry, under key HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\China Standard Time, the key Std and Dlt contain "中国标准时间" (China Standard Time in Chinese) and "中国夏季时间" (China Summer Time in Chinese) respectively. This means that time.toEnglishName() cannot determine the abbreviation for the local timezone (CST) and causes test failures (time.Local is empty)

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/43210043
2013-12-17 02:43:14 -05:00
Josh Bleecher Snyder
4a18e0edd9 math/rand: minor optimization to Perm
Instead of writing out 0..n and then reading it
back, just use i when it is needed.

Wikipedia calls this the "inside-out" implementation:
http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle

This yields identical values to the previous
implementation, given the same seed. (Note that the
output from Example_rand is unchanged.)

2.8 GHz Intel Core i7, results very stable:

benchmark          old ns/op    new ns/op    delta
BenchmarkPerm3           138          136   -1.45%
BenchmarkPerm30          825          803   -2.67%

Stock Raspberry Pi, minimum improvement out of three runs:

benchmark          old ns/op    new ns/op    delta
BenchmarkPerm3          5774         5664   -1.91%
BenchmarkPerm30        32582        29381   -9.82%

R=golang-dev, dave, mtj, adg
CC=golang-dev
https://golang.org/cl/21030043
2013-12-17 13:49:34 +11:00
Andrew Gerrand
1561230ca0 cmd/go: set GOROOT when testing "go install cmd/fix"
This particular test would never pass unless you had GOROOT set in your
environment. This changes makes the test use the baked-in GOROOT, as it
does with GOOS and GOARCH.

R=golang-dev, dave, iant
CC=golang-dev
https://golang.org/cl/43080043
2013-12-17 12:17:56 +11:00
Shenghou Ma
f85ba7d50a cmd/gc: fix comparison order of parameters in mpcmpfltc(a, b)
It should compare a - b to 0, not b - a to 0.
Fixes #6964.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/39020044
2013-12-16 16:54:10 -05:00
Marko Tiikkaja
1f20ab1116 database/sql: Check errors in QueryRow.Scan
The previous coding did not correctly check for errors from the driver's
Next() or Close(), which could mask genuine errors from the database, as
witnessed in issue #6651.

Even after this change errors from Close() will be ignored if the query
returned no rows (as Rows.Next will have closed the handle already), but it
is a lot easier for the drivers to guard against that.

Fixes #6651.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/41590043
2013-12-16 12:48:35 -08:00
David du Colombier
20dee338c3 net: lookup protocol in lower-case on Plan 9
Protocol keywords are case-insensitive,
but the Ndb database is case-sensitive.

Also use the generic net protocol instead
of tcp in lookupHost.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/40600047
2013-12-16 12:00:23 -08:00
Daniel Lidén
4e23b69314 strings: Add example function for IndexAny
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/42310044
2013-12-16 10:50:56 -08:00
Robin Eklind
ab9b2ae38c strings: Add IndexFunc example
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/42370043
2013-12-16 10:44:23 -08:00
Robin Eklind
7b53e32e0b strings: Update Trim example.
Use an input which better shows that behaviour of the function. Only leading
and trailing runes are trimed, not intermediate ones.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/42390043
2013-12-16 10:40:28 -08:00
Russ Cox
a392cf4fd3 runtime: fix test
Was supposed to be in the nm CL.

TBR=r
CC=golang-dev
https://golang.org/cl/42870043
2013-12-16 12:59:30 -05:00
Russ Cox
08b846b129 debug/goobj: add package for reading new Go object files
R=golang-dev, r, iant
CC=golang-dev
https://golang.org/cl/40610043
2013-12-16 12:52:21 -05:00
Russ Cox
500547f28b cmd/nm: reimplement in Go
The immediate goal is to support the new object file format,
which libmach (nm's support library) does not understand.
Rather than add code to libmach or reengineer liblink to
support this new use, just write it in Go.

The C version of nm reads the Plan 9 symbol table stored in
Go binaries, now otherwise unused.

This reimplementation uses the standard symbol table for
the corresponding file format instead, bringing us one step
closer to removing the Plan 9 symbol table from Go binaries.

Tell cmd/dist not to build cmd/nm anymore.
Tell cmd/go to install cmd/nm in the tool directory.

R=golang-dev, r, iant, alex.brainman
CC=golang-dev
https://golang.org/cl/40600043
2013-12-16 12:52:11 -05:00
Russ Cox
a9f6db58ce cmd/ld: move instruction selection + layout into compilers, assemblers
- new object file reader/writer (liblink/objfile.c)
- remove old object file writing routines
- add pcdata iterator
- remove all trace of "line number stack" and "path fragments" from
  object files, linker (!!!)
- dwarf now writes a single "compilation unit" instead of one per package

This CL disables the check for chains of no-split functions that
could overflow the stack red zone. A future CL will attack the problem
of reenabling that check (issue 6931).

This CL is just the liblink and cmd/ld changes.
There are minor associated adjustments in CL 37030045.
Each depends on the other.

R=golang-dev, dave, iant
CC=golang-dev
https://golang.org/cl/39680043
2013-12-16 12:51:58 -05:00
Russ Cox
870e821ded cmd/cc, cmd/gc: update compilers, assemblers for liblink changes
- add buffered stdout to all tools and provide to link ctxt.
- avoid extra \n before ! in .6 files written by assemblers
  (makes them match the C compilers).
- use linkwriteobj instead of linkouthist+linkwritefuncs.
- in assemblers and C compilers, record pc explicitly in Prog,
  for use by liblink.
- in C compilers, preserve jump target links.
- in Go compilers (gsubr.c) attach gotype directly to
  corresponding LSym* instead of rederiving from instruction stream.
- in Go compilers, emit just one definition for runtime.zerovalue
  from each compilation.

This CL consists entirely of small adjustments.
The heavy lifting is in CL 39680043.
Each depends on the other.

R=golang-dev, dave, iant
CC=golang-dev
https://golang.org/cl/37030045
2013-12-16 12:51:38 -05:00
Robin Eklind
a6ebc88bac strings: Add FieldsFunc example.
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/42360043
2013-12-16 09:43:03 -08:00
Dave Cheney
62baae6e57 unicode/utf16: add explicit test for decoding invalid runes.
The EncodeRune test exercises DecodeRune, but only for runes that it can encode. Add an explicit test for invalid utf16 surrogate pairs.

Bonus: coverage is now 100%

unicode/utf16/utf16.go: IsSurrogate     100.0%
unicode/utf16/utf16.go: DecodeRune      100.0%
unicode/utf16/utf16.go: EncodeRune      100.0%
unicode/utf16/utf16.go: Encode          100.0%
unicode/utf16/utf16.go: Decode          100.0%
total:                  (statements)    100.0%

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/39150044
2013-12-16 12:35:25 +11:00
Dave Cheney
fb31a0b1d0 unicode/utf16: add explicit tests for IsSurrogate
Update #6956

Add tests for IsSurrogate.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/42570043
2013-12-16 11:15:23 +11:00
Adam Langley
1dabd71666 crypto/tls: generate random serial numbers.
NSS (used in Firefox and Chrome) won't accept two certificates with the same
issuer and serial. But this causes problems with self-signed certificates
with a fixed serial number.

This change randomises the serial numbers in the certificates generated by
generate_cert.go.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/38290044
2013-12-15 12:57:57 -05:00
Adam Langley
1d546005af crypto/cipher: fix CFB mode.
a073d65e6f8c had a couple of bugs in the CFB mode that I missed in code review:
        1) The loop condition wasn't updated from the old version.
        2) It wasn't safe when src and dst aliased.

Fixes #6950.

R=golang-dev, hanwen
CC=golang-dev
https://golang.org/cl/42110043
2013-12-15 12:55:59 -05:00
Russ Cox
bc135f6492 runtime: fix crash in runtime.GoroutineProfile
This is a possible Go 1.2.1 candidate.

Fixes #6946.

R=iant, r
CC=golang-dev
https://golang.org/cl/41640043
2013-12-13 15:44:57 -05:00
Shenghou Ma
c134ce272f bytes: fix description of FieldsFunc
Similar to CL 3814041 that fixed the same issue in strings.
Fixes #6941.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/41490045
2013-12-12 22:13:19 -05:00
Ian Lance Taylor
52ecd2ce96 debug/dwarf: remove unused field addrsize from Data
The addrsize field is not a constant for an entire executable
file, and is now handled by the dataFormat interface when
reading the data.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/41620043
2013-12-12 18:55:05 -08:00
Ian Lance Taylor
c0946afb9c reflect: correct function name in panic string
R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/36840045
2013-12-12 18:54:48 -08:00
Richard Musiol
9394629b89 crypto/rc4: fix type errors in pure Go implementation
R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/40540049
2013-12-12 14:32:31 -05:00
Nick Craig-Wood
107d18299c crypto/sha1: Optimise FUNC1 with alternate formulation
According to Wikipedia: http://en.wikipedia.org/wiki/SHA-1
there is an alternate formulation for the FUNC1 transform,
namely

f1 = d xor (b and (c xor d))

instead of

f1 = (b and c) or ((not b) and d)

This reduces the instruction count of FUNC1 from 6 to 4 and
makes about 5% speed improvement on amd64 and suprisingly 17%
on 386.

amd64 Intel(R) Core(TM) i7 CPU Q 820 @ 1.73GHz:

benchmark              old ns/op    new ns/op    delta
BenchmarkHash8Bytes          506          499   -1.38%
BenchmarkHash1K             3099         2961   -4.45%
BenchmarkHash8K            22292        21243   -4.71%

benchmark               old MB/s     new MB/s  speedup
BenchmarkHash8Bytes        15.80        16.00    1.01x
BenchmarkHash1K           330.40       345.82    1.05x
BenchmarkHash8K           367.48       385.63    1.05x

i386 Intel(R) Core(TM) i7 CPU Q 820 @ 1.73GHz:

benchmark              old ns/op    new ns/op    delta
BenchmarkHash8Bytes          647          615   -4.95%
BenchmarkHash1K             3673         3161  -13.94%
BenchmarkHash8K            26141        22374  -14.41%

benchmark               old MB/s     new MB/s  speedup
BenchmarkHash8Bytes        12.35        13.01    1.05x
BenchmarkHash1K           278.74       323.94    1.16x
BenchmarkHash8K           313.37       366.13    1.17x

The improvements on an Intel(R) Core(TM) i7-4770K CPU @
3.50GHz were almost identical.

R=golang-dev, r, hanwen
CC=golang-dev, rsc
https://golang.org/cl/19910043
2013-12-12 11:26:36 -08:00
ChaiShushan
e5902fc70f image: add RGB and RGB48
R=golang-dev, r, nigeltao
CC=golang-dev
https://golang.org/cl/13239051
2013-12-12 11:24:27 -08:00
Han-Wen Nienhuys
b2a198ce39 crypto/cipher: speed up gcmInc32.
The counter is not secret, so the code does not need to be
constant time.

benchmark                    old MB/s     new MB/s  speedup
BenchmarkAESGCMSeal1K           89.90        92.84    1.03x
BenchmarkAESGCMOpen1K           89.16        92.30    1.04x

R=agl
CC=golang-dev
https://golang.org/cl/40690046
2013-12-12 11:25:17 -05:00
Felix Geisendörfer
5ad5b7a551 fmt: Fix signed zero-padding for positive floats
Space padding still has the same issue, I will send a separate patch for that
if this one gets accepted.
Fixes #6856.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/35660043
2013-12-12 06:40:16 -08:00
Josh Bleecher Snyder
563d0b62b8 net, text/tabwriter: use cap arg to make
Changes generated by:

gofmt -w -r 'make(a, b)[0:0] -> make(a, 0, b)' src/pkg

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/24820045
2013-12-12 10:13:17 +04:00
Josh Bleecher Snyder
cf51702bba net: don't leave hostsPath unrestored on error in TestLookupStaticHost
If the return was reached, then hostsPath would not be properly restored
to its original value. See the (lengthy) discussion at
https://golang.org/cl/15960047/

I assume that this is not for Go 1.2; mailing now since I promised to do so.
I will plan to ping once Go 1.2 is out.

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/16200043
2013-12-12 10:12:06 +04:00
Adam Langley
2f43ce7fb0 crypto/x509: fix typo in comment.
Fixes #6633.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/40720046
2013-12-11 17:27:29 -05:00
Han-Wen Nienhuys
5744be9fe4 crypto/cipher: speed up xor operations in CBC, CFB, OBF, CTR
and GCM on 386 and amd64

Intel(R) Core(TM) i5-2540M CPU @ 2.60GHz:

benchmark                    old MB/s     new MB/s  speedup
BenchmarkAESGCMSeal1K           82.39        92.05    1.12x
BenchmarkAESGCMOpen1K           82.28        91.88    1.12x
BenchmarkAESCFBEncrypt1K       141.54       277.59    1.96x
BenchmarkAESCFBDecrypt1K       133.06       278.07    2.09x
BenchmarkAESOFB1K              160.51       380.24    2.37x
BenchmarkAESCTR1K              164.07       429.25    2.62x
BenchmarkAESCBCEncrypt1K       170.99       263.74    1.54x
BenchmarkAESCBCDecrypt1K       124.96       249.14    1.99x

Fixes #6741.

R=agl, dave, agl
CC=golang-dev
https://golang.org/cl/24250044
2013-12-11 16:05:02 -05:00
Russ Cox
426b48a775 cmd/5a, cmd/6a, cmd/8a: fix .y files to match y.tab.[ch]
When I renamed LAddr back to Addr (before sending the
original linker CLs), I missed the .y files in my global substitute.
Since the .y files are only processed when running make in
one of those directories (not during all.bash), they were
behind the generated files.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/40770044
2013-12-11 12:11:37 -05:00
Joel Sing
75800a9a28 crypto/sha256: block implementation in amd64 assembly
Benchmark on Intel(R) Xeon(R) CPU X5650  @ 2.67GHz

benchmark              old ns/op    new ns/op    delta
BenchmarkHash8Bytes         1259          677  -46.23%
BenchmarkHash1K            14387         6749  -53.09%
BenchmarkHash8K           106006        50107  -52.73%

benchmark               old MB/s     new MB/s  speedup
BenchmarkHash8Bytes         6.35        11.81    1.86x
BenchmarkHash1K            71.17       151.72    2.13x
BenchmarkHash8K            77.28       163.49    2.12x

R=agl
CC=golang-dev
https://golang.org/cl/28460043
2013-12-11 11:41:30 -05:00
Shenghou Ma
77fe6befb7 net/http: document that body is closed after (*Request).Write.
Fixes #6911.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/38690043
2013-12-10 23:35:50 -05:00
Carl Shapiro
c69402d82b runtime: remove outdated comment and related indentation
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/39810043
2013-12-10 11:17:43 -08:00
Adam Langley
ddbad5ef20 crypto/x509: fix behaviour of KeyUsageAny.
(Reporter wasn't able to provide a certificate chain that uses this
feature for testing.)

Fixes #6831

R=golang-dev, bradfitz, r
CC=golang-dev
https://golang.org/cl/40340043
2013-12-10 14:06:26 -05:00
David du Colombier
4321beba85 liblink, cmd/gc: fix incompatible type signatures on Plan 9
R=ality, golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/39640043
2013-12-10 08:42:41 -05:00
Joel Sing
517e49eb29 syscall: skip routing messages with mismatched version
Skip routing messages with a mismatched version, rather than failing
and returning EINVAL. Only return EINVAL if we were unable to parse
any of the routing messages (presumably due to a version mismatch).

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/30340043
2013-12-11 00:03:46 +11:00
Alberto García Hierro
c8869e9caf database/sql: Remove redundant condition in if
The final condition (db.maxIdleConnsLocked() > db.freeConn.Len()) can
only be true iff db.maxIdleConnsLocked() is greater than 0, so previously
checking if it's greater than 0 is a waste, specially when that involves
a method call which (ATM) can't be inlined and includes a switch.

Dissasembly follows (test for err == nil has been omitted for clarity):

Before:
43c357: cmp    $0x0,%bl
43c35a: jne    43c3ce <database/sql.(*DB).putConnDBLocked+0x1ce>
43c35c: mov    %rax,(%rsp)
43c360: callq  43aec0 <database/sql.(*DB).maxIdleConnsLocked>
43c365: mov    0x8(%rsp),%rbx
43c36a: cmp    $0x0,%rbx
43c36e: jle    43c3ce <database/sql.(*DB).putConnDBLocked+0x1ce>
43c370: mov    0x30(%rsp),%rbx
43c375: mov    %rbx,(%rsp)
43c379: callq  43aec0 <database/sql.(*DB).maxIdleConnsLocked>
43c37e: mov    0x30(%rsp),%rdx
43c383: mov    0x8(%rsp),%rcx
43c388: mov    0x28(%rdx),%rbp
43c38c: mov    0x28(%rbp),%rbx
43c390: cmp    %rcx,%rbx
43c393: jge    43c3ce <database/sql.(*DB).putConnDBLocked+0x1ce>
43c395: mov    0x28(%rdx),%rbp
43c399: mov    %rbp,(%rsp)
43c39d: mov    0x38(%rsp),%rcx
43c3a2: mov    $0x556c60,%eax
43c3a7: mov    %rax,0x8(%rsp)
43c3ac: mov    %rcx,0x10(%rsp)
43c3b1: callq  4db5b0 <container/list.(*List).PushFront>

After:
43c357: cmp    $0x0,%bl
43c35a: jne    43c3b5 <database/sql.(*DB).putConnDBLocked+0x1b5>
43c35c: mov    %rax,(%rsp)
43c360: callq  43aec0 <database/sql.(*DB).maxIdleConnsLocked>
43c365: mov    0x30(%rsp),%rdx
43c36a: mov    0x8(%rsp),%rcx
43c36f: mov    0x28(%rdx),%rbp
43c373: mov    0x28(%rbp),%rbx
43c377: cmp    %rcx,%rbx
43c37a: jge    43c3b5 <database/sql.(*DB).putConnDBLocked+0x1b5>
43c37c: mov    0x28(%rdx),%rbp
43c380: mov    %rbp,(%rsp)
43c384: mov    0x38(%rsp),%rcx
43c389: mov    $0x556c60,%eax
43c38e: mov    %rax,0x8(%rsp)
43c393: mov    %rcx,0x10(%rsp)
43c398: callq  4db590 <container/list.(*List).PushFront>

R=golang-dev, bradfitz, iant
CC=golang-dev
https://golang.org/cl/14656044
2013-12-10 16:10:09 +04:00
Mikio Hara
e5a7ab8550 net: fix nits found by go tool vet
R=golang-dev, dave, adg
CC=golang-dev
https://golang.org/cl/27430043
2013-12-10 14:30:52 +09:00
Shenghou Ma
a4b66b7703 os: fix build.
CL 36800043 and CL 36930044 have a merge conflict that I overlooked.

R=golang-dev
CC=golang-dev
https://golang.org/cl/39850043
2013-12-09 23:46:21 -05:00
Shenghou Ma
4f2cfdc7f4 crypto/rand: support generation of 2-5 bit primes, also document the error return for Prime
Fixes #6849.
Fixes #6867.

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/35870043
2013-12-09 23:25:49 -05:00
Shenghou Ma
aa0ae7554c os: clarify docs for Rename.
Three changes:
1. mention "move" to clarify things up.
2. use {old,new}path instead of {old,new}name, which makes it clear what
   relative path would do here.
3. mention "OS-specific restrictions might apply".

Fixes #6887.

R=golang-dev, alex.brainman, iant, r
CC=golang-dev
https://golang.org/cl/36930044
2013-12-09 23:25:13 -05:00
Shenghou Ma
46d1461ab7 strconv: add example for Unquote.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/38920043
2013-12-09 23:24:58 -05:00
Carl Shapiro
f574726f16 runtime: check for signed zero in printfloat
Fixes #6899

R=golang-dev, r, cshapiro, iant, rsc
CC=golang-dev
https://golang.org/cl/38120043
2013-12-09 17:51:30 -08:00
Russ Cox
4c01a23cf1 cmd/pack: stop parsing object files to generate __.SYMDEF
Nothing looks at __.SYMDEF, and the object file format is changing.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/39580044
2013-12-09 19:35:17 -05:00
Russ Cox
4230044bb8 runtime: remove non-extern decls of runtime.goarm
The linker is in charge of providing the one true declaration.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/39560043
2013-12-09 19:35:07 -05:00
Alex Brainman
6795687427 cmd/cgo: use __gcc_struct__ for go exported functions
Fixes #6833

R=minux.ma, iant
CC=golang-dev
https://golang.org/cl/35790045
2013-12-10 11:30:12 +11:00
Anthony Martin
52ee63f544 liblink: fix extern register accesses on Plan 9 (386)
R=golang-dev, 0intro, rsc
CC=golang-dev
https://golang.org/cl/39680044
2013-12-09 18:48:44 -05:00
David du Colombier
58005207d2 cmd/8c, cmd/8g, cmd/8l: fix Plan 9 warnings
warning: src/cmd/8c/list.c:124 format mismatch d VLONG, arg 3
warning: src/cmd/8c/list.c:134 format mismatch d VLONG, arg 3
warning: src/cmd/8c/list.c:142 format mismatch d VLONG, arg 3
warning: src/cmd/8c/list.c:152 format mismatch d VLONG, arg 3
warning: src/cmd/8c/list.c:156 format mismatch d VLONG, arg 4
warning: src/cmd/8c/list.c:160 format mismatch d VLONG, arg 4
warning: src/cmd/8c/list.c:165 format mismatch d VLONG, arg 4
warning: src/cmd/8c/list.c:167 format mismatch d VLONG, arg 3
warning: src/cmd/8c/list.c:172 format mismatch d VLONG, arg 4
warning: src/cmd/8c/list.c:174 format mismatch d VLONG, arg 3
warning: src/cmd/8c/list.c:178 format mismatch d VLONG, arg 3
warning: src/cmd/8c/list.c:184 format mismatch d VLONG, arg 3

warning: src/cmd/8g/list.c:91 format mismatch d VLONG, arg 4
warning: src/cmd/8g/list.c:100 format mismatch d VLONG, arg 4
warning: src/cmd/8g/list.c:114 format mismatch d VLONG, arg 5
warning: src/cmd/8g/list.c:118 format mismatch d VLONG, arg 5
warning: src/cmd/8g/list.c:122 format mismatch d VLONG, arg 5
warning: src/cmd/8g/list.c:126 format mismatch d VLONG, arg 5
warning: src/cmd/8g/list.c:136 format mismatch d VLONG, arg 4

warning: src/cmd/8l/list.c:107 format mismatch d VLONG, arg 4
warning: src/cmd/8l/list.c:125 format mismatch ux VLONG, arg 4
warning: src/cmd/8l/list.c:128 format mismatch ux VLONG, arg 4
warning: src/cmd/8l/list.c:130 format mismatch d VLONG, arg 4
warning: src/cmd/8l/list.c:134 format mismatch d VLONG, arg 5
warning: src/cmd/8l/list.c:138 format mismatch d VLONG, arg 6
warning: src/cmd/8l/list.c:143 format mismatch d VLONG, arg 5
warning: src/cmd/8l/list.c:148 format mismatch d VLONG, arg 5
warning: src/cmd/8l/list.c:150 format mismatch d VLONG, arg 4
warning: src/cmd/8l/list.c:154 format mismatch d VLONG, arg 4
warning: src/cmd/8l/list.c:158 format mismatch d VLONG, arg 4
warning: src/cmd/8l/obj.c:132 format mismatch ux VLONG, arg 2

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/39710043
2013-12-09 18:47:22 -05:00
Anthony Martin
274a8e3f56 runtime: do not use memmove in the Plan 9 signal handler
Fixes a regression introduced in revision 4cb93e2900d0.

That revision changed runtime·memmove to use SSE MOVOU
instructions for sizes between 17 and 256 bytes. We were
using memmove to save a copy of the note string during
the note handler. The Plan 9 kernel does not allow the
use of floating point in note handlers (which includes
MOVOU since it touches the XMM registers).

Arguably, runtime·memmove should not be using MOVOU when
GO386=387 but that wouldn't help us on amd64. It's very
important that we guard against any future changes so we
use a simple copy loop instead.

This change is extracted from CL 9796043 (since that CL
is still being ironed out).

R=rsc
CC=golang-dev
https://golang.org/cl/34640045
2013-12-09 18:41:48 -05:00
Anthony Martin
66c32384dd build: do not use the host's libbio on Plan 9
R=jas, lucio.dere, rsc
CC=golang-dev
https://golang.org/cl/14604047
2013-12-09 18:39:58 -05:00
Carl Shapiro
bc9691c465 cmd/gc, runtime: correct a misnomer regarding dead value maps
The funcdata symbol incorrectly named the dead value map the
dead pointer map.  The dead value map identifies all dead
values, including pointers and non-pointers, in a stack frame.
The purpose of this map is to allow the runtime to poison
locations of dead data to catch lost invariants.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/38670043
2013-12-09 14:45:10 -08:00