]> Cypherpunks repositories - gostls13.git/log
gostls13.git
12 years agobytes, strings: add TrimPrefix and TrimSuffix
Brad Fitzpatrick [Fri, 1 Feb 2013 16:41:25 +0000 (08:41 -0800)]
bytes, strings: add TrimPrefix and TrimSuffix

Everybody either gets confused and thinks this is
TrimLeft/TrimRight or does this by hand which gets
repetitive looking.

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

12 years agocmd/6c, cmd/6g: add flag to support large-model code generation
Elias Naur [Fri, 1 Feb 2013 16:35:33 +0000 (08:35 -0800)]
cmd/6c, cmd/6g: add flag to support large-model code generation

Added the -pic flag to 6c and 6g to avoid assembler instructions that
cannot use RIP-relative adressing. This is needed to support the -shared mode
in 6l.

See also:
https://golang.org/cl/6926049
https://golang.org/cl/6822078

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

12 years agoruntime: cgo-related fixes
Russ Cox [Fri, 1 Feb 2013 16:34:41 +0000 (08:34 -0800)]
runtime: cgo-related fixes

* Separate internal and external LockOSThread, for cgo safety.
* Show goroutine that made faulting cgo call.
* Never start a panic due to a signal caused by a cgo call.

Fixes #3774.
Fixes #3775.
Fixes #3797.

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

12 years agocmd/go: clean cgo compiler errors
Russ Cox [Fri, 1 Feb 2013 16:34:21 +0000 (08:34 -0800)]
cmd/go: clean cgo compiler errors

Cut out temporary cgo file in error message.
Show C.foo instead of _Ctype_foo.

Before:
x.go:20[/var/folders/00/05_b8000h01000cxqpysvccm000n9d/T/go-build242036121/command-line-arguments/_obj/x.cgo1.go:19]: cannot use tv.Usec (type int32) as type _Ctype___darwin_suseconds_t in assignment

After:
x.go:20: cannot use tv.Usec (type int32) as type C.__darwin_suseconds_t in assignment

Fixes #4255.

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

12 years agocmd/cgo: fix line number annotations in generated C code
Russ Cox [Fri, 1 Feb 2013 16:34:08 +0000 (08:34 -0800)]
cmd/cgo: fix line number annotations in generated C code

The old version was using go/ast's CommentGroup.Text method,
but that method drops leading blank lines from the result, so that
if the comment looked like one of

//
// syntax error
import "C"

/*
syntax error
*/
import "C"

then the line numbers for the syntax error would be off by the
number of leading blank lines (1 in each of the above cases).

The new text extractor preserves blank lines.

Fixes #4019.

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

12 years agocmd/cgo: document //export preamble restriction
Russ Cox [Fri, 1 Feb 2013 16:33:52 +0000 (08:33 -0800)]
cmd/cgo: document //export preamble restriction

Fixes #3497.

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

12 years agocmd/dist: fix build
Russ Cox [Fri, 1 Feb 2013 06:57:30 +0000 (22:57 -0800)]
cmd/dist: fix build

The Unix and Plan 9 readfile call breset(b) but Windows was not,
leaving dregs in the buffer.

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/7229069

12 years agocmd/dist: redirect acid output to file to separate from errors
Russ Cox [Fri, 1 Feb 2013 06:02:20 +0000 (22:02 -0800)]
cmd/dist: redirect acid output to file to separate from errors

If runtime's proc.c does not compile, cmd/dist used to show
the compile errors in a sea of acid output, making them impossible
to find. Change the command invocation to write the acid output
to a file, so that the errors are the only thing shown on failure.

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

12 years agocmd/8l: fix build
Russ Cox [Fri, 1 Feb 2013 00:13:48 +0000 (16:13 -0800)]
cmd/8l: fix build

TBR=golang-dev
CC=golang-dev
https://golang.org/cl/7241061

12 years agotest: add test that caused a gccgo compilation failure
Ian Lance Taylor [Thu, 31 Jan 2013 23:59:30 +0000 (15:59 -0800)]
test: add test that caused a gccgo compilation failure

Updates #4734.

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

12 years agoexp/cookiejar: remove external storage
Volker Dobler [Thu, 31 Jan 2013 23:56:08 +0000 (10:56 +1100)]
exp/cookiejar: remove external storage

This CL removes the external storage of a cookie jar
and minimized the exported API as discussed in [1].

[1] https://groups.google.com/d/topic/golang-dev/ygDB3nbir00/discussion

Update #1960.

R=nigeltao
CC=golang-dev
https://golang.org/cl/7235065

12 years agoencoding/base64: fix test for ReadFull change
Russ Cox [Thu, 31 Jan 2013 22:42:56 +0000 (14:42 -0800)]
encoding/base64: fix test for ReadFull change

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

12 years agocmd/vet: add missing -all logic
Russ Cox [Thu, 31 Jan 2013 22:37:47 +0000 (14:37 -0800)]
cmd/vet: add missing -all logic

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

12 years agocmd/ld: support for linking with host linker
Russ Cox [Thu, 31 Jan 2013 22:11:32 +0000 (14:11 -0800)]
cmd/ld: support for linking with host linker

