]> Cypherpunks repositories - gostls13.git/log
gostls13.git
12 years agoio/ioutil: fix Discard data race
Brad Fitzpatrick [Fri, 28 Dec 2012 17:33:22 +0000 (09:33 -0800)]
io/ioutil: fix Discard data race

Fixes #4589

R=golang-dev, iant, dvyukov
CC=golang-dev
https://golang.org/cl/7011047

12 years agoruntime: fix potential crash in sigqueue
Dmitriy Vyukov [Fri, 28 Dec 2012 11:36:06 +0000 (15:36 +0400)]
runtime: fix potential crash in sigqueue
Fixes #4383.

R=golang-dev, minux.ma, rsc, iant
CC=golang-dev
https://golang.org/cl/6996060

12 years agonet: consolidate fd_{free,net,open}bsd.go into fd_bsd.go
Dave Cheney [Fri, 28 Dec 2012 10:01:52 +0000 (21:01 +1100)]
net: consolidate fd_{free,net,open}bsd.go into fd_bsd.go

These files are identical, so probably pre date // +build.

With a little work, fd_darwin could be merged as well.

R=mikioh.mikioh, jsing, devon.odell, lucio.dere, minux.ma
CC=golang-dev
https://golang.org/cl/7004053

12 years agocmd/ld: fix valgrind warning in strnput
Dave Cheney [Fri, 28 Dec 2012 04:32:24 +0000 (15:32 +1100)]
cmd/ld: fix valgrind warning in strnput

Fixes #4592.

Thanks to minux for the suggestion.

R=minux.ma, iant
CC=golang-dev
https://golang.org/cl/7017048

12 years agoreflect: declare slice as *[]unsafe.Pointer instead of *[]byte
Jan Ziak [Thu, 27 Dec 2012 18:35:04 +0000 (02:35 +0800)]
reflect: declare slice as *[]unsafe.Pointer instead of *[]byte

The new garbage collector (CL 6114046) may find the fake *[]byte value
and interpret its contents as bytes rather than as potential pointers.
This may lead the garbage collector to free memory blocks that
shouldn't be freed.

R=dvyukov, rsc, dave, minux.ma, remyoudompheng, iant
CC=golang-dev
https://golang.org/cl/7000059

12 years agolog/syslog: add stub for Plan 9
Akshat Kumar [Thu, 27 Dec 2012 00:45:03 +0000 (11:45 +1100)]
log/syslog: add stub for Plan 9

Proper local system log semantics still need to be
created for Plan 9. In the meantime, the test suite
(viz., exp/gotype) expects there to be some Go
source for each import path. Thus, here is a stub,
equivalent to syslog_windows, for this purpose.

R=golang-dev, rsc, alex.brainman
CC=golang-dev
https://golang.org/cl/7000062

12 years agoexp/types: some comment fixes
Robert Griesemer [Wed, 26 Dec 2012 22:04:50 +0000 (14:04 -0800)]
exp/types: some comment fixes

R=adonovan, bradfitz
CC=golang-dev
https://golang.org/cl/7018046

12 years agoexp/types: configurable types.Check API
Robert Griesemer [Wed, 26 Dec 2012 20:48:26 +0000 (12:48 -0800)]
exp/types: configurable types.Check API

- added Context type for configuration of type checker
- type check all function and method bodies
- (partial) fixes to shift hinting (still not complete)
- revamped test harness - does not rely on specific position
  representation anymore, just a standard (compiler) error
  message
- lots of bug fixes

R=adonovan, rsc
CC=golang-dev
https://golang.org/cl/6948071

12 years agofmt: update an old comment; fix a typo.
Oling Cat [Tue, 25 Dec 2012 22:54:24 +0000 (14:54 -0800)]
fmt: update an old comment; fix a typo.

R=golang-dev, iant
CC=golang-dev, minux.ma
https://golang.org/cl/6998055

12 years agoruntime: diagnose double wakeup on Note
Dmitriy Vyukov [Mon, 24 Dec 2012 17:06:57 +0000 (21:06 +0400)]
runtime: diagnose double wakeup on Note
Double wakeup is prohibited by the Note interface
and checked in lock_sema.c.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6976054

12 years agoexp/norm: changed API of Iter.
Marcel van Lohuizen [Mon, 24 Dec 2012 15:53:25 +0000 (16:53 +0100)]
exp/norm: changed API of Iter.
Motivations:
 - Simpler UI. Previous API proved a bit awkward for practical purposes.
 - Iter is often used in cases where one want to be able to bail out early.
   The old implementaton had too much look-ahead to be efficient.
Disadvantages:
 - ASCII performance is bad. This is unavoidable for tiny iterations.
   Example is included to show how to work around this.

Description:
Iter now iterates per boundary/segment. It returns a slice of bytes that
either points to the input bytes, the internal decomposition strings,
or the small internal buffer that each iterator has. In many cases, copying
bytes is avoided.
The method Seek was added to support jumping around the input without
having to reinitialize.

Details:
 - Table adjustments: some decompositions exist of multiple segments.
   Decompositions that are of this type are now marked so that Iter can
   handle them separately.
 - The old iterator had a different next function for different normal forms
   that was assigned to a function pointer called by Next.
   The new iterator uses this mechanism to switch between different modes
   for handling different type of input as well.  This greatly improves
   performance for Hangul and ASCII. It is also used for multi-segment
   decompositions.
 - input is now a struct of sting and []byte, instead of an interface.
   This simplifies optimizing the ASCII case.

R=rsc
CC=golang-dev
https://golang.org/cl/6873072

12 years agoexp/locale/collate: include composed characters into the table. This eliminates
Marcel van Lohuizen [Mon, 24 Dec 2012 15:42:29 +0000 (16:42 +0100)]
exp/locale/collate: include composed characters into the table. This eliminates
the need to decompose characters for the majority of cases.  This considerably
speeds up collation while increasing the table size minimally.

To detect non-normalized strings, rather than relying on exp/norm, the table
now includes CCC information. The inclusion of this information does not
increase table size.

DETAILS
 - Raw collation elements are now a struct that includes the CCC, rather
   than a slice of ints.
 - Builder now ensures that NFD and NFC counterparts are included in the table.
   This also fixes a bug for Korean which is responsible for most of the growth
   of the table size.
 - As there is no more normalization step, code should now handle both strings
   and byte slices as input. Introduced source type to facilitate this.

NOTES
 - This change does not handle normalization correctly entirely for contractions.
   This causes a few failures with the regtest. table_test.go contains a few
   uncommented tests that can be enabled once this is fixed.  The easiest is to
   fix this once we have the new norm.Iter.
 - Removed a test cases in table_test that covers cases that are now guaranteed
   to not exist.

R=rsc, mpvl
CC=golang-dev
https://golang.org/cl/6971044

12 years agoruntime/race: make test driver print compilation errors
Dmitriy Vyukov [Mon, 24 Dec 2012 11:33:32 +0000 (15:33 +0400)]
runtime/race: make test driver print compilation errors
Currently it silently "succeeds" saying that it run 0 tests
if there are compilations errors.
With this change it fails and outputs the compilation error.

R=golang-dev, remyoudompheng
CC=golang-dev
https://golang.org/cl/7002058

12 years agocmd/gc: fix race instrumentation of unaddressable arrays.
Rémy Oudompheng [Mon, 24 Dec 2012 11:14:41 +0000 (12:14 +0100)]
cmd/gc: fix race instrumentation of unaddressable arrays.

Fixes #4578.

R=dvyukov, golang-dev
CC=golang-dev
https://golang.org/cl/7005050

12 years agodoc/articles/wiki/test.bash: suppress unnecessary output
Shenghou Ma [Sun, 23 Dec 2012 19:48:17 +0000 (03:48 +0800)]
doc/articles/wiki/test.bash: suppress unnecessary output

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7000045

12 years agonet/http: match curl and others' NO_PROXY wildcard handling
Brad Fitzpatrick [Sun, 23 Dec 2012 01:41:00 +0000 (17:41 -0800)]
net/http: match curl and others' NO_PROXY wildcard handling

NO_PROXY="example.com" should match "foo.example.com", just
the same as NO_PROXY=".example.com".  This is what curl and
Python do.

Fixes #4574

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7005049

12 years agoruntime: zero d.free field
Russ Cox [Sat, 22 Dec 2012 23:23:26 +0000 (18:23 -0500)]
runtime: zero d.free field

Not programming in Go anymore:
have to clear fields in local variables.

R=ken2
CC=golang-dev
https://golang.org/cl/7002053

12 years agoruntime/debug: document that Stack is deprecated
Russ Cox [Sat, 22 Dec 2012 22:23:50 +0000 (17:23 -0500)]
runtime/debug: document that Stack is deprecated

Fixes #4070.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7004050

12 years agocmd/gc: add diagnostic for var, type, const named init
Russ Cox [Sat, 22 Dec 2012 22:23:33 +0000 (17:23 -0500)]
cmd/gc: add diagnostic for var, type, const named init

Before this CL, defining the variable worked fine, but then when
the implicit package-level init func was created, that caused a
name collision and a confusing error about the redeclaration.

Also add a test for issue 3705 (func init() needs body).

Fixes #4517.

R=ken2
CC=golang-dev
https://golang.org/cl/7008045

12 years agocmd/go: remove debugging flag introduced in CL 6996054
Russ Cox [Sat, 22 Dec 2012 22:04:56 +0000 (17:04 -0500)]
cmd/go: remove debugging flag introduced in CL 6996054

R=remyoudompheng
CC=golang-dev
https://golang.org/cl/7002052

12 years agocmd/gc: make forward declaration in pure Go package an error
Russ Cox [Sat, 22 Dec 2012 21:46:46 +0000 (16:46 -0500)]
cmd/gc: make forward declaration in pure Go package an error

An error during the compilation can be more precise
than an error at link time.

For 'func init', the error happens always: you can't forward
declare an init func because the name gets mangled.

For other funcs, the error happens only with the special
(and never used by hand) -= flag, which tells 6g the
package is pure go.

The go command now passes -= for pure Go packages.

Fixes #3705.

R=ken2
CC=golang-dev
https://golang.org/cl/6996054

12 years agocmd/gc: fix eval order in select
Russ Cox [Sat, 22 Dec 2012 21:46:01 +0000 (16:46 -0500)]
cmd/gc: fix eval order in select

Ordinary variable load was assumed to be not worth saving,
but not if one of the function calls later might change
its value.

Fixes #4313.

R=ken2
CC=golang-dev
https://golang.org/cl/6997047

12 years agocmd/yacc: fix debug print of token name
Russ Cox [Sat, 22 Dec 2012 21:45:35 +0000 (16:45 -0500)]
cmd/yacc: fix debug print of token name

The array skips the first TOKSTART entries.

Fixes #4410.

R=golang-dev, ken2, ken
CC=golang-dev
https://golang.org/cl/6999054

12 years agoruntime: coalesce 0-size allocations
Russ Cox [Sat, 22 Dec 2012 21:42:22 +0000 (16:42 -0500)]
runtime: coalesce 0-size allocations

Fixes #3996.

R=ken2
CC=golang-dev
https://golang.org/cl/7001052

12 years agoruntime: ignore failure from madvise
Russ Cox [Sat, 22 Dec 2012 20:06:28 +0000 (15:06 -0500)]
runtime: ignore failure from madvise