A step toward a fix for issue 4069.

To allow linking with arbitrary host object files, add a linker mode
that can generate a host object file instead of an executable.
Then the host linker can be invoked to generate the final executable.

This CL adds a new -hostobj flag that instructs the linker to write
a host object file instead of an executable.

That is, this works:

        go tool 6g x.go
        go tool 6l -hostobj -o x.o x.6
        ld -e _rt0_amd64_linux x.o
        ./a.out

as does:

        go tool 8g x.go
        go tool 8l -hostld ignored -o x.o x.8
        ld -m elf_i386 -e _rt0_386_linux x.o
        ./a.out

Because 5l was never updated to use the standard relocation scheme,
it will take more work to get this working on ARM.

This is a checkpoint of the basic functionality. It does not work
with cgo yet, and cgo is the main reason for the change.
The command-line interface will likely change too.
The gc linker has other information that needs to be returned to
the caller for use when invoking the host linker besides the single
object file.

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

12 years agocmd/vet: check for misplaced and malformed build tags
Russ Cox [Thu, 31 Jan 2013 21:52:27 +0000 (13:52 -0800)]
cmd/vet: check for misplaced and malformed build tags

Fixes #4184.

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

12 years agoio: guarantee err == nil for full reads in ReadFull and ReadAtLeast
Russ Cox [Thu, 31 Jan 2013 21:46:12 +0000 (13:46 -0800)]
io: guarantee err == nil for full reads in ReadFull and ReadAtLeast

This is a backwards compatible API change that fixes broken code.

In Go 1.0, ReadFull(r, buf) could return either len(buf), nil or len(buf), non-nil.
Most code expects only the former, so do that and document the guarantee.

Code that was correct before is still correct.
Code that was incorrect before, by assuming the guarantee, is now correct too.

The same applies to ReadAtLeast.

Fixes #4544.

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

12 years agonet/url: normalize scheme to lower case (http not HTTP)
Russ Cox [Thu, 31 Jan 2013 21:45:43 +0000 (13:45 -0800)]
net/url: normalize scheme to lower case (http not HTTP)

Also document %2f vs / ambiguity in URL.Path.

Fixes #3913.
Fixes #3659.

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

12 years agodoc/codewalk: gofmt pig.go
Russ Cox [Thu, 31 Jan 2013 21:42:26 +0000 (13:42 -0800)]
doc/codewalk: gofmt pig.go

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

12 years agocrypto/x509: test for negative RSA parameters.
Adam Langley [Thu, 31 Jan 2013 17:54:37 +0000 (12:54 -0500)]
crypto/x509: test for negative RSA parameters.

Someone found software that generates negative numbers for the RSA
modulus in an X.509 certificate. Our error messages were very poor in
this case so this change improves that.

Update #4728
Return more helpful errors when RSA parameters are negative or zero.

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

12 years agocmd/go: many bug fixes
Russ Cox [Thu, 31 Jan 2013 16:06:38 +0000 (08:06 -0800)]
cmd/go: many bug fixes

* Reject import paths of the form cmd/x/y.
* Reject 'go install' of command outside GOPATH
* Clearer error rejecting 'go install' of package outside GOPATH.
* Name temporary binary for first file in 'go run' list or for test.
* Provide a way to pass -ldflags arguments with spaces.
* Pass all Go files (even +build ignored ones) to go fix, go fmt, go vet.
* Reject 'go run foo_test.go'.
* Silence 'exit 1' prints from 'go tool' invocations.
* Make go test -xxxprofile leave binary behind for analysis.
* Reject ~ in GOPATH except on Windows.
* Get a little less confused by symlinks.
* Document that go test x y z runs three test binaries.
* Fix go test -timeout=0.
* Add -tags flag to 'go list'.
* Use pkg/gccgo_$GOOS_$GOARCH for gccgo output.

Fixes #3389.
Fixes #3500.
Fixes #3503.
Fixes #3760.
Fixes #3941.
Fixes #4007.
Fixes #4032.
Fixes #4074.
Fixes #4127.
Fixes #4140.
Fixes #4311.
Fixes #4568.
Fixes #4576.
Fixes #4702.

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

12 years agocmd/vet: handle added string constants in printf format check
Russ Cox [Thu, 31 Jan 2013 15:53:38 +0000 (07:53 -0800)]
cmd/vet: handle added string constants in printf format check

Fixes #4599.

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

12 years agoos: use signal strings where possible in ProcessState.String
Russ Cox [Thu, 31 Jan 2013 15:53:18 +0000 (07:53 -0800)]
os: use signal strings where possible in ProcessState.String

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

12 years agocmd/ld: retry short writes, to get error detail
Russ Cox [Thu, 31 Jan 2013 15:49:33 +0000 (07:49 -0800)]
cmd/ld: retry short writes, to get error detail

Fixes #3802.

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

12 years agoencoding/json: document case-insensitive Unmarshal key matching
Russ Cox [Thu, 31 Jan 2013 15:49:23 +0000 (07:49 -0800)]
encoding/json: document case-insensitive Unmarshal key matching

Fixes #4664.

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