When we release memory to the OS, if the OS doesn't want us
to release it (for example, because the program executed
mlockall(MCL_FUTURE)), madvise will fail. Ignore the failure
instead of crashing.

Fixes #3435.

R=ken2
CC=golang-dev
https://golang.org/cl/6998052

12 years agoruntime: aggregate defer allocations
Russ Cox [Sat, 22 Dec 2012 19:54:39 +0000 (14:54 -0500)]
runtime: aggregate defer allocations

benchmark             old ns/op    new ns/op    delta
BenchmarkDefer              165          113  -31.52%
BenchmarkDefer10            155          103  -33.55%
BenchmarkDeferMany          216          158  -26.85%

benchmark            old allocs   new allocs    delta
BenchmarkDefer                1            0  -100.00%
BenchmarkDefer10              1            0  -100.00%
BenchmarkDeferMany            1            0  -100.00%

benchmark             old bytes    new bytes    delta
BenchmarkDefer               64            0  -100.00%
BenchmarkDefer10             64            0  -100.00%
BenchmarkDeferMany           64           66    3.12%

Fixes #2364.

R=ken2
CC=golang-dev
https://golang.org/cl/7001051

12 years agomisc/benchcmp: show byte allocation statistics
Shenghou Ma [Sat, 22 Dec 2012 19:51:16 +0000 (14:51 -0500)]
misc/benchcmp: show byte allocation statistics

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6971048

12 years agotesting: fix example test fd leak
Emil Hessman [Sat, 22 Dec 2012 18:41:01 +0000 (13:41 -0500)]
testing: fix example test fd leak

Close the read side of the pipe.
Fixes #4551.

R=rsc
CC=golang-dev
https://golang.org/cl/6962049

12 years agoencoding/json: A JSON tag can be any valid JSON string.
Stéphane Travostino [Sat, 22 Dec 2012 18:36:55 +0000 (13:36 -0500)]
encoding/json: A JSON tag can be any valid JSON string.

Fixes #3887.

R=golang-dev, daniel.morsing, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6997045

12 years agofmt: document width and flags a bit more
Russ Cox [Sat, 22 Dec 2012 18:36:39 +0000 (13:36 -0500)]
fmt: document width and flags a bit more

Fixes #4581.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7000052

12 years agoflag: add implicit boolFlag interface
Rick Arnold [Sat, 22 Dec 2012 18:34:48 +0000 (13:34 -0500)]
flag: add implicit boolFlag interface

Any flag.Value that has an IsBoolFlag method that returns true
will be treated as a bool flag type during parsing.

Fixes #4262.

R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6944064

12 years agocmd/gc: fix wrong interaction between inlining and embedded builtins.
Rémy Oudompheng [Sat, 22 Dec 2012 18:16:31 +0000 (19:16 +0100)]
cmd/gc: fix wrong interaction between inlining and embedded builtins.

The patch makes the compile user an ordinary package-local
symbol for the name of embedded fields of builtin type.

This is incompatible with the fix delivered for issue 2687
(revision 3c060add43fb) but fixes it in a different way, because
the explicit symbol on the field makes the typechecker able to
find it in lookdot.

Fixes #3552.

R=lvd, rsc, daniel.morsing
CC=golang-dev
https://golang.org/cl/6866047

12 years agocmd/gc: do not accept (**T).Method expressions.
Rémy Oudompheng [Sat, 22 Dec 2012 18:13:45 +0000 (19:13 +0100)]
cmd/gc: do not accept (**T).Method expressions.

The typechecking code was doing an extra, unnecessary
indirection.

Fixes #4458.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6998051

12 years agocmd/gc: Reject parenthesised .(type) expressions.
Daniel Morsing [Sat, 22 Dec 2012 16:36:10 +0000 (17:36 +0100)]
cmd/gc: Reject parenthesised .(type) expressions.

Fixes #4470.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6949073

12 years agocmd/6l, cmd/8l: add -Z flag to zero stack frame on entry
Russ Cox [Sat, 22 Dec 2012 16:20:17 +0000 (11:20 -0500)]
cmd/6l, cmd/8l: add -Z flag to zero stack frame on entry

Replacement for GOEXPERIMENT=zerostack, easier to use.
Does not require a separate toolchain.

R=ken2
CC=golang-dev
https://golang.org/cl/6996051

12 years agoundo CL 6938073 / 1542912cf09d
Russ Cox [Sat, 22 Dec 2012 16:18:04 +0000 (11:18 -0500)]
undo CL 6938073 / 1542912cf09d

remove zerostack compiler experiment; will do at link time instead

««« original CL description
cmd/gc: add GOEXPERIMENT=zerostack to clear stack on function entry

This is expensive but it might be useful in cases where
people are suffering from false positives during garbage
collection and are willing to trade the CPU time for getting
rid of the false positives.

On the other hand it only eliminates false positives caused
by other function calls, not false positives caused by dead
temporaries stored in the current function call.

The 5g/6g/8g changes were pulled out of the history, from
the last time we needed to do this (to work around a goto bug).
The code in go.h, lex.c, pgen.c is new but tiny.

R=ken2
CC=golang-dev
https://golang.org/cl/6938073
»»»

R=ken2
CC=golang-dev
https://golang.org/cl/7002051

12 years ago regexp: fix index panic in Replace
Erik St. Martin [Sat, 22 Dec 2012 16:14:56 +0000 (11:14 -0500)]
  regexp: fix index panic in Replace

When using subexpressions ($1) as replacements, when they either don't exist or values weren't found causes a panic.
This patch ensures that the match location isn't -1, to prevent out of bounds errors.
Fixes #3816.

R=franciscossouza, rsc
CC=golang-dev
https://golang.org/cl/6931049

12 years agoA+C: Erik St. Martin (individual CLA)
Russ Cox [Sat, 22 Dec 2012 16:13:25 +0000 (11:13 -0500)]
A+C: Erik St. Martin (individual CLA)

Generated by addca.

R=gobot
CC=golang-dev
https://golang.org/cl/7007051

12 years agocrypto/des: add an example to demonstrate EDE2 operation.
Adam Langley [Sat, 22 Dec 2012 15:50:11 +0000 (10:50 -0500)]
crypto/des: add an example to demonstrate EDE2 operation.

EDE2 is a rare DES mode that can be implemented with crypto/des, but
it's somewhat non-obvious so this CL adds an example of doing so.

Fixes #3537.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6721056

12 years agoencoding/gob: document that structs only encode/decode exported fields
Russ Cox [Sat, 22 Dec 2012 15:43:47 +0000 (10:43 -0500)]
encoding/gob: document that structs only encode/decode exported fields

Fixes #4579.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7000051

12 years agocmd/gc: fix error line in switch expr eval
Russ Cox [Sat, 22 Dec 2012 15:01:15 +0000 (10:01 -0500)]
cmd/gc: fix error line in switch expr eval

Fixes #4562.

R=ken2
CC=golang-dev
https://golang.org/cl/7008044

12 years agoencoding/xml: Marshal ",any" fields
Chris Jones [Sat, 22 Dec 2012 15:00:36 +0000 (10:00 -0500)]
encoding/xml: Marshal ",any" fields

Fixes #3559.

This makes Marshal handle fields marked ",any" instead of ignoring
them. That makes Marshal more symmetrical with Unmarshal, which seems
to have been a design goal.

Note some test cases were changed, because this patch changes
marshalling behavior. I think the previous behavior was buggy, but
there's still a backward-compatibility question to consider.

R=rsc
CC=golang-dev, n13m3y3r
https://golang.org/cl/6938068

12 years agonet: fix timeout tests
Mikio Hara [Sat, 22 Dec 2012 05:56:02 +0000 (14:56 +0900)]
net: fix timeout tests

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7003049

12 years agocmd/8g: introduce temporaries in byte multiplication.
Rémy Oudompheng [Fri, 21 Dec 2012 22:46:16 +0000 (23:46 +0100)]
cmd/8g: introduce temporaries in byte multiplication.

Also restore the smallintconst case for binary ops.

Fixes #3835.

R=daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6999043

12 years agocmd/5g: avoid temporaries in agen OINDEX
Dave Cheney [Fri, 21 Dec 2012 22:09:31 +0000 (09:09 +1100)]
cmd/5g: avoid temporaries in agen OINDEX

Most benchmarks are within the 3% margin of error. This code path is quite common in the fmt package.

linux/arm, Freescale iMX.53 (cortex-a8)

fmt:
benchmark                      old ns/op    new ns/op    delta
BenchmarkSprintfEmpty                925          785  -15.14%
BenchmarkSprintfString              5050         5039   -0.22%
BenchmarkSprintfInt                 4425         4406   -0.43%
BenchmarkSprintfIntInt              5802         5762   -0.69%
BenchmarkSprintfPrefixedInt         7029         6541   -6.94%
BenchmarkSprintfFloat              10278        10083   -1.90%
BenchmarkManyArgs                  18558        17606   -5.13%
BenchmarkScanInts               15592690     15415360   -1.14%
BenchmarkScanRecursiveInt       25155020     25050900   -0.41%

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6921056

12 years agogo/ast: ast.DeclStmt.Decl must be an *ast.GenDecl node (documentation)
Robert Griesemer [Fri, 21 Dec 2012 19:52:21 +0000 (11:52 -0800)]
go/ast: ast.DeclStmt.Decl must be an *ast.GenDecl node (documentation)

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6996046

12 years agomisc/pprof: don't look for browser in current directory.
Rémy Oudompheng [Fri, 21 Dec 2012 19:40:44 +0000 (20:40 +0100)]
misc/pprof: don't look for browser in current directory.

Taken from upstream pprof.

Fixes #4564.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6952045

12 years agocmd/gc: mapassign2 doesn't exist anymore.
Rémy Oudompheng [Fri, 21 Dec 2012 19:39:30 +0000 (20:39 +0100)]
cmd/gc: mapassign2 doesn't exist anymore.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6997043

12 years agocmd/dist: make GOARM detection better compatible with thumb toolchain
Shenghou Ma [Fri, 21 Dec 2012 18:39:54 +0000 (02:39 +0800)]
cmd/dist: make GOARM detection better compatible with thumb toolchain
Fixes #4557.

R=dave, rsc
CC=golang-dev
https://golang.org/cl/6946078

12 years agoruntime/race: update linux runtime to r170876.
Dmitriy Vyukov [Fri, 21 Dec 2012 15:12:00 +0000 (19:12 +0400)]
runtime/race: update linux runtime to r170876.
This disables checks for limited address space
and unlimited stack. They are not required for Go.
Fixes #4577.

R=golang-dev, iant
CC=golang-dev, kamil.kisiel, minux.ma
https://golang.org/cl/7003045

12 years agocmd/go: improve wording of race detector documentation
Dmitriy Vyukov [Fri, 21 Dec 2012 15:11:10 +0000 (19:11 +0400)]
cmd/go: improve wording of race detector documentation

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7006043

12 years agonet: make unix connection tests more robust
Mikio Hara [Fri, 21 Dec 2012 05:19:33 +0000 (14:19 +0900)]
net: make unix connection tests more robust

Avoids unlink the underlying file before the socket close.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7004044

12 years agoos: remove dead code
Alex Brainman [Fri, 21 Dec 2012 05:02:39 +0000 (16:02 +1100)]
os: remove dead code

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6944066