12 years agocmd/8l: fix misassembling of MOVB involving (AX)(BX*1)
Rémy Oudompheng [Thu, 31 Jan 2013 07:52:46 +0000 (08:52 +0100)]
cmd/8l: fix misassembling of MOVB involving (AX)(BX*1)

The linker accepts MOVB involving non-byte-addressable
registers, by generating XCHG instructions to AX or BX.
It does not handle the case where nor AX nor BX are available.

See also revision 1470920a2804.

Assembling
    TEXT ·Truc(SB),7,$0
    MOVB BP, (BX)(AX*1)
    RET

gives before:
   08048c60 <main.Truc>:
    8048c60:       87 dd         xchg   %ebx,%ebp
    8048c62:       88 1c 03      mov    %bl,(%ebx,%eax,1)
    8048c65:       87 dd         xchg   %ebx,%ebp
    8048c67:       c3            ret

and after:
   08048c60 <main.Truc>:
    8048c60:       87 cd         xchg   %ecx,%ebp
    8048c62:       88 0c 03      mov    %cl,(%ebx,%eax,1)
    8048c65:       87 cd         xchg   %ecx,%ebp
    8048c67:       c3            ret

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

12 years agocmd/gc: inlining of variadic functions.
Rémy Oudompheng [Thu, 31 Jan 2013 07:40:59 +0000 (08:40 +0100)]
cmd/gc: inlining of variadic functions.

R=rsc, lvd, golang-dev, kardianos
CC=golang-dev
https://golang.org/cl/7093050

12 years agocontainer/heap: split example into two
Caleb Spare [Thu, 31 Jan 2013 07:14:29 +0000 (23:14 -0800)]
container/heap: split example into two

This adds a simple IntHeap example, and modifies the more complex
PriorityQueue example to make use of the index field it maintains.

Fixes #4331.

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

12 years agoos: provide access to file LastAccessTime and CreationTime on windows
Alex Brainman [Thu, 31 Jan 2013 06:17:37 +0000 (17:17 +1100)]
os: provide access to file LastAccessTime and CreationTime on windows

Fixes #4569.

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

12 years agoexp/cookiejar: update PublicSuffixList doc comment to match the
Nigel Tao [Thu, 31 Jan 2013 03:12:43 +0000 (14:12 +1100)]
exp/cookiejar: update PublicSuffixList doc comment to match the
examples at http://publicsuffix.org/.

That website previously listed pvt.k12.wy.us, but that was an error,
as confirmed by correspondance with submissions@publicsuffix.org, and
the website was fixed on 2013-01-23.

R=adg
CC=dr.volker.dobler, golang-dev
https://golang.org/cl/7241053

12 years agofmt: improve go syntax handling of byte-derived arrays and slices
Robert Daniel Kortschak [Thu, 31 Jan 2013 01:53:53 +0000 (17:53 -0800)]
fmt: improve go syntax handling of byte-derived arrays and slices

Fixes #4685.

R=golang-dev, adg, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/7205047

12 years agoencoding/json: improve performance of Unmarshal on primitive types
Rick Arnold [Thu, 31 Jan 2013 01:53:48 +0000 (17:53 -0800)]
encoding/json: improve performance of Unmarshal on primitive types

Attempt 2. The first fix was much faster but ignored syntax errors.

benchmark                      old ns/op    new ns/op    delta
BenchmarkCodeEncoder            74993543     72982390   -2.68%
BenchmarkCodeMarshal            77811181     75610637   -2.83%
BenchmarkCodeDecoder           213337123    190144982  -10.87%
BenchmarkCodeUnmarshal         212180972    190394852  -10.27%
BenchmarkCodeUnmarshalReuse    202113428    182106660   -9.90%
BenchmarkUnmarshalString            1343          919  -31.57%
BenchmarkUnmarshalFloat64           1149          908  -20.97%
BenchmarkUnmarshalInt64              967          778  -19.54%
BenchmarkSkipValue              28851581     28414125   -1.52%

benchmark                       old MB/s     new MB/s  speedup
BenchmarkCodeEncoder               25.88        26.59    1.03x
BenchmarkCodeMarshal               24.94        25.66    1.03x
BenchmarkCodeDecoder                9.10        10.21    1.12x
BenchmarkCodeUnmarshal              9.15        10.19    1.11x
BenchmarkSkipValue                 69.05        70.11    1.02x

Fixes #3949.

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

12 years agoA+C: Robert Daniel Kortschak (individual CLA)
Russ Cox [Thu, 31 Jan 2013 01:53:07 +0000 (17:53 -0800)]
A+C: Robert Daniel Kortschak (individual CLA)

Generated by addca.

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

12 years agomath/big: make tests faster by reducing coverage in --test.short mode.
Alan Donovan [Wed, 30 Jan 2013 23:19:58 +0000 (18:19 -0500)]
math/big: make tests faster by reducing coverage in --test.short mode.

The time to test all of math/big is now:
 default      => ~3min
 --test.short => 150ms

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

12 years agonet/http: fix race
Brad Fitzpatrick [Wed, 30 Jan 2013 23:10:07 +0000 (15:10 -0800)]
net/http: fix race

Fixes #4724

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