12 years agonet/http: simplify serve() connection close
Dave Cheney [Fri, 21 Dec 2012 04:14:38 +0000 (15:14 +1100)]
net/http: simplify serve() connection close

Followup to 6971049.

R=bradfitz
CC=golang-dev
https://golang.org/cl/6970049

12 years agocmd/vet: expand printf flags understood by %s and %q.
David Symonds [Fri, 21 Dec 2012 02:48:36 +0000 (13:48 +1100)]
cmd/vet: expand printf flags understood by %s and %q.

Fixes #4580.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7002043

12 years agocmd/gc: remove an incorrect assertion in escape analysis.
Rémy Oudompheng [Thu, 20 Dec 2012 22:27:28 +0000 (23:27 +0100)]
cmd/gc: remove an incorrect assertion in escape analysis.

A fatal error used to happen when escassign-ing a multiple
function return to a single node. However, the situation
naturally appears when using "go f(g())" or "defer f(g())",
because g() is escassign-ed to sink.

Fixes #4529.

R=golang-dev, lvd, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6920060

12 years agogo/doc: don't synthesize code for examples that are not self-contained
Andrew Gerrand [Thu, 20 Dec 2012 20:06:38 +0000 (07:06 +1100)]
go/doc: don't synthesize code for examples that are not self-contained

Fixes #4309.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6974045

12 years agocmd/godoc: redirect for file with trailing /
Andrew Gerrand [Thu, 20 Dec 2012 20:03:00 +0000 (07:03 +1100)]
cmd/godoc: redirect for file with trailing /

Fixes #4543.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6971050

12 years agomath: handle exponent separately in Log2
Russ Cox [Thu, 20 Dec 2012 17:23:27 +0000 (12:23 -0500)]
math: handle exponent separately in Log2

This guarantees that powers of two return exact answers.

We could do a multiprecision approximation for the
rest of the answer too, but this seems like it should be
good enough.

Fixes #4567.

R=golang-dev, iant, remyoudompheng
CC=golang-dev
https://golang.org/cl/6943074

12 years agocgo: enable cgo on openbsd
Joel Sing [Thu, 20 Dec 2012 14:43:19 +0000 (01:43 +1100)]
cgo: enable cgo on openbsd

Enable cgo on OpenBSD.

The OpenBSD ld.so(1) does not currently support PT_TLS sections. Work
around this by fixing up the TCB that has been provided by librthread
and reallocating a TCB with additional space for TLS. Also provide a
wrapper for pthread_create, allowing zeroed TLS to be allocated for
threads created externally to Go.

Joint work with Shenghou Ma (minux).

Requires change 6846064.

Fixes #3205.

R=golang-dev, minux.ma, iant, rsc, iant
CC=golang-dev
https://golang.org/cl/6853059

12 years agocmd/[568]l: do not generate PT_TLS on openbsd
Joel Sing [Thu, 20 Dec 2012 14:27:50 +0000 (01:27 +1100)]
cmd/[568]l: do not generate PT_TLS on openbsd

The OpenBSD ld.so(1) does not currently support PT_TLS and refuses
to load ELF binaries that contain PT_TLS sections. Do not emit PT_TLS
sections - we will handle this appropriately in runtime/cgo instead.

R=golang-dev, minux.ma, iant
CC=golang-dev
https://golang.org/cl/6846064

12 years agonet/http: only call client SetCookie when needed
Joakim Sernbrant [Thu, 20 Dec 2012 00:24:38 +0000 (16:24 -0800)]
net/http: only call client SetCookie when needed

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6968049

12 years agotesting: only capture stdout when running examples
Andrew Gerrand [Wed, 19 Dec 2012 23:48:33 +0000 (10:48 +1100)]
testing: only capture stdout when running examples

Fixes #4550.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6973048

12 years agonet/http: fix server connection leak on Handler's panic(nil)
Brad Fitzpatrick [Wed, 19 Dec 2012 23:39:19 +0000 (15:39 -0800)]
net/http: fix server connection leak on Handler's panic(nil)

If a handler did a panic(nil), the connection was never closed.

Fixes #4050

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6971049

12 years agogo/token: fix data race on FileSet.last
Dave Cheney [Wed, 19 Dec 2012 21:26:24 +0000 (08:26 +1100)]
go/token: fix data race on FileSet.last

Fixes #4345.

Benchmarks are promising,

benchmark         old ns/op    new ns/op    delta
BenchmarkPrint     14716391     14747131   +0.21%

benchmark         old ns/op    new ns/op    delta
BenchmarkParse      8846219      8809343   -0.42%

benchmark          old MB/s     new MB/s  speedup
BenchmarkParse         6.61         6.64    1.00x

Also includes additional tests to improve token.FileSet coverage.

R=dvyukov, gri
CC=golang-dev
https://golang.org/cl/6968044

12 years agogo/token: add test for concurrent use of FileSet.Pos
Dave Cheney [Wed, 19 Dec 2012 00:38:00 +0000 (16:38 -0800)]
go/token: add test for concurrent use of FileSet.Pos

Update #4354.

Add a test to expose the race in the FileSet position cache.

R=dvyukov, gri
CC=fullung, golang-dev
https://golang.org/cl/6940078

12 years agoC: add Shawn Ledbetter (Google CLA)
Andrew Gerrand [Tue, 18 Dec 2012 23:14:05 +0000 (10:14 +1100)]
C: add Shawn Ledbetter (Google CLA)

R=golang-dev, agl, iant
CC=golang-dev
https://golang.org/cl/6955043

12 years agoall: fix typos
Shenghou Ma [Tue, 18 Dec 2012 19:04:09 +0000 (03:04 +0800)]
all: fix typos
caught by https://github.com/lyda/misspell-check.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/6949072

12 years agocmd/go: pass gccgoflags at the end of gccgo command line, warn if user passes the...
Shenghou Ma [Tue, 18 Dec 2012 17:48:09 +0000 (01:48 +0800)]
cmd/go: pass gccgoflags at the end of gccgo command line, warn if user passes the wrong toolchain options

R=iant
CC=golang-dev
https://golang.org/cl/6940082

12 years agoruntime: use "mp" and "gp" instead of "m" and "g" for local variable name to avoid...
Jingcheng Zhang [Tue, 18 Dec 2012 16:30:29 +0000 (00:30 +0800)]
runtime: use "mp" and "gp" instead of "m" and "g" for local variable name to avoid confusion with the global "m" and "g".

R=golang-dev, minux.ma, rsc
CC=bradfitz, golang-dev
https://golang.org/cl/6939064

12 years agoA+C: Eric Milliken (individual CLA)
Adam Langley [Tue, 18 Dec 2012 16:28:40 +0000 (11:28 -0500)]
A+C: Eric Milliken (individual CLA)

Generated by addca.

R=gobot
CC=golang-dev
https://golang.org/cl/6945079

12 years agocmd/5l, cmd/6l, cmd/8l: fix function symbol generation from gcc compiled source code
Shenghou Ma [Tue, 18 Dec 2012 15:17:39 +0000 (23:17 +0800)]
cmd/5l, cmd/6l, cmd/8l: fix function symbol generation from gcc compiled source code
For CL 6853059.

R=jsing, rsc
CC=golang-dev
https://golang.org/cl/6938076

12 years agoruntime: use clock_gettime to get ns resolution for time.now & runtime.nanotime
Shenghou Ma [Tue, 18 Dec 2012 14:57:25 +0000 (22:57 +0800)]
runtime: use clock_gettime to get ns resolution for time.now & runtime.nanotime

For Linux/{386,arm}, FreeBSD/{386,amd64,arm}, NetBSD/{386,amd64}, OpenBSD/{386,amd64}.
Note: our Darwin implementation already has ns resolution.

Linux/386 (Core i7-2600 @ 3.40GHz, kernel 3.5.2-gentoo)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow          110          118   +7.27%

Linux/ARM (ARM Cortex-A8 @ 800MHz, kernel 2.6.32.28 android)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow          625          542  -13.28%

Linux/ARM (ARM Cortex-A9 @ 1GHz, Pandaboard)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow          992          909   -8.37%

FreeBSD 9-REL-p1/amd64 (Dell R610 Server with Xeon X5650 @ 2.67GHz)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow          699          695   -0.57%

FreeBSD 9-REL-p1/amd64 (Atom D525 @ 1.80GHz)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow         1553         1658   +6.76%

OpenBSD/amd64 (Dell E6410 with i5 CPU M 540 @ 2.53GHz)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow         1262         1236   -2.06%

OpenBSD/i386 (Asus eeePC 701 with Intel Celeron M 900MHz - locked to 631MHz)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow         5089         5043   -0.90%

NetBSD/i386 (VMware VM with Core i5 CPU @ 2.7GHz)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow          277          278   +0.36%

NetBSD/amd64 (VMware VM with Core i5 CPU @ 2.7Ghz)
benchmark       old ns/op    new ns/op    delta
BenchmarkNow          103          105   +1.94%

Thanks Maxim Khitrov, Joel Sing, and Dave Cheney for providing benchmark data.

R=jsing, dave, rsc
CC=golang-dev
https://golang.org/cl/6820120

12 years agogo/doc: add "hdr-" prefix to headers generated from package overviews.
David Symonds [Tue, 18 Dec 2012 01:19:04 +0000 (12:19 +1100)]
go/doc: add "hdr-" prefix to headers generated from package overviews.

R=golang-dev, bradfitz, gri
CC=golang-dev
https://golang.org/cl/6935071

12 years agoexp/gotype: disable failing tests and add a few more
Robert Griesemer [Mon, 17 Dec 2012 22:32:46 +0000 (14:32 -0800)]
exp/gotype: disable failing tests and add a few more

R=rsc, alex.brainman
CC=golang-dev
https://golang.org/cl/6948066

12 years agocmd/6g: fix componentgen for funarg structs.
Rémy Oudompheng [Mon, 17 Dec 2012 21:29:43 +0000 (22:29 +0100)]
cmd/6g: fix componentgen for funarg structs.

Fixes #4518.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6932045

12 years agodebug/elf: handle missing shstrndx in core files
Dave Cheney [Mon, 17 Dec 2012 20:58:22 +0000 (07:58 +1100)]
debug/elf: handle missing shstrndx in core files

Fixes #4481.

hello-world-core.gz was generated with a simple hello world c program and core dumped as suggested in the issue.

Also: add support for gz compressed test fixtures.

R=minux.ma, rsc, iant
CC=golang-dev
https://golang.org/cl/6936058

12 years agotime: fix panic with time.Parse(time.StampNano, ... )
Dave Cheney [Mon, 17 Dec 2012 20:52:23 +0000 (07:52 +1100)]
time: fix panic with time.Parse(time.StampNano, ... )

Fixes #4502.

R=rsc
CC=golang-dev
https://golang.org/cl/6949058

12 years agonet/http: fix goroutine leak in error case
Brad Fitzpatrick [Mon, 17 Dec 2012 20:01:00 +0000 (12:01 -0800)]
net/http: fix goroutine leak in error case

Fixes #4531

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6937069

12 years agoexp/types: completed typechecking of parameter passing
Robert Griesemer [Mon, 17 Dec 2012 19:35:59 +0000 (11:35 -0800)]
exp/types: completed typechecking of parameter passing