12 years agocmd/go: fix build -n for cgo enabled packages
Anthony Martin [Wed, 30 Jan 2013 23:09:34 +0000 (15:09 -0800)]
cmd/go: fix build -n for cgo enabled packages

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

12 years agocmd/gc: support GNU Bison 2.7 in bisonerrors
Anthony Martin [Wed, 30 Jan 2013 23:06:35 +0000 (15:06 -0800)]
cmd/gc: support GNU Bison 2.7 in bisonerrors

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

12 years agocrypto/cipher: avoid out of bounds error in CryptBlocks
Russ Cox [Wed, 30 Jan 2013 20:45:13 +0000 (12:45 -0800)]
crypto/cipher: avoid out of bounds error in CryptBlocks

Fixes #4699.

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

12 years agocmd/godoc: fix buggy use of strings.HasSuffix
Brad Fitzpatrick [Wed, 30 Jan 2013 20:30:26 +0000 (12:30 -0800)]
cmd/godoc: fix buggy use of strings.HasSuffix

This code never worked. Maybe it's not necessary?

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

12 years agoexp/locale/collate/tools/colcmp: fixes some discrepancies between
Marcel van Lohuizen [Wed, 30 Jan 2013 20:19:03 +0000 (21:19 +0100)]
exp/locale/collate/tools/colcmp: fixes some discrepancies between
ICU and collate package: ICU requires strings to be in FCD form.
Not all NFC strings are in this form, leading to incorrect results.
Change to NFD instead.

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

12 years agocmd/gc: fix export data for aggressive inlining.
Rémy Oudompheng [Wed, 30 Jan 2013 20:10:19 +0000 (21:10 +0100)]
cmd/gc: fix export data for aggressive inlining.

Export data was broken after revision 6b602ab487d6
when -l is specified at least 3 times: it makes the compiler
write out func (*T).Method() declarations in export data, which
is not supported.

Also fix the formatting of recover() in export data. It was
not treated like panic() and was rendered as "<node RECOVER>".

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

12 years agocmd/gc: Error out on division by constant zero.
Daniel Morsing [Wed, 30 Jan 2013 19:21:08 +0000 (20:21 +0100)]
cmd/gc: Error out on division by constant zero.

Fixes #4264.

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

12 years agosyscall: handle empty address in ReadFrom better
Jeff R. Allen [Wed, 30 Jan 2013 18:02:01 +0000 (10:02 -0800)]
syscall: handle empty address in ReadFrom better

Handle return values from recvfrom correctly when the
kernel decides to not return an address.

Fixes #4636.
Fixes #4352.

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

12 years agoos: don't hold ForkLock across opens on Plan 9
Akshat Kumar [Wed, 30 Jan 2013 17:41:16 +0000 (09:41 -0800)]
os: don't hold ForkLock across opens on Plan 9

If os.OpenFile holds ForkLock on files that block opens,
then threads that simultaneously try to do fork-exec will
get hung up (until the open succeeds). Blocked opens are
common enough on Plan 9 that protecting against fd leaks
into fork-execs means not being able to do fork-execs
properly in the general case. Thus, we forgo taking the
lock.

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

12 years agonet: SplitHostPort: adjust error message for missing port in IPv6 addresses
Michael Teichgräber [Wed, 30 Jan 2013 17:25:16 +0000 (09:25 -0800)]
net: SplitHostPort: adjust error message for missing port in IPv6 addresses

An hostport of "[::1]" now results in the same error message
"missing port in address" as the hostport value "127.0.0.1",
so SplitHostPort won't complain about "too many colons
in address" anymore for an IPv6 address missing a port.

Added tests checking the error values.

Fixes #4526.

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

12 years agoA+C: Michael Teichgräber (individual CLA)
Russ Cox [Wed, 30 Jan 2013 17:25:10 +0000 (09:25 -0800)]
A+C: Michael Teichgräber (individual CLA)

Generated by addca.

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

12 years agodoc/go1.1.html: document division by zero change from CL 6710045
Russ Cox [Wed, 30 Jan 2013 17:23:36 +0000 (09:23 -0800)]
doc/go1.1.html: document division by zero change from CL 6710045

I am still not convinced this is a change we should make, but at least
documenting it will keep us from forgetting it as we get closer to Go 1.1.

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

12 years agoencoding/json: properly unmarshal empty arrays.
Andrey Mirtchovski [Wed, 30 Jan 2013 17:10:32 +0000 (09:10 -0800)]
encoding/json: properly unmarshal empty arrays.

The JSON unmarshaller failed to allocate an array when there
are no values for the input causing the `[]` unmarshalled
to []interface{} to generate []interface{}(nil) rather than
[]interface{}{}. This wasn't caught in the tests because Decode()
works correctly and because jsonBig never generated zero-sized
arrays. The modification to scanner_test.go quickly triggers
the error:

without the change to decoder.go, but with the change to scanner_test.go:

$ go test
--- FAIL: TestUnmarshalMarshal (0.10 seconds)
decode_test.go:446: Marshal jsonBig
scanner_test.go:206: diverge at 70: «03c1OL6$":null},{"[=» vs «03c1OL6$":[]},{"[=^\»
FAIL
exit status 1
FAIL encoding/json 0.266s

Also added a simple regression to decode_test.go.

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

12 years agocmd/5l: reestablish uniform union field naming
Russ Cox [Wed, 30 Jan 2013 17:10:06 +0000 (09:10 -0800)]
cmd/5l: reestablish uniform union field naming

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

12 years agoruntime: local allocation in mprof.goc
Jan Ziak [Wed, 30 Jan 2013 17:01:31 +0000 (09:01 -0800)]
runtime: local allocation in mprof.goc

Binary data in mprof.goc may prevent the garbage collector from freeing
memory blocks. This patch replaces all calls to runtime·mallocgc() with
calls to an allocator private to mprof.goc, thus making the private
memory invisible to the garbage collector. The addrhash variable is
moved outside of the .bss section.

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

12 years ago6l/5l: PIC and shared library support for the linkers.
Elias Naur [Wed, 30 Jan 2013 16:46:56 +0000 (08:46 -0800)]
6l/5l: PIC and shared library support for the linkers.

Added the -shared flag to 5l/6l to output a PIC executable with the required
dynamic relocations and RIP-relative addressing in machine code.
Added dummy support to 8l to avoid compilation errors

See also:
https://golang.org/cl/6822078
https://golang.org/cl/7064048

and

https://groups.google.com/d/topic/golang-nuts/P05BDjLcQ5k/discussion

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

12 years agocmd/dist: fix code example in README
Russ Cox [Wed, 30 Jan 2013 16:46:50 +0000 (08:46 -0800)]
cmd/dist: fix code example in README

Fixes #4729.

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

12 years agoA+C: Elias Naur (individual CLA)
Russ Cox [Wed, 30 Jan 2013 16:46:40 +0000 (08:46 -0800)]
A+C: Elias Naur (individual CLA)

Generated by addca.

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

12 years agocmd/cgo: allow for stdcall decorated dynimport names
James Gray [Wed, 30 Jan 2013 16:29:33 +0000 (08:29 -0800)]
cmd/cgo: allow for stdcall decorated dynimport names

To allow for stdcall decorated names on Windows, two changes were needed:
1. Change the symbol versioning delimiter '@' in cgo's dynimport output to a '#', and in cmd/ld when it parses dynimports.
2. Remove the "@N" decorator from the first argument of cgo's dynimport output (PE only).

Fixes #4607.

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

12 years agocrypto/rc4: add simple amd64 asm implementation.
Adam Langley [Wed, 30 Jan 2013 16:01:19 +0000 (11:01 -0500)]
crypto/rc4: add simple amd64 asm implementation.

(Although it's still half the speed of OpenSSL.)

benchmark           old ns/op    new ns/op    delta
BenchmarkRC4_128         1409          398  -71.75%
BenchmarkRC4_1K         10920         2898  -73.46%
BenchmarkRC4_8K        131323        23083  -82.42%

benchmark            old MB/s     new MB/s  speedup
BenchmarkRC4_128        90.83       321.43    3.54x
BenchmarkRC4_1K         93.77       353.28    3.77x
BenchmarkRC4_8K         61.65       350.73    5.69x

R=rsc, remyoudompheng
CC=golang-dev, jgrahamc
https://golang.org/cl/7234055

12 years agoencoding/xml: add (*Encoder).Indent
Russ Cox [Wed, 30 Jan 2013 15:57:20 +0000 (07:57 -0800)]
encoding/xml: add (*Encoder).Indent

Exposing this on the Encoder allows streaming generation of indented XML.

R=golang-dev, rogpeppe
CC=golang-dev
https://golang.org/cl/7221075

12 years agocmd/vet: detect misuse of atomic.Add*
Rodrigo Rafael Monti Kochenburger [Wed, 30 Jan 2013 15:57:11 +0000 (07:57 -0800)]
cmd/vet: detect misuse of atomic.Add*

Re-assigning the return value of an atomic operation to the same variable being operated is a common mistake:

x = atomic.AddUint64(&x, 1)

Add this check to go vet.

Fixes #4065.

R=dvyukov, golang-dev, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/7097048

12 years agoinclude: Plan 9: hide any previous definition of Runemax
Akshat Kumar [Wed, 30 Jan 2013 15:56:08 +0000 (07:56 -0800)]
include: Plan 9: hide any previous definition of Runemax

Runemax is already defined in libc on 64-bit version of
Plan 9, but is not defined on other versions.
To accommodate, we make sure to rename any previous
instance of Runemax and re-define it subsequently.

R=rsc, ality, rminnich
CC=golang-dev
https://golang.org/cl/7232059

12 years agoruntime: add support for panic/recover in Plan 9 note handler
Akshat Kumar [Wed, 30 Jan 2013 10:53:56 +0000 (02:53 -0800)]
runtime: add support for panic/recover in Plan 9 note handler

This change also resolves some issues with note handling: we now make
sure that there is enough room at the bottom of every goroutine to
execute the note handler, and the `exitstatus' is no longer a global
entity, which resolves some race conditions.

R=rminnich, npe, rsc, ality
CC=golang-dev
https://golang.org/cl/6569068

12 years agoC: add Hossein Sheikh Attar (Google CLA)
Andrew Gerrand [Wed, 30 Jan 2013 06:26:22 +0000 (17:26 +1100)]
C: add Hossein Sheikh Attar (Google CLA)

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

12 years agoruntime: implement range access functions in race detector.
Rémy Oudompheng [Wed, 30 Jan 2013 00:55:02 +0000 (01:55 +0100)]
runtime: implement range access functions in race detector.

Range access functions are already available in TSan library
but were not yet used.

Time for go test -race -short:

Before:
compress/flate 24.244s
exp/norm       >200s
go/printer     78.268s

After:
compress/flate 17.760s
exp/norm        5.537s
go/printer      5.738s

Fixes #4250.

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

12 years agoA+C: Rodrigo Rafael Monti Kochenburger (individual CLA)
Russ Cox [Tue, 29 Jan 2013 23:26:42 +0000 (15:26 -0800)]
A+C: Rodrigo Rafael Monti Kochenburger (individual CLA)

Generated by addca.

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

12 years agogo/misc/dist: Keep file modes when copying.
Francesc Campoy [Tue, 29 Jan 2013 23:17:39 +0000 (15:17 -0800)]
go/misc/dist: Keep file modes when copying.

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

12 years agogo/build: clean up after rollback
Andrew Gerrand [Tue, 29 Jan 2013 22:10:58 +0000 (09:10 +1100)]
go/build: clean up after rollback

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

12 years agoencoding/json: add test for Unmarshal of malformed data
Russ Cox [Tue, 29 Jan 2013 21:34:18 +0000 (13:34 -0800)]
encoding/json: add test for Unmarshal of malformed data

Roll back CL making primitive type unmarshal faster,
because it broke the Unmarshal of malformed data.

Add benchmarks for unmarshal of primitive types.

Update #3949.

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

12 years agoruntime: clear up lr comments
Russ Cox [Tue, 29 Jan 2013 21:12:50 +0000 (13:12 -0800)]
runtime: clear up lr comments

R=cshapiro
CC=golang-dev
https://golang.org/cl/7230052

12 years agocodereview: show 'not lgtms' in hg p output (with lgtms)
Russ Cox [Tue, 29 Jan 2013 17:32:49 +0000 (09:32 -0800)]
codereview: show 'not lgtms' in hg p output (with lgtms)

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

12 years agocmd/go: add helpful error message when vcs is not found.
Gustavo Franco [Tue, 29 Jan 2013 16:20:43 +0000 (08:20 -0800)]
cmd/go: add helpful error message when vcs is not found.
Fixes #4652.

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

12 years agoexp/ssa: make Parameters values, not addresses.
Alan Donovan [Tue, 29 Jan 2013 15:49:16 +0000 (10:49 -0500)]
exp/ssa: make Parameters values, not addresses.

We explicitly spill all parameters to the frame during initial
SSA construction.  (Later passes will remove spills.)
We now properly handle local Allocs escaping via Captures.

Also: allocate BasicBlock.Succs inline.

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

12 years agoruntime: dump the full stack of a throwing goroutine
Dmitriy Vyukov [Tue, 29 Jan 2013 10:57:11 +0000 (14:57 +0400)]
runtime: dump the full stack of a throwing goroutine
Useful for debugging of runtime bugs.
+ Do not print "stack segment boundary" unless GOTRACEBACK>1.
+ Do not traceback system goroutines unless GOTRACEBACK>1.

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

12 years agogo/misc: Adding go-tour to the generated packages for every distribution.
Francesc Campoy [Tue, 29 Jan 2013 05:46:49 +0000 (21:46 -0800)]
go/misc: Adding go-tour to the generated packages for every distribution.

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

12 years agocmd/gc: document more of the declaration context enumeration
Carl Shapiro [Tue, 29 Jan 2013 00:57:36 +0000 (16:57 -0800)]
cmd/gc: document more of the declaration context enumeration

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

12 years agocmd/api: normalize byte to uint8 and rune to int32
Brad Fitzpatrick [Tue, 29 Jan 2013 00:45:45 +0000 (16:45 -0800)]
cmd/api: normalize byte to uint8 and rune to int32

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

12 years agoencoding/json: add Decoder.Buffered accessor to get overread data
Brad Fitzpatrick [Tue, 29 Jan 2013 00:31:46 +0000 (16:31 -0800)]
encoding/json: add Decoder.Buffered accessor to get overread data

Otherwise it's impossible to know how much data from the
json.Decoder's underlying Reader was actually consumed.

The old fix from golang.org/issue/1955 just added docs. This
provides an actual mechanism.

Update #1955

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

12 years agoexp/ssa: fix breakage due to https://code.google.com/p/go/source/detail?r=ca5e5de48173
Alan Donovan [Tue, 29 Jan 2013 00:21:25 +0000 (19:21 -0500)]
exp/ssa: fix breakage due to https://code.google.com/p/go/source/detail?r=ca5e5de48173

I don't understand why this didn't show up during my testing.

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

12 years agotest: add test case miscompiled by gccgo
Ian Lance Taylor [Tue, 29 Jan 2013 00:17:06 +0000 (16:17 -0800)]
test: add test case miscompiled by gccgo

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

12 years agocmd/ld: avoid a segfault when dumping the symbol table
Carl Shapiro [Mon, 28 Jan 2013 23:47:25 +0000 (15:47 -0800)]
cmd/ld: avoid a segfault when dumping the symbol table

The dumping routine incorrectly assumed that all incoming
symbols would be non-nil and load through it to retrieve the
symbol name.  Instead of using the symbol to retrieve a name,
use the name provided by the caller.

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

12 years agoexp/gotype: fix build breakage due to https://code.google.com/p/go/source/detail...
Alan Donovan [Mon, 28 Jan 2013 23:26:26 +0000 (18:26 -0500)]
exp/gotype: fix build breakage due to https://code.google.com/p/go/source/detail?r=ca5e5de48173

Add 'math/big' to blacklist of packages that use shift
operations as yet unsupported by go/types.

(The failure was masked due to local bugfixes in my client.)

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

12 years agoexp/ssa: (#3 of 5): Function, BasicBlock and optimisations
Alan Donovan [Mon, 28 Jan 2013 23:14:09 +0000 (18:14 -0500)]
exp/ssa: (#3 of 5): Function, BasicBlock and optimisations

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

12 years agoexp/ssa: (#2 of 5): core utilities
Alan Donovan [Mon, 28 Jan 2013 23:06:14 +0000 (18:06 -0500)]
exp/ssa: (#2 of 5): core utilities

This CL includes the implementation of Literal, all the
Value.String and Instruction.String methods, the sanity
checker, and other misc utilities.

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

12 years agomath/big: add Rat.{,Set}Float64 methods for IEEE 754 conversions.
Alan Donovan [Mon, 28 Jan 2013 23:00:15 +0000 (18:00 -0500)]
math/big: add Rat.{,Set}Float64 methods for IEEE 754 conversions.

Added tests, using input data from strconv.ParseFloat.
Thanks to rsc for most of the test code.

math/big could use some good package-level documentation.

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

12 years agotest: add support for build tags.
Rémy Oudompheng [Mon, 28 Jan 2013 20:29:45 +0000 (21:29 +0100)]
test: add support for build tags.

This enables a few tests that were only executed
unconditionnally.

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

12 years agoxml: differentiate between float32 and float64 for marshalSimple
Vega Garcia Luis Alfonso [Mon, 28 Jan 2013 17:54:27 +0000 (12:54 -0500)]
xml: differentiate between float32 and float64 for marshalSimple

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

12 years agoruntime: earlier detection of unused spans.
Sébastien Paolacci [Mon, 28 Jan 2013 17:53:35 +0000 (12:53 -0500)]
runtime: earlier detection of unused spans.

Mark candidate spans one GC pass earlier.

Move scavenger's code out from mgc0 and constrain it into mheap (where it belongs).

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

12 years agogo/build: undo CL 7129048
Russ Cox [Mon, 28 Jan 2013 17:49:26 +0000 (12:49 -0500)]
go/build: undo CL 7129048

This broke 'godoc net/http'.

TBR=adg
CC=golang-dev
https://golang.org/cl/7235052

12 years agonet: fix windows build
Ian Lance Taylor [Mon, 28 Jan 2013 17:37:10 +0000 (09:37 -0800)]
net: fix windows build

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

12 years agonet, syscall: use accept4 and SOCK_CLOEXEC on Linux
Ian Lance Taylor [Mon, 28 Jan 2013 16:54:15 +0000 (08:54 -0800)]
net, syscall: use accept4 and SOCK_CLOEXEC on Linux

R=golang-dev, bradfitz, mikioh.mikioh, dave, minux.ma
CC=golang-dev
https://golang.org/cl/7227043

12 years agosrc: add race.bash
Dave Cheney [Mon, 28 Jan 2013 10:05:25 +0000 (21:05 +1100)]
src: add race.bash

Add race.bash so anyone with suitable hardware can run a race detector build. race.bash can be called from the dashboard builder by passing -cmd="race.bash".

Original source for race.bash is here, http://code.google.com/p/go-wiki/wiki/DashboardBuilders

TODO: add race.bat for windows/amd64

R=dvyukov, minux.ma, adg, rsc
CC=fullung, golang-dev
https://golang.org/cl/7179052

12 years agogo/ast: Fix typo for the godoc of ObjKind
Vega Garcia Luis Alfonso [Mon, 28 Jan 2013 05:36:47 +0000 (21:36 -0800)]
go/ast: Fix typo for the godoc of ObjKind

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

12 years agoCONTRIBUTORS: Add Gustavo Franco (Google CLA)
Brad Fitzpatrick [Mon, 28 Jan 2013 00:32:21 +0000 (16:32 -0800)]
CONTRIBUTORS: Add Gustavo Franco (Google CLA)

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

12 years agoruntime: use new CNT_MASK in lfstack
Ian Lance Taylor [Sun, 27 Jan 2013 02:16:43 +0000 (18:16 -0800)]
runtime: use new CNT_MASK in lfstack

This is for SPARC64, a 64-bit processor that uses all 64-bits
of virtual addresses.  The idea is to use the low order 3 bits
to at least get a small ABA counter.  That should work since
pointers are aligned.  The idea is for SPARC64 to set CNT_MASK
== 7, PTR_BITS == 0, PTR_MASK == 0xffffffffffffff8.

Also add uintptr casts to avoid GCC warnings.  The gccgo
runtime code is compiled with GCC, and GCC warns when casting
between a pointer and a type of a different size.

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

12 years agoall: make tests able to run multiple times.
Rémy Oudompheng [Sat, 26 Jan 2013 23:24:09 +0000 (00:24 +0100)]
all: make tests able to run multiple times.

It is now possible to run "go test -cpu=1,2,4 std"
successfully.

Fixes #3185.

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

12 years agocmd/go: add missing tests
Dave Cheney [Sat, 26 Jan 2013 04:07:21 +0000 (23:07 -0500)]
cmd/go: add missing tests

These changes to test.bash were intended to be submitted with CL 6941058, but were accidentally excluded from the original CL.

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

12 years agoruntime: avoid defining the same variable in more than one translation unit
Shenghou Ma [Sat, 26 Jan 2013 01:57:06 +0000 (09:57 +0800)]
runtime: avoid defining the same variable in more than one translation unit
For gccgo runtime and Darwin where -fno-common is the default.

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

12 years agoCONTRIBUTORS: add Carl Shapiro's golang.org address
Brad Fitzpatrick [Fri, 25 Jan 2013 23:35:25 +0000 (15:35 -0800)]
CONTRIBUTORS: add Carl Shapiro's golang.org address

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

12 years agonet/http: fix Content-Length/Transfer-Encoding on HEAD requests
John Graham-Cumming [Fri, 25 Jan 2013 18:20:19 +0000 (10:20 -0800)]
net/http: fix Content-Length/Transfer-Encoding on HEAD requests

net/http currently assumes that the response to a HEAD request
    will always have a Content-Length header. This is incorrect.

RFC2616 says: "The HEAD method is identical to GET except that
the server MUST NOT return a message-body in the response. The
metainformation contained in the HTTP headers in response to a
HEAD request SHOULD be identical to the information sent in
response to a GET request. This method can be used for
obtaining metainformation about the entity implied by the
request without transferring the entity-body itself. This
method is often used for testing hypertext links for validity,
accessibility, and recent modification."

This means that three cases are possible: a Content-Length
header, a Transfer-Encoding header or neither. In the wild the
following sites exhibit these behaviours (curl -I):

HEAD on http://www.google.co.uk/ has Transfer-Encoding: chunked
HEAD on http://www.bbc.co.uk/    has Content-Length: 45247
HEAD on http://edition.cnn.com/  has neither header

This patch does not remove the ErrMissingContentLength error
for compatibility reasons, but it is no longer used.

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

12 years agomisc/dashboard/builder: synchronize accesses to goroot, always -commit
Andrew Gerrand [Thu, 24 Jan 2013 23:06:18 +0000 (10:06 +1100)]
misc/dashboard/builder: synchronize accesses to goroot, always -commit

This prevents the occasional issue when Mercurial screws up the locking
itself, and by moving the locking into this process we can use the
goroot for other things (such as automatically updating the builder
binary).

It also asks all builders to poll for new commits.

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

12 years agoexp/ssa: API and documentation.
Alan Donovan [Thu, 24 Jan 2013 22:21:48 +0000 (17:21 -0500)]
exp/ssa: API and documentation.

R=gri, iant, crawshaw, bradfitz, gri, iant
CC=golang-dev
https://golang.org/cl/7071058

12 years agodoc: add mention of the Go+ community
Andrew Gerrand [Thu, 24 Jan 2013 21:27:34 +0000 (08:27 +1100)]
doc: add mention of the Go+ community

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

12 years agogo/types: expose types.IsIdentical, the Type equivalence relation.
Alan Donovan [Thu, 24 Jan 2013 19:22:17 +0000 (14:22 -0500)]
go/types: expose types.IsIdentical, the Type equivalence relation.

This function is absolutely critical for clients such as
exp/ssa, and too complex for clients to duplicate.

As with CL 7200046, gri expressed in the doc below [gophers
only] before going on leave that he intended to expose such a
predicate, though his wording suggests as an interface method
of Type rather than a standalone function.  (My preference is
for binary methods to be standalone; see "On Binary Methods",
Kim Bruce, 1995).  In any case if he wishes to move it that's
easily accommodated by clients.

https://docs.google.com/a/google.com/document/d/1-DQ4fxlMDs9cYtnkKhAAehX6MArjOQyJsRXp-6kiJLA/edit#heading=h.k3bwja7xony9

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

12 years agogo/types: add String() method to Type interface.
Alan Donovan [Thu, 24 Jan 2013 19:21:51 +0000 (14:21 -0500)]
go/types: add String() method to Type interface.

All implementations delegate to typeString.

Though I don't wish to exploit gri's absence to change
his code, this change is pretty low-risk and he assented to it
in the blue ink in the doc below [gophers only].
https://docs.google.com/a/google.com/document/d/1-DQ4fxlMDs9cYtnkKhAAehX6MArjOQyJsRXp-6kiJLA/edit#

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