Details:
- fixed variadic parameter passing and calls of the form f(g())
- fixed implementation of ^x for unsigned constants x
- fixed assignability of untyped booleans
- resolved a few TODOs, various minor fixes
- enabled many more tests (only 6 std packages don't typecheck)

R=rsc
CC=golang-dev
https://golang.org/cl/6930053

12 years agocmd/gc: add GOEXPERIMENT=zerostack to clear stack on function entry
Russ Cox [Mon, 17 Dec 2012 19:32:26 +0000 (14:32 -0500)]
cmd/gc: add GOEXPERIMENT=zerostack to clear stack on function entry

This is expensive but it might be useful in cases where
people are suffering from false positives during garbage
collection and are willing to trade the CPU time for getting
rid of the false positives.

On the other hand it only eliminates false positives caused
by other function calls, not false positives caused by dead
temporaries stored in the current function call.

The 5g/6g/8g changes were pulled out of the history, from
the last time we needed to do this (to work around a goto bug).
The code in go.h, lex.c, pgen.c is new but tiny.

R=ken2
CC=golang-dev
https://golang.org/cl/6938073

12 years agofmt, encoding/gob: fix misuse of Read
Shenghou Ma [Mon, 17 Dec 2012 17:26:48 +0000 (01:26 +0800)]
fmt, encoding/gob: fix misuse of Read
reader.Read() can return both 0,nil and len(buf),err.
To be safe, we use io.ReadFull instead of doing reader.Read directly.

Fixes #3472.

R=bradfitz, rsc, ality
CC=golang-dev
https://golang.org/cl/6285050

12 years agosyscall: lazily populate the environment cache on Plan 9
Anthony Martin [Mon, 17 Dec 2012 16:33:51 +0000 (08:33 -0800)]
syscall: lazily populate the environment cache on Plan 9

This decreases the amount of system calls during the
first call to Getenv. Calling Environ will still read
in all environment variables and populate the cache.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6939048

12 years agocmd/cgo: access errno from void C function
Shenghou Ma [Mon, 17 Dec 2012 16:26:08 +0000 (00:26 +0800)]
cmd/cgo: access errno from void C function
Fixes #3729.

R=rsc
CC=golang-dev
https://golang.org/cl/6938052

12 years agoruntime: implement getenv for Plan 9
Anthony Martin [Mon, 17 Dec 2012 16:07:40 +0000 (11:07 -0500)]
runtime: implement getenv for Plan 9

With this change the runtime can now read GOMAXPROCS, GOGC, etc.

I'm not quite sure how we missed this.

R=seed, lucio.dere, rsc
CC=golang-dev
https://golang.org/cl/6935062

12 years agotest: add "duplicate" struct map key test
Russ Cox [Mon, 17 Dec 2012 16:05:58 +0000 (11:05 -0500)]
test: add "duplicate" struct map key test

Update #4555.

R=gri, iant
CC=golang-dev
https://golang.org/cl/6944059

12 years agonet/smtp: remove data race from TestSendMail.
Rick Arnold [Mon, 17 Dec 2012 15:45:33 +0000 (10:45 -0500)]
net/smtp: remove data race from TestSendMail.

A data race was found in TestSendMail by the race detector.

Fixes #4559.

R=golang-dev, bradfitz, dave, rsc
CC=golang-dev
https://golang.org/cl/6944057

12 years agoos: fix docs for Expand
Shenghou Ma [Mon, 17 Dec 2012 15:37:02 +0000 (23:37 +0800)]
os: fix docs for Expand
there is no concept of “undefined” variables for Expand。

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6946063

12 years agonet/http/pprof: fix doc for /debug/pprof/
Shenghou Ma [Mon, 17 Dec 2012 15:32:08 +0000 (23:32 +0800)]
net/http/pprof: fix doc for /debug/pprof/
Fixes #4548.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6944053

12 years agoapi/next.txt: update
Shenghou Ma [Mon, 17 Dec 2012 15:01:36 +0000 (23:01 +0800)]
api/next.txt: update

R=golang-dev, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/6935061

12 years agosyscall: document that documentation is platform specific
Christopher Nielsen [Mon, 17 Dec 2012 14:50:00 +0000 (22:50 +0800)]
syscall: document that documentation is platform specific

Fixes #4051

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6943063

12 years agocmd/gc: racewalk: fix compiler crash
Dmitriy Vyukov [Mon, 17 Dec 2012 08:55:41 +0000 (12:55 +0400)]
cmd/gc: racewalk: fix compiler crash
The code:
func main() {
        v := make([]int64, 10)
        i := 1
        _ = v[(i*4)/3]
}
crashes compiler with:

Program received signal SIGSEGV, Segmentation fault.
0x000000000043c274 in walkexpr (np=0x7fffffffc9b8, init=0x0) at src/cmd/gc/walk.c:587
587 *init = concat(*init, n->ninit);
(gdb) bt
#0  0x000000000043c274 in walkexpr (np=0x7fffffffc9b8, init=0x0) at src/cmd/gc/walk.c:587
#1  0x0000000000432d15 in copyexpr (n=0x7ffff7f69a48, t=<optimized out>, init=0x0) at src/cmd/gc/subr.c:2020
#2  0x000000000043f281 in walkdiv (init=0x0, np=0x7fffffffca70) at src/cmd/gc/walk.c:2901
#3  walkexpr (np=0x7ffff7f69760, init=0x0) at src/cmd/gc/walk.c:956
#4  0x000000000043d801 in walkexpr (np=0x7ffff7f69bc0, init=0x0) at src/cmd/gc/walk.c:988
#5  0x000000000043cc9b in walkexpr (np=0x7ffff7f69d38, init=0x0) at src/cmd/gc/walk.c:1068
#6  0x000000000043c50b in walkexpr (np=0x7ffff7f69f50, init=0x0) at src/cmd/gc/walk.c:879
#7  0x000000000043c50b in walkexpr (np=0x7ffff7f6a0c8, init=0x0) at src/cmd/gc/walk.c:879
#8  0x0000000000440a53 in walkexprlist (l=0x7ffff7f6a0c8, init=0x0) at src/cmd/gc/walk.c:357
#9  0x000000000043d0bf in walkexpr (np=0x7fffffffd318, init=0x0) at src/cmd/gc/walk.c:566
#10 0x00000000004402bf in vmkcall (fn=<optimized out>, t=0x0, init=0x0, va=0x7fffffffd368) at src/cmd/gc/walk.c:2275
#11 0x000000000044059a in mkcall (name=<optimized out>, t=0x0, init=0x0) at src/cmd/gc/walk.c:2287
#12 0x000000000042862b in callinstr (np=0x7fffffffd4c8, init=0x7fffffffd568, wr=0, skip=<optimized out>) at src/cmd/gc/racewalk.c:478
#13 0x00000000004288b7 in racewalknode (np=0x7ffff7f68108, init=0x7fffffffd568, wr=0, skip=0) at src/cmd/gc/racewalk.c:287
#14 0x0000000000428781 in racewalknode (np=0x7ffff7f65840, init=0x7fffffffd568, wr=0, skip=0) at src/cmd/gc/racewalk.c:302
#15 0x0000000000428abd in racewalklist (l=0x7ffff7f65840, init=0x0) at src/cmd/gc/racewalk.c:97
#16 0x0000000000428d0b in racewalk (fn=0x7ffff7f5f010) at src/cmd/gc/racewalk.c:63
#17 0x0000000000402b9c in compile (fn=0x7ffff7f5f010) at src/cmd/6g/../gc/pgen.c:67
#18 0x0000000000419f86 in funccompile (n=0x7ffff7f5f010, isclosure=0) at src/cmd/gc/dcl.c:1414
#19 0x0000000000424161 in p9main (argc=<optimized out>, argv=<optimized out>) at src/cmd/gc/lex.c:431
#20 0x0000000000401739 in main (argc=<optimized out>, argv=<optimized out>) at src/lib9/main.c:35

The problem is nil init passed to mkcall().

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6940045

12 years agofmt: fix a typo
Oling Cat [Mon, 17 Dec 2012 07:13:12 +0000 (18:13 +1100)]
fmt: fix a typo

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6937065

12 years agoencoding/json: cleanup leftover redundant variables.
Rémy Oudompheng [Mon, 17 Dec 2012 01:34:49 +0000 (02:34 +0100)]
encoding/json: cleanup leftover redundant variables.

Those variables come from ancient times when reflect.Value was
an interface.

R=dave, rsc
CC=golang-dev
https://golang.org/cl/6946059

12 years agonet/smtp: add optional Hello method
Rick Arnold [Mon, 17 Dec 2012 01:19:35 +0000 (20:19 -0500)]
net/smtp: add optional Hello method

Add a Hello method that allows clients to set the server sent in the EHLO/HELO exchange; the default remains localhost.
Based on CL 5555045 by rsc.

Fixes #4219.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6946057

12 years agoruntime: struct Obj in mgc0.c and buffers in scanblock()
Jan Ziak [Mon, 17 Dec 2012 00:32:12 +0000 (19:32 -0500)]
runtime: struct Obj in mgc0.c and buffers in scanblock()

Details:

- This CL is the conceptual skeleton of code found in CL 6114046

- The garbage collector uses struct Obj to specify memory blocks

- scanblock() is putting found memory blocks into an intermediate buffer
  (xbuf) before adding/flushing them to the main work buffer (wbuf)

- The main loop in scanblock() is replaced with a skeleton code that
  in the future will be able to recognize the type of objects and
  thus will improve the garbage collector's precision.
  For now, all objects are simply sequences of pointers so
  the precision of the garbage collector remains unchanged.

- The code plugs .gcdata and .gcbss sections into the garbage collector.
  scanblock() in this CL is unable to make any use of this.

R=rsc, dvyukov, remyoudompheng
CC=dave, golang-dev, minux.ma
https://golang.org/cl/6856121

12 years agocmd/fix: Add keys to printer.Config composite literals.
Christopher Cahoon [Mon, 17 Dec 2012 00:31:59 +0000 (19:31 -0500)]
cmd/fix: Add keys to printer.Config composite literals.

Fixes #4499.

R=rsc
CC=golang-dev
https://golang.org/cl/6931046

12 years agoA+C: Christopher Cahoon (individual CLA)
Russ Cox [Mon, 17 Dec 2012 00:17:50 +0000 (19:17 -0500)]
A+C: Christopher Cahoon (individual CLA)

Generated by addca.

R=gobot
CC=golang-dev
https://golang.org/cl/6947067

12 years agoA+C: Alexander Surma (individual CLA)
Andrew Gerrand [Sun, 16 Dec 2012 22:11:26 +0000 (09:11 +1100)]
A+C: Alexander Surma (individual CLA)

Generated by addca.

R=gobot
CC=golang-dev
https://golang.org/cl/6951043

12 years agonet: change ListenUnixgram signature to return UnixConn instead of UDPConn
Mikio Hara [Sun, 16 Dec 2012 02:51:47 +0000 (11:51 +0900)]
net: change ListenUnixgram signature to return UnixConn instead of UDPConn

This CL breaks Go 1 API compatibility but it doesn't matter because
previous ListenUnixgram doesn't work in any use cases, oops.

The public API change is:
-pkg net, func ListenUnixgram(string, *UnixAddr) (*UDPConn, error)
+pkg net, func ListenUnixgram(string, *UnixAddr) (*UnixConn, error)

Fixes #3875.

R=rsc, golang-dev, dave
CC=golang-dev
https://golang.org/cl/6937059