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

12244 Commits

Author SHA1 Message Date
Russ Cox
4dd3e1e844 encoding/xml: name space bug fixes
If two fields have the same name but different explicit name spaces,
treat as non-conflicting. This allows parsing common XML formats
that have ns1:tag and ns2:tag in the same XML element.
Fixes #4691.

Allow setting the default name space for unadorned tags, by
writing to Decoder.DefaultSpace. This allows turned the job of
parsing common XML formats that have tag and ns2:tag in the
same XML element into the first case by setting DefaultSpace="ns1".
Fixes #3703.

Use name space attributes when decoding.
Attach name space to attributes when encoding.
Could be done with fewer annotations, but semantically correct as is.
Fixes #3526.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7227056
2013-03-12 11:46:12 -04:00
Adrian Nos
0d559f7b92 net/rpc/jsonrpc: nil pointer deference on invalid reply.
Fixes #5006.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7691045
2013-03-12 11:45:56 -04:00
Dmitriy Vyukov
6ee739d7e9 runtime: fix deadlock detector false negative
The issue was that scvg is assigned *after* the scavenger goroutine is started,
so when the scavenger calls entersyscall() the g==scvg check can fail.
Fixes #5025.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7629045
2013-03-12 17:21:44 +04:00
Dmitriy Vyukov
7f070af515 runtime: deflake TestStackMem
The problem is that there are lots of dead G's from previous tests,
each dead G consumes 1 stack segment.
Fixes #5034.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7749043
2013-03-12 15:19:06 +04:00
Dmitriy Vyukov
e0fd6d08b2 net/http: deflake test
Update #5005.

R=golang-dev, fullung, bradfitz
CC=golang-dev
https://golang.org/cl/7651045
2013-03-12 12:52:49 +04:00
Philip K. Warren
b4237b5997 encoding/base32, encoding/base64: fix issues with decoder whitespace handling
Adds a new reader to filter newlines, which fixes errors seen in the
decoder chunking code. Found additional issues with whitespace handling
after the first padding character.
Fixes #4779.

R=minux.ma, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/7311069
2013-03-12 01:50:10 -04:00
Russ Cox
e64f3f211a net: never use backlog > 65535
The system call takes an int, but the kernel stores it in a uint16.
At least one Linux system sets /proc/sys/net/core/somaxconn
to 262144, which ends up being 0 in the uint16. Avoid being tricked.

FreeBSD sources also store the backlog in a uint16.
Assume the problem is systemic and fix it everywhere.

Fixes #5030.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7480046
2013-03-12 01:48:48 -04:00
Russ Cox
019754ed40 encoding/xml: fix spurious "no semicolon" in error
Noticed while doing other XML investigations.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7550045
2013-03-12 00:29:36 -04:00
Russ Cox
aa81eb5901 encoding/xml: allow embedded non-structs
The old code just assumed that the only thing
you can embed is a struct. Not true.

Fixes #3803.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7743043
2013-03-11 23:58:20 -04:00
Brad Fitzpatrick
864278ad90 net/http: bit more docs on Client vs Transport
This isn't as bad as it used to be, but add a bit
more detail to close the issue.

Fixes #3359

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7606044
2013-03-11 18:51:01 -07:00
Nigel Tao
96e0c0c764 encoding/base32, encoding/base64: a small stack-space optimization.
R=dsymonds, dave
CC=golang-dev
https://golang.org/cl/7568045
2013-03-12 11:24:24 +11:00
Dave Cheney
2f2271db7a net/http: add tests for ParseHTTPVersion
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7739043
2013-03-12 11:18:18 +11:00
Nigel Tao
79d06d7286 encoding/base32: don't panic when decoding "AAAA==".
Edit encoding/base64's internals and tests to match encoding/base32.

Properly handling line breaks in padding is left for another CL.

R=dsymonds
CC=golang-dev
https://golang.org/cl/7693044
2013-03-12 11:07:36 +11:00
Rob Pike
1b3c969ac3 regexp: identify that submatch is also known as capturing group
Mention the syntax is defined by the regexp/syntax package.
Fixes #3953.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7702044
2013-03-11 16:23:06 -07:00
Robert Griesemer
916f4cfa64 go/parser: better error message if = is seen instead of ==
Fixes #4519.

R=rsc
CC=golang-dev
https://golang.org/cl/7733044
2013-03-11 15:23:18 -07:00
Russ Cox
d2be8f2948 cmd/addr2line: exit 0 for --help
This is what pprof expects, or else it won't use the program.
And if it doesn't use the program, it gets very bad results.

Fixes #4818.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7728043
2013-03-11 18:12:07 -04:00
Rémy Oudompheng
401e0fea3a cmd/gc: reject complex calls with mismatched argument types.
The specification says "the two arguments must be of the same
floating-point type."

R=rsc, gri
CC=golang-dev
https://golang.org/cl/7671045
2013-03-11 22:55:14 +01:00
Brad Fitzpatrick
e15c0ac693 all: remove now-unnecessary unreachable panics
Take advantage of the new terminating statement rule.

R=golang-dev, r, gri
CC=golang-dev
https://golang.org/cl/7712044
2013-03-11 14:16:55 -07:00
Rob Pike
5f91a62a3c cmd/go: fix description of -o flag to build
Fixes #5003.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7476047
2013-03-11 14:07:47 -07:00
Russ Cox
7b4ac31cab cmd/dist: make cc rule match what cmd/go uses
We added -I$GOROOT/pkg/$GOOS_$GOARCH in cmd/go
(I think for use by cgo and swig, primarily) but didn't
update cmd/dist. I was testing some other code and
found that my changes built with cmd/go but failed
during the initial bootstrap. Make them match again.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7707044
2013-03-11 16:50:44 -04:00
Robert Griesemer
5183bfda75 go/types: update operand types early
For expressions where the result type is independent
of the argument types (comparisons, conversions, rhs
of shifts), set the final expression types for those
subtrees early.

This fixes several bugs where incorrect lhs shift
operands where used (say in a comparison), but were
not reported.

Together with the changes listed below this CL fixes
many type-checker bugs.

Also:
- better documented updateExprType
- added larger comment to expr.go explaining
  the basic expression checking algorithm
- use latest definition for indices and make
  arguments; use the same code to check both
- use the same mechanism for cycle detection
  in constant expressions as for variables
  (new field Constant.visited)
- more tests for complex and make builtins
- many more and systematic tests for shifts;
  moved them into separate testfile
- in the testing code, don't compare the
  expected error pattern against itself
  (the actual message was always ignored...)
- fix affected error patterns in the test files
- various cleanups along the way

R=adonovan
CC=golang-dev
https://golang.org/cl/7432051
2013-03-11 13:38:45 -07:00
Akshat Kumar
76374412c3 lib9, cmd/dist, cmd/ld: Plan 9: fix build
lib9: fix runcmd, removeall, and tempdir functions

cmd/dist: Include run_plan9.c and tempdir_plan9.c
        from lib9 for build, and in general consider
        file names containing "plan9" for building.

cmd/ld: provide function args for the new functions
        from lib9.

R=rsc, rminnich, ality, bradfitz
CC=golang-dev
https://golang.org/cl/7666043
2013-03-11 13:34:57 -07:00
Rémy Oudompheng
386ad0ab90 cmd/gc: enable inlining in generated method wrappers.
Method calls on interfaces with large stored values
will call the pointer receiver method which may be
a wrapper over a method with value receiver.

This is particularly inefficient for very small bodies.
Inlining the wrapped method body saves a potentially expensive
function call.

benchmark                old ns/op    new ns/op    delta
BenchmarkSortString1K       802295       641387  -20.06%
BenchmarkSortInt1K          359914       238234  -33.81%
BenchmarkSortInt64K       35764226     22803078  -36.24%

Fixes #4707.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/7214044
2013-03-11 21:24:51 +01:00
Brad Fitzpatrick
404e4a90cb net/http/httputil: fix string in test failure message
R=golang-dev, daniel.morsing
CC=golang-dev
https://golang.org/cl/7722043
2013-03-11 13:23:47 -07:00
Rob Pike
ea196278aa debug/macho: add doc comment for FormatError
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7624044
2013-03-11 12:32:47 -07:00
Rodrigo Moraes de Oliveira
82e3ca7b7a net/url: better path resolution
This includes a simplified resolvePath function and tests for all normal and abnormal path resolution examples described in RFC 3986, sections 5.4.1 and 5.4.2 [1]. Some of those examples failed before (see http://play.golang.org/p/F0ApSaXniv).

Also, parsing a reference "//foo" now works as expected. It was treated as an absolute path with very weird results (see http://play.golang.org/p/089b-_xoNe).

During path resolution, all dot segments are removed as described by the RFC.

A few existing tests had to be changed because they expected the wrong output.

Fixes #4700.

Fixes #4706.

[1] http://tools.ietf.org/html/rfc3986#section-5.4.1

R=rsc, adg, bradfitz
CC=golang-dev
https://golang.org/cl/7203059
2013-03-11 15:03:07 -04:00
Dmitriy Vyukov
fe017550ac os/signal: deflake test
Fixes #4987.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7713043
2013-03-11 22:31:34 +04:00
Brad Fitzpatrick
f0396caf12 net/http: add a test verifying header case preservation
Fixes #5022

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7712043
2013-03-11 11:10:43 -07:00
Brad Fitzpatrick
c6e8993e79 net/http/httputil: remove hop-by-hop headers in ReverseProxy
Fixes #2735

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7470048
2013-03-11 10:32:32 -07:00
Albert Strasheim
2f0a970bde net: allow concurrent UNIX socket tests if TMPDIR is unique.
Only clever enough to allow concurrent stress testing.

R=mikioh.mikioh, rsc
CC=golang-dev
https://golang.org/cl/7703044
2013-03-11 13:24:52 -04:00
Russ Cox
14a295c817 sync/atomic: make unaligned 64-bit atomics crash on 386
R=golang-dev, bradfitz, dvyukov
CC=golang-dev
https://golang.org/cl/7702043
2013-03-11 12:21:46 -04:00
Jonathan Rudenberg
fadeafac93 net/http: add additional status codes defined in RFC 6585
428 Precondition Required
429 Too Many Requests
431 Request Header Fields Too Large
511 Network Authentication Required

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7678043
2013-03-11 07:43:57 -07:00
Russ Cox
65ed3f1073 math/big: fix comment
The variable is named b not bit.

R=golang-dev, agl
CC=golang-dev
https://golang.org/cl/7699043
2013-03-11 10:20:33 -04:00
Shenghou Ma
960d7082ee cmd/ld, runtime/cgo: allow a symbol to be both cgo_export and cgo_import.
Fixes #4878.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7420052
2013-03-11 14:24:51 +08:00
Russ Cox
72dd01451f cmd/5l: fix build (define stub machoreloc1)
R=ken2
CC=golang-dev
https://golang.org/cl/7694043
2013-03-11 01:27:03 -04:00
Russ Cox
761c386770 build: enable host linking test for all BSDs
Let's just see what breaks.

R=golang-dev, bradfitz, adg
CC=golang-dev
https://golang.org/cl/7693043
2013-03-11 01:12:18 -04:00
Russ Cox
3b85b724c5 cmd/ld: darwin support for host linking
R=ken2
CC=golang-dev
https://golang.org/cl/7626045
2013-03-11 00:51:42 -04:00
Russ Cox
9e13803ae1 cmd/ld: avoid redundant external relocation calculations
R=ken2, ken
CC=golang-dev
https://golang.org/cl/7483045
2013-03-10 19:07:16 -07:00
Jeff R. Allen
53f034c7a8 cmd/go: send output of build and install to stderr
"go build" and "go install" were mixing stdout and stderr
from the toolchain, then putting it all on stdout. With this
change, it stays mixed, and is sent to stderr. Because
the toolchain does not create output in a clean compile/install,
sending all output to stderr makese more sense.

Also fix test.bash because of "mktemp: too few X's
in template `testgo'" on Linux.

Fixes #4917.

R=golang-dev, rsc, adg
CC=golang-dev
https://golang.org/cl/7393073
2013-03-11 11:31:14 +11:00
Russ Cox
96b243fa47 cmd/ld: replace dynimpname with extname
Dynimpname was getting too confusing.
Replace flag-like checks with tests of s->type.

R=ken2
CC=golang-dev
https://golang.org/cl/7594046
2013-03-10 18:19:53 -04:00
Russ Cox
4c40e5ae51 cmd/ld: wrap long data lines in -a output
Also move symbol names onto lines by themselves: some are very long.
Show relocations.

R=ken2
CC=golang-dev
https://golang.org/cl/7689043
2013-03-10 16:32:00 -04:00
Russ Cox
df6072b41c cmd/ld: include full symbol table in Mach-O output
This makes binaries work with OS X nm.

R=ken2
CC=golang-dev
https://golang.org/cl/7558044
2013-03-10 16:24:01 -04:00
Russ Cox
85d83c2e51 libmach: fix build
I guess it would be too much to ask for gcc on my machine to give
the same errors as gcc on the builder machines.

R=ken2
CC=golang-dev
https://golang.org/cl/7686044
2013-03-10 14:45:57 -04:00
Russ Cox
b83d4af330 cmd/ld: make mach-o sections match internal sections
This brings Mach-O generation more in line with ELF generation.

Having separate sections for the symtab and pclntab mean that we
can find them that way, instead of using the deprecated debug segments.
(And the host linker will keep separate sections for us, but probably
not the debug segments.)

R=ken2
CC=golang-dev
https://golang.org/cl/7688043
2013-03-10 14:17:04 -04:00
Russ Cox
e982ecacd1 cmd/ld: add tmpdir flag to preserve temp files
R=ken2
CC=golang-dev
https://golang.org/cl/7497044
2013-03-10 12:50:44 -04:00
Dmitriy Vyukov
433824d808 runtime: fix misaligned 64-bit atomic
Fixes #4869.
Fixes #5007.
Update #5005.

R=golang-dev, 0xe2.0x9a.0x9b, bradfitz
CC=golang-dev
https://golang.org/cl/7534044
2013-03-10 20:46:11 +04:00
Brad Fitzpatrick
8d51c33012 net: evaluate the timeout dial opt's deadline at dial time
Previously it was evaluated once, so re-using the timeout option
repeatedly would always generate the same deadine.

Also switch to doing just one pass over the options, making
the private interface actually useful.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7608045
2013-03-09 18:14:00 -08:00
Lucio De Re
a8e55f8858 cmd/8l/obj.c: NetBSD passes the test, Hnetbsd added.
myrtle$ go version
go version devel +d533352b414d Sat Mar 09 05:39:15 2013 +0100 netbsd/386
myrtle$ time go test -ldflags -hostobj ../misc/cgo/test
ok      _/var/project/GoLang/misc/cgo/test      10.962s
   68.63s real    49.60s user    19.06s system
myrtle$ uname -a
NetBSD myrtle.plan9.local 6.0_BETA2 NetBSD 6.0_BETA2 (GENERIC) i386

R=rsc
CC=golang-dev
https://golang.org/cl/7641047
2013-03-09 14:54:56 -08:00
Steve McCoy
18f926aab3 cgo: enable external linking mode on FreeBSD amd64.
Tested on FreeBSD 9.1 amd64, per rsc's instructions at
https://groups.google.com/d/topic/golang-dev/HjRTLvRsJXo/discussion .

R=golang-dev, lucio.dere, devon.odell, rsc
CC=golang-dev
https://golang.org/cl/7664044
2013-03-09 14:51:57 -08:00
Dave Cheney
9dd92d522f syscall: add PROT_* and MAP_* constants to freebsd
Update #4929

Regenerated from FreeBSD-9.1 for amd64 and 386, FreeBSD-CURRENT for arm.

R=devon.odell, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7438053
2013-03-09 16:25:30 +11:00
Ian Lance Taylor
30b89a84ac net: if accept4 returns EINVAL fall back to accept
R=golang-dev, andybalholm, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7485045
2013-03-08 21:18:06 -08:00
Akshat Kumar
ef7705f6dd runtime: Plan 9: fix errstr
The call to the C function runtime.findnull() requires
that we provide the argument at 0(SP).

R=rsc, rminnich, ality
CC=golang-dev
https://golang.org/cl/7559047
2013-03-09 05:39:15 +01:00
Russ Cox
cd94cabad6 cmd/ld: external linking fixes for linux/386
The sticking point on 386 has been the "PC relative" relocations
used to point the garbage collection metadata at the type info.
These aren't in the code segment, and I don't trust that the linker
isn't doing something special that would be okay in code but
not when interpreting the pointers as data (for example, a PLT
jump table would be terrible).

Solve the problem in two steps:

1. Handle "PC relative" relocations within a section internally,
so that the external linker never sees them.

2. Move the gcdata and gcbss tables into the rodata section,
where the type information lives, so that the relocations can
be handled internally.

(To answer the obvious question, we make the gc->type
references relative so that they need not be relocated
individually when generating a shared object file.)

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7629043
2013-03-08 20:22:38 -08:00
Rob Pike
0406c63ea3 text/template: revert minor change to Name method
For  better printing, I recently changed Name to return "<unnamed>" for templates
with empty names, but this causes trouble for the many packages that used "" as
the template name, so restore the old behavior.
It's usually printed as a quoted string anyway, so it should be fine.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7577044
2013-03-08 16:39:54 -08:00
Rémy Oudompheng
1b8f51c917 runtime: fix integer overflow in amd64 memmove.
Fixes #4981.

R=bradfitz, fullung, rsc, minux.ma
CC=golang-dev
https://golang.org/cl/7474047
2013-03-09 00:41:03 +01:00
Brad Fitzpatrick
3cdf8bae1a database/sql: fix Conn leak
Fixes #4902

R=golang-dev, alex.brainman, r, google
CC=golang-dev
https://golang.org/cl/7579045
2013-03-08 10:04:17 -08:00
Russ Cox
1a4599b41a runtime: clear locked bit when goroutine exits
Otherwise the next goroutine run on the m
can get inadvertently locked if it executes a cgo call
that turns on the internal lock.

While we're here, fix the cgo panic unwind to
decrement m->ncgo like the non-panic unwind does.

Fixes #4971.

R=golang-dev, iant, dvyukov
CC=golang-dev
https://golang.org/cl/7627043
2013-03-08 11:26:00 -05:00
Russ Cox
091d7210c7 runtime: make TestStackMem a little less flaky
Have seen failures with GOMAXPROCS=4 on Windows.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7626043
2013-03-08 11:25:21 -05:00
Russ Cox
e0c430d5b7 cmd/6l, cmd/8l: fix BSD builds
Before this CL, running

        cd misc/cgo/test
        go test -c
        readelf --dyn-syms test.test | grep cgoexp

turned up many UNDEF symbols corresponding to symbols actually
in the binary but marked only cgo_export_static. Only symbols
marked cgo_export_dynamic should be listed in this mode.
And if the symbol is going to be listed, it should be listed with its
actual address instead of UNDEF.

The Linux dynamic linker didn't care about the seemingly missing
symbols, but the BSD one did.

This CL eliminates the symbols from the dyn-syms table.

R=golang-dev
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/7624043
2013-03-07 21:23:59 -08:00
Russ Cox
7663ffcae6 cmd/ld: steps toward 386 host linking
- Introduce MaxAlign constant and use in data layout
and ELF section header.

- Allow up to 16-byte alignment for large objects
(will help Keith's hash changes).

- Emit ELF symbol for .rathole (global /dev/null used by 8c).

- Invoke gcc with -m32/-m64 as appropriate.

- Don't invoke gcc if writing the .o file failed.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7563045
2013-03-07 19:57:25 -08:00
Russ Cox
dfc22e29ec runtime: change 386 startup convention
Now the default startup is that the program begins at _rt0_386_$GOOS,
which behaves as if calling main(argc, argv). Main jumps to _rt0_386.

This makes the _rt0_386 entry match the expected semantics for
the standard C "main" function, which we can now provide for use when
linking against a standard C library.

386 analogue of https://golang.org/cl/7525043

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7551045
2013-03-07 19:57:10 -08:00
Brad Fitzpatrick
b6e0d39a34 net/http: Transport socket late binding
Implement what Chrome calls socket "late binding". See:
https://insouciant.org/tech/connection-management-in-chromium/

In a nutshell, if our HTTP client needs a TCP connection to a
remote host and there's not an idle one available, rather than
kick off a dial and wait for that specific dial, we instead
kick off a dial and wait for either our own dial to finish, or
any other TCP connection to that same host to become
available.

The implementation looks like a classic "Learning Go
Concurrency" slide.

Chrome's commit and numbers:
http://src.chromium.org/viewvc/chrome?view=rev&revision=36230

R=golang-dev, daniel.morsing, adg
CC=golang-dev
https://golang.org/cl/7587043
2013-03-07 17:56:00 -08:00
Akshat Kumar
a566deace1 syscall: Plan 9: use lightweight errstr in entersyscall mode
Change 231af8ac63aa (CL 7314062) made runtime.enteryscall()
set m->mcache = nil, which means that we can no longer use
syscall.errstr in syscall.Syscall and syscall.Syscall6, since it
requires a new buffer to be allocated for holding the error string.
Instead, we use pre-allocated per-M storage to hold error strings
from syscalls made while in entersyscall mode, and call
runtime.findnull to calculate the lengths.

Fixes #4994.

R=rsc, rminnich, ality, dvyukov, rminnich, r
CC=golang-dev
https://golang.org/cl/7567043
2013-03-08 00:54:44 +01:00
Mikio Hara
2ac799cfbc net: fix multicast listener tests
This CL splits multicast listener tests into two; for IPv4 and
for IPv6. It also removes redundant test inputs and makes sure
that assignment of multicast interface to stablize the tests.

Fixes #4059.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7565043
2013-03-08 06:51:06 +09:00
Keith Randall
297bb12809 cmd/6a, cmd/8a, cmd/6l, cmd/8l: add AES instructions
Instructions for use in AES hashing.  See CL#7543043

R=rsc
CC=golang-dev
https://golang.org/cl/7548043
2013-03-07 12:54:00 -08:00
Rémy Oudompheng
4c203172a2 cmd/8g: fix code generation of int64(0) == int64(0).
The code would violate the contract of cmp64.

Fixes #5002.

R=rsc, golang-dev
CC=golang-dev
https://golang.org/cl/7593043
2013-03-07 21:47:45 +01:00
Russ Cox
5641a09171 lib9: fix windows build (don't use runesmprint)
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/7575046
2013-03-07 14:38:49 -05:00
Robert Griesemer
6ee75663c9 go/types: more internal cleanups
R=adonovan, bradfitz
CC=golang-dev
https://golang.org/cl/7492045
2013-03-07 11:17:30 -08:00
Dmitriy Vyukov
b000f2286c net: more refactoring in preparation for runtime integrated pollster
Move pollServer from fd_unix.go to fd_poll_unix.go.
Add pollServerInit(*NetFD) to allow custom initialization.
Add pollServer.Close(*NetFD) to allow custom finalization.
Move setDeadline() to fd_poll_unix.go to allow custom handling of deadlines.
Move newPollServer() to fd_poll_unix.go to allow custom initialization.
No logical code changes.
The next step will be to turn off fd_poll_unix.go for some platform
(I have changes for darwin/linux) and redirect it into runtime. See:
https://golang.org/cl/7569043/diff/2001/src/pkg/net/fd_poll_runtime.go

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7513045
2013-03-07 21:44:24 +04:00
Dmitriy Vyukov
cb945ba6ba runtime: fix deadlock
The deadlock episodically occurs on misc/cgo/test/TestCthread.
The problem is that starttheworld() leaves some P's with local work
without M's. Then all active M's enter into syscalls, but reject to
wake another M's due to the following check (both in entersyscallblock() and in retake()):
if(p->runqhead == p->runqtail &&
        runtime·atomicload(&runtime·sched.nmspinning) +
        runtime·atomicload(&runtime·sched.npidle) > 0)
        continue;

R=rsc
CC=golang-dev
https://golang.org/cl/7424054
2013-03-07 21:39:59 +04:00
Russ Cox
60f783d92b cmd/ld: host linking support for linux/amd64
Still to do: non-linux and non-amd64.
It may work on other ELF-based amd64 systems too, but untested.

"go test -ldflags -hostobj $GOROOT/misc/cgo/test" passes.

Much may yet change, but this seems a reasonable checkpoint.

R=iant
CC=golang-dev
https://golang.org/cl/7369057
2013-03-07 09:19:02 -05:00
Russ Cox
8aafb44b0b runtime: fix cgo callbacks on windows
Fixes #4955.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/7563043
2013-03-07 09:18:48 -05:00
Dmitriy Vyukov
0f136f2c05 net: fix accept/connect deadline handling
Ensure that accept/connect respect deadline,
even if the operation can be executed w/o blocking.
Note this changes external behavior, but it makes
it consistent with read/write.
Factor out deadline check into pollServer.PrepareRead/Write,
in preparation for edge triggered pollServer.
Ensure that pollServer.WaitRead/Write are not called concurrently
by adding rio/wio locks around connect/accept.

R=golang-dev, mikioh.mikioh, bradfitz, iant
CC=golang-dev
https://golang.org/cl/7436048
2013-03-07 17:03:40 +04:00
Mikio Hara
48fa4a10fb net: fix typo in skip message
R=golang-dev, akumar
CC=golang-dev
https://golang.org/cl/7523044
2013-03-07 19:17:18 +09:00
Mikio Hara
3fc244f370 net: fix plan9 build
R=golang-dev, akumar
CC=golang-dev
https://golang.org/cl/7564043
2013-03-07 19:15:00 +09:00
Tyler Bunnell
ae7aa345db cmd/fix: remove redundant 0 port
Fixes #4505.

R=golang-dev, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7468043
2013-03-07 19:06:19 +09:00
Rob Pike
bcb1da7065 all: delete a couple of mentions of the exp and old trees
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7551043
2013-03-06 16:52:03 -08:00
Robert Griesemer
0b2caf2717 go/types: implement constant string(x) conversions
Fixes #4982.

R=adonovan, r
CC=golang-dev
https://golang.org/cl/7537043
2013-03-06 16:15:04 -08:00
Robert Griesemer
b8db56ad2e go/types: cleanup of assignment checks
Also:
- cleaner handling of constants w/ unknown value
- removed several TODOs

R=adonovan
CC=golang-dev
https://golang.org/cl/7473043
2013-03-06 16:14:07 -08:00
Albert Strasheim
0a71a5b029 all: Skip AllocsPerRun tests if GOMAXPROCS>1.
Fixes #4974.

R=rsc, bradfitz, r
CC=golang-dev
https://golang.org/cl/7545043
2013-03-06 15:52:32 -08:00
Rob Pike
d07978a0f7 exp/norm: delete, part of moving to go.text
See also https://golang.org/cl/7520044

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7533044
2013-03-06 14:34:03 -08:00
Brad Fitzpatrick
a30bede5ef net/http: remove allocations in HeaderWriteSubset
Before:
BenchmarkHeaderWriteSubset  500000  2354 ns/op  197 B/op  2 allocs/op
After:
BenchmarkHeaderWriteSubset 1000000  2085 ns/op    0 B/op  0 allocs/op

Fixes #3761

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7508043
2013-03-06 14:10:47 -08:00
Russ Cox
fb59aed60b cmd/cgo: split cgo_export into cgo_export_static and cgo_export_dynamic
Also emit cgo_ldflag pragmas.

R=golang-dev, remyoudompheng, iant
CC=golang-dev
https://golang.org/cl/7530043
2013-03-06 16:57:14 -05:00
Russ Cox
56d1faa8b6 net/http/httputil: fix build
TBR=bradfitz
CC=golang-dev
https://golang.org/cl/7540043
2013-03-06 16:56:53 -05:00
Russ Cox
efd3d1ffe9 runtime: fix netbsd, windows build
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/7539043
2013-03-06 16:55:08 -05:00
Russ Cox
48c1db4003 net/http: change user agent string
Some IDS somewhere thinks "Go http package" is a virus.
Make it something else for Go 1.1. Dumb but easy.

R=golang-dev, bradfitz, minux.ma
CC=golang-dev
https://golang.org/cl/7532043
2013-03-06 16:48:20 -05:00
Rob Pike
a25486e4b1 make.bash,bat: add -tags gotypes to the build
This installs type checking into go vet.
(To be removed before releasing Go 1.1)

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7528044
2013-03-06 13:16:43 -08:00
Rob Pike
0ed517e5e6 cmd/vet: isolate the type checking code into a separate file
We can enable/disable type checking with a build tag.
Should simplify cutting the go1.1 distribution free of go/types.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7482045
2013-03-06 12:49:56 -08:00
Russ Cox
7610a0552f lib9: add mktempdir, removeall, runprog
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7523043
2013-03-06 15:48:28 -05:00
Rob Pike
c76379954f text/template: improve error reporting for executing an empty template
Fixes #4522.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7502044
2013-03-06 12:34:19 -08:00
Ewan Chou
4f43201e51 strings: remove allocations in Split(s, "")
BenchmarkSplit1     77984460     24131380  -69.06%

R=golang-dev, rsc, minux.ma, dave, extemporalgenome
CC=golang-dev
https://golang.org/cl/7458043
2013-03-06 15:21:19 -05:00
Alex Brainman
2f23f90dab runtime,misc/cgo/test: disable broken tests so we can test the rest
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7486048
2013-03-06 15:19:01 -05:00
Alex Brainman
e44f42e056 libmach: fix amd64 pe handling
Fixes #4841.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7475046
2013-03-06 15:14:07 -05:00
Russ Cox
36b414f639 runtime: change amd64 startup convention
Now the default startup is that the program begins at _rt0_amd64_$GOOS,
which sets DI = argc, SI = argv and jumps to _rt0_amd64.

This makes the _rt0_amd64 entry match the expected semantics for
the standard C "main" function, which we can now provide for use when
linking against a standard C library.

R=golang-dev, devon.odell, minux.ma
CC=golang-dev
https://golang.org/cl/7525043
2013-03-06 15:03:04 -05:00
Brad Fitzpatrick
ce8341554c net/http: close TCP connection on Response.Body.Close
Previously the HTTP client's (*Response).Body.Close would try
to keep reading until EOF, hoping to reuse the keep-alive HTTP
connection, but the EOF might never come, or it might take a
long time. Now we immediately close the TCP connection if we
haven't seen EOF.

This shifts the burden onto clients to read their whole response
bodies if they want the advantage of reusing TCP connections.

In the future maybe we could decide on heuristics to read some
number of bytes for some max amount of time before forcefully
closing, but I'd rather not for now.

Statistically, touching this code makes things regress, so I
wouldn't be surprised if this introduces new bugs, but all the
tests pass, and I think the code is simpler now too. Maybe.

Please test your HTTP client code before Go 1.1.

Fixes #3672

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7419050
2013-03-05 18:47:27 -08:00
Nigel Tao
0d9bf2757e image/jpeg: for progressive JPEGs, the first SOS segment doesn't
necessarily contain all components.

Fixes #4975.

R=r, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/7469043
2013-03-06 10:08:46 +11:00
David Symonds
a22361d68d vet: check for useless assignments.
The only check so far is for self-assignments of the form "expr = expr",
but even that found one instance in the standard library.

R=r, adg, mtj, rsc
CC=golang-dev
https://golang.org/cl/7455048
2013-03-06 09:55:04 +11:00
Rob Pike
8cf6e75e2a cmd/vet: change some warnings to errors for consistency.
Fixes #4980.

R=golang-dev, rsc, dsymonds
CC=golang-dev
https://golang.org/cl/7479044
2013-03-05 14:31:17 -08:00
Russ Cox
e0deb2ef7f undo CL 7301062 / 9742f722b558
broke arm garbage collector

traceback_arm fails with a missing pc. It needs CL 7494043.
But that only makes the build break later, this time with
"invalid freelist". Roll back until it can be fixed correctly.

««« original CL description
runtime: restrict stack root scan to locals and arguments

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

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7493044
2013-03-05 15:36:40 -05:00
Robert Griesemer
d01516796c go/types: add test typechecking std lib
- run time is limited if -short is set
- also added missing TODO to unrelated file return.go

R=r
CC=golang-dev
https://golang.org/cl/7448052
2013-03-05 11:42:43 -08:00
Joel Sing
1b36bcc3b5 syscall: handle getsockname for unix sockets on openbsd 5.2
On OpenBSD 5.2, calling getsockname on an unbound Unix domain socket
results in a successful syscall, however the AF is unset and the length
is returned as zero. This has been changed to more portable behaviour,
which will be included in the OpenBSD 5.3 release.

For now, work around this by treating a successful getsockname() call
that returns a family of AF_UNSPEC and length of zero as a AF_UNIX
socket.

Makes TestPassFD work on OpenBSD 5.2.

Fixes #4956.

R=golang-dev, minux.ma, rsc, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7449046
2013-03-05 21:40:37 +11:00
Dmitriy Vyukov
add3349867 runtime: add atomic xchg64
It will be handy for network poller.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7429048
2013-03-05 09:46:52 +02:00
Dmitriy Vyukov
2fe840f4f6 runtime: fix false positive deadlock when using runtime.Goexit
Fixes #4893.
Actually it's fixed by cl/7314062 (improved scheduler),
just submitting the test.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7422054
2013-03-05 09:40:17 +02:00
Dmitriy Vyukov
d0c11d20b8 runtime: declare addtimer/deltimer in runtime.h
In preparation for integrated network poller
(https://golang.org/cl/7326051),
this is required to handle deadlines.

R=golang-dev, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/7446047
2013-03-05 09:38:15 +02:00
Carl Shapiro
db018bf77c runtime: restrict stack root scan to locals and arguments
R=rsc
CC=golang-dev
https://golang.org/cl/7301062
2013-03-04 19:48:50 -08:00
David Symonds
6a75252088 text/template/parse: remove self-assignment.
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7431054
2013-03-05 11:16:58 +11:00
David Symonds
eeade74529 vet: clean up taglit error print when typechecking fails.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7416050
2013-03-05 09:56:46 +11:00
Robert Griesemer
6b34eba007 go/types: "missing return" check
Implementation closely based on Russ' CL 7440047.

Future work: The error messages could be better
(e.g., instead of "missing return" it might say
"missing return (no default in switch)", etc.).

R=adonovan, rsc
CC=golang-dev
https://golang.org/cl/7437049
2013-03-04 14:40:12 -08:00
Russ Cox
ecab408c42 cmd/gc: implement new return requirements
Fixes #65.

R=ken2
CC=golang-dev
https://golang.org/cl/7441049
2013-03-04 17:02:04 -05:00
Brad Fitzpatrick
9744c0e175 net: make some tests less flaky
Fixes #4969

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7456049
2013-03-04 11:55:27 -08:00
Russ Cox
6dc3c9cfdd cmd/cgo: use explicit flag to emit dynamic linker path
Using -import_runtime_cgo would have worked great except
that it doesn't get passed to the second invocation of cgo,
and that's the one that writes the relevant file.

Fixes ARM build on systems with a different dynamic linker
than the one 5l assumes (like Gentoo).

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7432048
2013-03-04 11:23:17 -05:00
Brad Fitzpatrick
7903e3600c net/http/cgi: maybe improve darwin test reliability
Use a 17 MB payload instead of a 1 MB payload, since
OS X can apparently buffer up to 16 MB in its pipes.

Fixes #4958 maybe

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7453049
2013-03-04 08:13:39 -08:00
Daniel Morsing
b65acaeab2 cmd/gc: disallow selectors to the blank identifier
Fixes #4941.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7415051
2013-03-04 17:01:42 +01:00
Jan Ziak
cea46387b9 runtime: add garbage collector statistics
If the constant CollectStats is non-zero and GOGCTRACE=1
the garbage collector will print basic statistics about executed
GC instructions.

R=golang-dev, dvyukov
CC=golang-dev, rsc
https://golang.org/cl/7413049
2013-03-04 16:54:37 +01:00
Rémy Oudompheng
a85fce282e cmd/gc: simplify and fix defaultlit.
Fixes #4882.
Fixes #4936.
Fixes #4937.

R=golang-dev, dave, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/7432044
2013-03-04 16:51:42 +01:00
Rémy Oudompheng
b0bb6f8cee cmd/gc: unbreak exporting of composite literals.
Fixes #4932.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/7437043
2013-03-04 16:42:03 +01:00
Russ Cox
69c90985b3 runtime: add link to design doc for new scheduler
R=golang-dev, remyoudompheng, bradfitz
CC=golang-dev
https://golang.org/cl/7419049
2013-03-04 10:36:45 -05:00
Stefan Nilsson
d4a020dec1 container/heap: fix int overflow bug
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7450052
2013-03-04 10:25:21 -05:00
Volker Dobler
9d6e02742c image/png: always set up palette during DecodeConfig
The old code would decode the palette only for 8-bit
images during a DecodeConfig.
This CL keeps the behavior for 8-bit images and sets
up the decoded palette also for 1, 2 and 4-bit images.

Fixes #4279.

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/7421048
2013-03-04 14:54:36 +11:00
Andrew Gerrand
15825dc935 cmd/godoc: move note argument to godoc.go
Fixes the App Engine version of godoc. The other fix is to duplicate
this code inside appinit.go. I think initHandlers is the right place
to put the strings.Split call, as the notesToShow var is used by
docServer, which is what initHandlers sets up.

R=dsymonds
CC=golang-dev
https://golang.org/cl/7434044
2013-03-04 09:02:45 +11:00
Mikio Hara
51d52f820e net: disable unixgram test on Plan 9 and Windows
Fixes build on Plan 9 and Windows.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7454049
2013-03-03 20:06:51 +09:00
Mikio Hara
b767556dd7 net: fix windows build
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7429049
2013-03-03 19:10:59 +09:00
Mikio Hara
ed01f4be59 net: add unixgram dial test
Also replaces testing.Errof with testing.Fatalf, make use of ICMP mock.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7308058
2013-03-03 15:59:53 +09:00
Mikio Hara
13393fb6c7 net: add TCP over IPv6 benchmarks
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7433044
2013-03-03 11:25:49 +09:00
Shenghou Ma
3d50aaf483 cmd/dist: support for NetBSD/ARM
1. when executing a unsupported VFP instruction, the NetBSD kernel somehow
doesn't report SIGILL, and instead just spin and spin, we add a alarm(2)
to detect this case (albeit this is a kernel bug).
2. NetBSD/ARM's VFP11 support is not complete, so temporarily disable it.
3. The default gcc shipped with NetBSD-current mis-optimizes our code
at -O2, so lower the optimization level to -O1 on NetBSD/ARM.

R=dave, rsc
CC=golang-dev
https://golang.org/cl/7286044
2013-03-03 06:50:17 +08:00
Andrew Gerrand
a17b7b9491 archive/tar: remove execute bit from common.go
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7422055
2013-03-03 08:56:08 +11:00
Rémy Oudompheng
1f74aa21d5 runtime: benchmark for appending N bytes should not append N² bytes.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7420051
2013-03-02 21:11:05 +01:00
Rob Pike
aa36afed3b old/netchan: delete as part of move to go.exp/old/netchan
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7450050
2013-03-02 11:45:22 -08:00
Rob Pike
831db8d988 exp: delete all packages except norm
They are moving to code.google.com/p/go.exp.
See also https://golang.org/cl/7463043

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7456047
2013-03-02 11:13:24 -08:00
Dmitriy Vyukov
01a5b66d95 runtime: deadlock tests now work with GOMAXPROCS>1
Fixes #4826.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7434046
2013-03-02 10:41:53 +04:00
Dmitriy Vyukov
46890f60ce runtime: move TestGcSys into a separate process
Fixes #4904.
The problem was that when the test runs the heap had grown to ~100MB,
so GC allows it to grow to 200MB, and so the test fails.
Moving the test to a separate process makes it much more isolated and stable.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7441046
2013-03-02 08:36:06 +02:00
Mikio Hara
fd9049f404 net: skip interface tests when required external command not found
Fixes #4952.

R=alex.brainman
CC=golang-dev
https://golang.org/cl/7445046
2013-03-02 10:56:51 +09:00
Robert Griesemer
83c8cc5436 go/types: fixed a few failure checks
More robustness in case of incorrect programs.

Fixes #4962.

R=dsymonds
CC=golang-dev
https://golang.org/cl/7429047
2013-03-01 17:39:22 -08:00
Carlos Castillo
7c793826d4 cmd/go: pass -intgosize to SWIG
swig >= 2.0.9 requires the size of int values to be passed via a command line flag. Should swig complain about the -intgosize not being supported, then alert the user to their outdated version of swig.

Fixes #4756.

R=golang-dev, minux.ma, iant
CC=golang-dev
https://golang.org/cl/7331048
2013-03-01 16:48:21 -08:00
Rob Pike
f235d5d8d7 runtime: special-case append([]byte, string) for small strings
Also make the crossover point an architecture-dependent constant,
although it's the same everywhere for now.

BenchmarkAppendStr1Byte            416          145  -65.14%
BenchmarkAppendStr4Bytes           743          217  -70.79%
BenchmarkAppendStr8Bytes           421          270  -35.87%
BenchmarkAppendStr16Bytes          415          403   -2.89%
BenchmarkAppendStr32Bytes          415          391   -5.78%

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7459044
2013-03-01 16:41:39 -08:00
Rob Pike
8cfed59941 runtime: special-case small byte appends.
Update #3679.

BenchmarkAppend1Byte            484          199  -58.88%
BenchmarkAppend4Bytes           829          286  -65.50%
BenchmarkAppend8Bytes           484          365  -24.59%
BenchmarkAppend16Bytes          484          498   +2.89%
BenchmarkAppend32Bytes          486          484   -0.41%

R=iant, dave, rsc
CC=golang-dev
https://golang.org/cl/7443047
2013-03-01 14:31:26 -08:00
Russ Cox
0598114a90 runtime/cgo: fix arm build, re-enable test
Fixes #4961.

R=golang-dev, r, minux.ma
CC=golang-dev
https://golang.org/cl/7443048
2013-03-01 16:24:23 -05:00
Rob Pike
749082e2a4 cmd/vet: use go/printer to pretty-print expressions in printf messages
Fixes #4945.
Most examples in this issue now better, but #10 is incomplete and I'm not
certain how to reproduce it. It actually looks like a go/types problem, since
the type being reported is coming directly from that package.
Please reopen the issue if you disagree.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7448046
2013-03-01 12:30:09 -08:00
Rémy Oudompheng
80d2eac14d cmd/cgo: don't reimplement os/exec in util.go.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7450049
2013-03-01 15:04:14 -05:00
Russ Cox
e02168f659 build: skip cgo test on arm
Update #4961.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7451044
2013-03-01 15:01:26 -05:00
Russ Cox
3611553c3b runtime: add atomics to fix arm
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7429046
2013-03-01 14:57:05 -05:00
John Graham-Cumming
f42a11ec8e net: eliminate odd if statement with identical branches
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7447044
2013-03-01 11:56:33 -08:00
Alan Donovan
be6e82e30b exp/ssa/interp: disable interp_test on non-POSIX.
R=gri, rsc
CC=golang-dev
https://golang.org/cl/7422051
2013-03-01 13:17:13 -05:00
Alan Donovan
ba1d5571db exp/ssa/interp: uncomment tests now passing thanks to recent typechecker fixes.
Also: add support for pointer conversions, covered by one new test.

R=gri, bradfitz, dave
CC=golang-dev
https://golang.org/cl/7435047
2013-03-01 12:51:34 -05:00
Alan Donovan
139160eb30 exp/ssa: fix bug in bridge method
Bridge methods for embedded interfaces were
passing the interface twice: once as receiver,
once as first param.
Covered by $GOROOT/test/ddd.go.

Also:
- invent names ("arg%d") for parameters if missing.
- refactoring: move common code for bridge methods into
  createParams and emitTailCall.

R=gri
CC=golang-dev
https://golang.org/cl/7437047
2013-03-01 12:51:19 -05:00
Russ Cox
f5ceeb94a8 build: disable cgo test on openbsd
Update #4878.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7450048
2013-03-01 12:13:42 -05:00
Russ Cox
83f59d0a4f net/http/cgi: disable TestCopyError to try to fix darwin/386 on builder
Update #4958.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7434047
2013-03-01 12:00:24 -05:00
Russ Cox
08a1631cda runtime: fix build on openbsd, plan9
R=golang-dev
CC=golang-dev
https://golang.org/cl/7438052
2013-03-01 11:57:50 -05:00
Russ Cox
2202663a93 build: disable cgo on windows
Update #4955.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7435049
2013-03-01 11:55:00 -05:00
Russ Cox
418dd410db syscall: disable TestPassFD on openbsd
Update #4956.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7417048
2013-03-01 11:51:32 -05:00
Russ Cox
e6a3e22c75 runtime: start all threads with runtime.mstart
Putting the M initialization in multiple places will not scale.
Various code assumes mstart is the start already. Make it so.

R=golang-dev, devon.odell
CC=golang-dev
https://golang.org/cl/7420048
2013-03-01 11:44:43 -05:00
Russ Cox
d0d7416d3f runtime: more build fixing
Move the mstartfn into its own field.
Simpler, more likely to be correct.

R=golang-dev, devon.odell
CC=golang-dev
https://golang.org/cl/7414046
2013-03-01 09:24:17 -05:00
Russ Cox
c5f694a5c9 runtime: fix new scheduler on freebsd, windows
R=devon.odell
CC=golang-dev
https://golang.org/cl/7443046
2013-03-01 08:30:11 -05:00
Russ Cox
8d732368c2 cmd/ld: fix windows build
Fixes #4948.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/7445045
2013-03-01 05:03:25 -08:00
Russ Cox
776b51850b runtime/cgo: fix crosscall2 on arm
This time for sure.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7449045
2013-03-01 05:02:41 -08:00
Dmitriy Vyukov
779c45a507 runtime: improved scheduler
Distribute runnable queues, memory cache
and cache of dead G's per processor.
Faster non-blocking syscall enter/exit.
More conservative worker thread blocking/unblocking.

R=dave, bradfitz, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/7314062
2013-03-01 13:49:16 +02:00
Russ Cox
d17506e52d runtime/cgo: make crosscall2 5a/6a/8a-assembled
There is a #pragma dynexport crosscall2, to help SWIG,
and 6l cannot export the symbol if it doesn't get to see it.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7448044
2013-02-28 22:14:55 -08:00
Russ Cox
83c5d07c0e runtime/cgo: fix arm build
During my global search and replace I forgot to open *.S (capital).

R=golang-dev
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/7415047
2013-03-01 00:30:19 -05:00
Russ Cox
7556ccc7b1 cmd/cgo, cmd/ld: new cgo object file section
Switch to new pragma names, but leave old ones available for now.
Merge the three cgo-related sections in the .6 files into a single
cgo section.

R=golang-dev, iant, ality
CC=golang-dev
https://golang.org/cl/7424048
2013-03-01 00:27:57 -05:00
Jan Ziak
94955f9b40 runtime: check the value returned by runtime·SysAlloc
R=golang-dev, rsc
CC=golang-dev, minux.ma
https://golang.org/cl/7424047
2013-03-01 00:21:08 -05:00
Andrew Gerrand
df60c0a3b8 html/template: fix doc typo
Fixes #4950.

R=golang-dev, peter
CC=golang-dev
https://golang.org/cl/7415046
2013-03-01 14:57:59 +11:00
Alex Brainman
3889d8afe5 path/filepath: better error reporting during TestWinSplitListTestsAreValid
Fixes #4930.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7424043
2013-03-01 14:49:55 +11:00
Alex Brainman
e72d1a9575 libmach: many pe handling fixes
- implement windows pread;
- set correct Fhdr.type;
- add ImageBase to all pe "virtual" addresses;
- correct settext parameter order;
- use pclntab/epclntab to find line numbers.

Fixes #4841.
Fixes #4926.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7405050
2013-03-01 14:49:23 +11:00
Alex Brainman
211589a9ed run.bat: disable race detector test
R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7439048
2013-03-01 14:19:56 +11:00
Alan Donovan
abbbb4283a go/types: fix regression in type checking of RangeStmt.
Now that untyped expressions are done in two phases, the
identity of operand.expr is used as a map key; when reusing
operand values we now must be careful to update the
expr field.

R=gri
CC=golang-dev
https://golang.org/cl/7444049
2013-02-28 20:37:25 -05:00
Brad Fitzpatrick
0bc38b7fe4 net/http: don't special-case multipart/byteranges responses
Fixes #4767

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7435046
2013-02-28 16:58:26 -08:00
Brad Fitzpatrick
523cb45c9d net/http: document net/http/cookiejar on CookieJar
R=golang-dev, nigeltao, adg
CC=golang-dev
https://golang.org/cl/7444048
2013-02-28 16:58:14 -08:00
Nigel Tao
f29b0cf955 net/http/cookiejar: move cookiejar from exp/cookiejar to
net/http/cookiejar.

This is a straight rename. There are no code changes.

Fixes #1960.

R=rsc, adg
CC=dr.volker.dobler, golang-dev
https://golang.org/cl/7436043
2013-03-01 11:15:00 +11:00
Robert Griesemer
3a9fcc45f6 go/types: fix type-checking of shift expressions
Completely rethought shift expression type checking.
Instead of attempting to type-check them eagerly, now
delay the checking of untyped constant lhs in non-
constant shifts until the final expression type
becomes clear. Once it is clear, update the respective
expression tree with the final (not untyped) type and
check respective shift lhs' where necessary.

This also cleans up another conundrum: How to report
the type of untyped constants as it changes from
untyped to typed. Now, Context.Expr is only called
for an expresion x once x has received its final
(not untyped) type (for constant initializers, the
final type may still be untyped).

With this CL all remaining std lib packages that
did not typecheck due to shift errors pass now.

TODO: There's a lot of residual stuff that needs
to be cleaned up but with this CL all tests pass
now.

R=adonovan, axwalk
CC=golang-dev
https://golang.org/cl/7381052
2013-02-28 15:27:52 -08:00
Dmitriy Vyukov
38d4d3c66a runtime: refactor Syscall benchmark
And add a benchmark where #goroutines>GOMAXPROCS,
because it's the most interesting case.
Current results on darwin/amd64, Intel Core 2 Duo 2.13 GHz, 2 cores:
BenchmarkSyscall	100000000	        56.0 ns/op
BenchmarkSyscall-2	50000000	        57.2 ns/op
BenchmarkSyscallWork	10000000	       635 ns/op
BenchmarkSyscallWork-2	10000000	       315 ns/op
BenchmarkSyscallExcess	 1000000	      2698 ns/op
BenchmarkSyscallExcess-2	 5000000	      1192 ns/op
BenchmarkSyscallExcessWork	 1000000	      2832 ns/op
BenchmarkSyscallExcessWork-2	 2000000	      1966 ns/op

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7415044
2013-03-01 01:10:34 +02:00
Dmitriy Vyukov
72b09bd7ae runtime: add matrix multiplication benchmark
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7431047
2013-03-01 00:41:45 +02:00
Akshat Kumar
bd88990722 os: Plan 9: allocate space for a string in Rename
The Name field of the stat structure is variable length
and the marshalling code in package syscall requires
a buf long enough to contain the Name as well as the
static data. This change makes sure that the buffer in
os.Rename is allocated with the appropriate length.

R=rsc, rminnich, ality, r
CC=golang-dev
https://golang.org/cl/7453044
2013-02-28 14:20:42 -08:00
Russ Cox
5bffa3b88e runtime/cgo: move common symbol overrides into 6c-compiled code
There are some function pointers declared by 6c in
package runtime without initialization and then also
declared in package runtime/cgo with initialization,
so that if runtime/cgo is linked in, the function pointers
are non-nil, and otherwise they are nil. We depend on
this property for implementing non-essential cgo hooks
in package runtime.

The declarations in package runtime are 6c-compiled
and end up in .6 files. The declarations in package runtime/cgo
are gcc-compiled and end up in .o files. Since 6l links the .6
and .o files together, this all works.

However, when we switch to "external linking" mode,
6l will not see the .o files, and it would be up to the host linker
to resolve the two into a single initialized symbol.
Not all host linkers will do this (in particular OS X gcc will not).

To fix this, move the cgo declarations into 6c-compiled code,
so that they end up in .6 files, so that 6l gets them no matter what.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7440045
2013-02-28 13:54:23 -08:00
Russ Cox
349cc74867 encoding/gob: fix copyright
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7423046
2013-02-28 13:30:59 -08:00
Russ Cox
f8d49b509b runtime/cgo: make symbol naming consistent
The naming in this package is a disaster.
Make it all consistent.

Remove some 'static' from functions that will
be referred to from other files soon.

This CL is purely renames using global search and replace.

Submitting separately so that real changes will not
be drowned out by these renames in future CLs.

TBR=iant
CC=golang-dev
https://golang.org/cl/7416046
2013-02-28 16:24:38 -05:00
Russ Cox
40ed753ebd cmd/ld: fix symbol table sorting
runtime: double-check that symbol table is sorted

If the symbol table is unsorted, the binary search in findfunc
will not find its func, which will make stack traces stop early.
When the garbage collector starts using the stack tracer,
that would be a serious problem.

The unsorted symbol addresses came from from two things:

1. The symbols in an ELF object are not necessarily sorted,
   so sort them before adding them to the symbol list.

2. The __i686.get_pc_thunk.bx symbol is present in multiple
   object files and was having its address adjusted multiple
   times, producing an incorrect address in the symbol table.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7440044
2013-02-28 16:21:58 -05:00
Rob Pike
1bf66f081f all: fix a few more printf arg bugs found by go vet
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7413045
2013-02-28 11:33:08 -08:00
Rob Pike
3dc7f17e89 cmd/vet: %b is a valid floating-point format.
Also add a report about "invalid type" from gotype, if -v is set.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7420045
2013-02-28 11:32:53 -08:00
Robin Eklind
f82ea304f0 cgo: fix reference to puts in implementation comment.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7431046
2013-02-28 11:31:52 -08:00
Russ Cox
b89000bcab cmd/cgo: extend implementation comment
This is the plan for how to make host linking work with
the rest of the system.

There are two complications:

1. It is a goal to preserve the property that pure Go programs
(even ones importing "net") can be compiled without needing
gcc, so that a Go toolchain download works out of the box.
This forces the support for two linking modes: with and without
gcc.

2. It is a goal to allow users with old copies of SWIG to continue
to use those copies. This forces the support for "internal only"
packages. Perhaps it is reasonable to require a new SWIG.
I don't know.

R=iant
CC=golang-dev
https://golang.org/cl/7433043
2013-02-28 10:44:29 -08:00
Matt Brown
1300fb5449 strconv: use Quote to escape the input string for failed conversion errors
This reveals the presence of control and non-printable characters in the
errors returned by the Parse functions.  Also add unit tests for NumError.

R=golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/7393075
2013-02-28 10:08:05 -08:00
John Graham-Cumming
087b708fd3 net/http: fix handling of HEAD in ReadResponse and (*http.Response).Write
The test suite for ReadResponse was not checking the error return on the io.Copy
on the body. This was masking two errors: the handling of chunked responses to
HEAD requests and the handling of Content-Length > 0 to HEAD.

The former manifested itself as an 'unexpected EOF' when doing the io.Copy
because a chunked reader was assigned but there were no chunks to read. The
latter cause (*http.Response).Write to report an error on HEAD requests
because it saw a Content-Length > 0 and expected a body.

There was also a missing \r\n in one chunked test that meant that the chunked
encoding was malformed. This does not appear to have been intentional.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7407046
2013-02-28 09:29:50 -08:00
Shenghou Ma
6ecb39fce6 cmd/go: fix "go run" cgo source when cgo is disabled
also move a cgo-depend test to appropriate source file in runtime.

R=golang-dev, dave, adg, rsc
CC=golang-dev
https://golang.org/cl/7393063
2013-02-28 16:07:26 +08:00
Rémy Oudompheng
67d0445c87 log/syslog: fix race in test between channel close and accept.
Fixes #4769.

R=golang-dev, dave, adg, bradfitz
CC=fullung, golang-dev
https://golang.org/cl/7322089
2013-02-28 07:48:16 +01:00
Rémy Oudompheng
e2f9e816b7 runtime: fix racefuncenter argument corruption.
Revision 6a88e1893941 corrupts the argument to
racefuncenter by pushing the data block pointer
to the stack.

Fixes #4885.

R=dvyukov, rsc
CC=golang-dev
https://golang.org/cl/7381053
2013-02-28 07:32:29 +01:00
Akshat Kumar
b2249f2018 net: pass tests on Plan 9
Ignore problematic tests and un-ignore one
we can now pass.

R=rsc, rminnich, ality, dave, bradfitz
CC=golang-dev
https://golang.org/cl/7396060
2013-02-28 07:18:02 +01:00
Mikio Hara
322214cf54 net: fix slow network interface manipulations
This CL reduces unnecessary network facility lookups introduced
by recent changes below.

changeset: 15798:53a4da6a4f4a
net: return correct point-to-point interface address on linux

changeset: 15799:a81ef8e0cc05
net: set up IPv6 scoped addressing zone for network facilities

Also adds a test case for issue	4839.

Benchmark results on linux/amd64, virtual machine:
benchmark                                 old ns/op    new ns/op    delta
BenchmarkInterfaces-2                         80487        80382   -0.13%
BenchmarkInterfaceByIndex-2                   72013        71391   -0.86%
BenchmarkInterfaceByName-2                    79865        80101   +0.30%
BenchmarkInterfaceAddrs-2                     42071       829677  +1872.09%
BenchmarkInterfacesAndAddrs-2                 35016       607622  +1635.27%
BenchmarkInterfacesAndMulticastAddrs-2       169849       169082   -0.45%
old: 15797:9c3930413c1b, new: tip

Benchmark results on linux/amd64, virtual machine:
benchmark                                 old ns/op    new ns/op    delta
BenchmarkInterfaces-2                         80487        81459   +1.21%
BenchmarkInterfaceByIndex-2                   72013        71512   -0.70%
BenchmarkInterfaceByName-2                    79865        80567   +0.88%
BenchmarkInterfaceAddrs-2                     42071       120108  +185.49%
BenchmarkInterfacesAndAddrs-2                 35016        33259   -5.02%
BenchmarkInterfacesAndMulticastAddrs-2       169849        82391  -51.49%
old: 15797:9c3930413c1b, new: tip+CL7400055

Benchmark results on darwin/amd64:
benchmark                                 old ns/op    new ns/op    delta
BenchmarkInterfaces-2                         34402        34231   -0.50%
BenchmarkInterfaceByIndex-2                   13192        12956   -1.79%
BenchmarkInterfaceByName-2                    34791        34388   -1.16%
BenchmarkInterfaceAddrs-2                     36565        63906  +74.77%
BenchmarkInterfacesAndAddrs-2                 17497        31068  +77.56%
BenchmarkInterfacesAndMulticastAddrs-2        25276        66711  +163.93%
old: 15797:9c3930413c1b, new: tip

Benchmark results on darwin/amd64:
benchmark                                 old ns/op    new ns/op    delta
BenchmarkInterfaces-2                         34402        31854   -7.41%
BenchmarkInterfaceByIndex-2                   13192        12950   -1.83%
BenchmarkInterfaceByName-2                    34791        31926   -8.23%
BenchmarkInterfaceAddrs-2                     36565        42144  +15.26%
BenchmarkInterfacesAndAddrs-2                 17497        17329   -0.96%
BenchmarkInterfacesAndMulticastAddrs-2        25276        24870   -1.61%
old: 15797:9c3930413c1b, new: tip+CL7400055

Update #4234.
Fixes #4839 (again).
Fixes #4866.

R=golang-dev, fullung
CC=golang-dev
https://golang.org/cl/7400055
2013-02-28 14:58:41 +09:00
Akshat Kumar
f0a8b610e7 net, os, syscall: Plan 9: adjust error handling
syscall: Use NewError for all system errors and introduce
        some new errors for compatibility with other packages
        and proper error handling in net. Also introduce
        Temporary and Timeout methods on ErrorString.

net: Make errors from dial, accept, listen functions follow the
        OpError standard and discern whether the underlying
        error came from syscall. Since Plan 9 uses a correspondence
        between file and network operations, all system error
        reporting happens through the underlying file operation.
        In Go code, we go through package os for file operations,
        so there is another level of indirection in error types.
        This change allows us to compare the errors with those in
        package syscall, when appropriate.

os: Just use the error string already present in package os,
        instead of calling out to package syscall.

R=rsc, ality, rminnich, bradfitz
CC=golang-dev
https://golang.org/cl/7398054
2013-02-28 06:43:21 +01:00
Akshat Kumar
1f62a784f4 syscall: Plan 9: keep a consistent environment array
Map order is non-deterministic. Introduce a new
environment string array that tracks the env map.
This allows us to produce identical results for
Environ() upon successive calls, as expected by the
TestConsistentEnviron test in package os.

R=rsc, ality, rminnich, bradfitz, r
CC=golang-dev
https://golang.org/cl/7411047
2013-02-28 06:39:02 +01:00
Russ Cox
062a239046 cmd/cgo: add implementation comment
R=golang-dev, r, bradfitz, iant
CC=golang-dev
https://golang.org/cl/7407050
2013-02-27 20:55:01 -08:00
Nigel Tao
3b69efb010 exp/cookiejar: eliminate some "."+str garbage.
It's not a big deal, but it's easy to fix.

R=dsymonds
CC=dr.volker.dobler, golang-dev
https://golang.org/cl/7425043
2013-02-28 13:46:26 +11:00
Volker Dobler
1069d25e37 exp/cookiejar: add some more tests
New tests added for port handling and IDNA domains.
A new test case contains several redundant
tests but provides a nice documentation of the
implemented rules for domain handling.

R=nigeltao
CC=golang-dev
https://golang.org/cl/7393070
2013-02-28 11:18:39 +11:00
Gustavo Niemeyer
64648986e3 net/http: don't drop error on request write
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7230059
2013-02-27 21:15:36 -03:00
Rob Pike
f12796e9f7 builtin: document appending a string to a byte slice
Fixes #4873.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7421043
2013-02-27 16:11:17 -08:00
Brad Fitzpatrick
abf5700a15 syscall: add MSG_FASTOPEN to Linux
Update #4842

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7369060
2013-02-27 15:51:51 -08:00
Rob Pike
9e19337de9 cmd/vet: continue past first error
Also delete bogus tests for f.pkg (does the file have a package) since all
files have a package attached. The tests for pkg.types and pkg.values
suffice.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7418043
2013-02-27 15:43:33 -08:00
Robert Griesemer
25c99300b9 go/types: don't crash if there are no hints
R=r
CC=golang-dev
https://golang.org/cl/7375060
2013-02-27 15:22:14 -08:00
Brad Fitzpatrick
11776a39a1 net/http: add Transport.CancelRequest
Permits all sorts of custom HTTP timeout policies without
adding a new Transport timeout Duration for each combination
of HTTP phases.

This keeps track internally of which TCP connection a given
Request is on, and lets callers forcefully close the TCP
connection for a given request, without actually getting
the net.Conn directly.

Additionally, a future CL will implement res.Body.Close (Issue
3672) in terms of this.

Update #3362
Update #3672

R=golang-dev, rsc, adg
CC=golang-dev
https://golang.org/cl/7372054
2013-02-27 15:20:13 -08:00
Robert Griesemer
029457aab5 go/types: don't crash when assigning to undefined variables
R=adonovan
CC=golang-dev
https://golang.org/cl/7369059
2013-02-27 14:24:41 -08:00
Alan Donovan
877153f04a exp/ssa: fix *bsd breakage.
Use portable ReadDirent, not linux Getdents.

R=gri
TBR=gri
CC=golang-dev
https://golang.org/cl/7405051
2013-02-27 17:00:02 -05:00
Alan Donovan
1c5e079600 exp/ssa: a number of bug fixes.
ssadump:
- permit naming a package (not just *.go files) on command line.
- set BuildSerially flag when setting Log* flags
  (Q. should instead the logging functions take a lock?)

Builder:
- fixed bug when calling variadic function with zero '...'-params.
  Added regression test.

interp:
- more external functions:
   the 'error' interface
   bytes.{Equal,IndexByte}
   reflect.(Value).{Bool,NumOut,Out}
   syscall.{Close,Fstat,Read,Open,Stat,Lstat,Fstat,
     Getdents,ParseDirents,Getwd}
- permit comparisons between *Function and *closure.

With this CL, ssadump can now interpret ssadump itself (!),
loading, parsing, typing, SSA-building, and running
println("Hello, World!").  While a fmt-based equivalent still
lacks some external routines, e.g. math/big, I think there are
diminishing returns in expanding the interpreter (and
debugging it is starting to feel like "Inception").

I'm pretty confident this package is now good enough for wider use.

R=gri
CC=golang-dev
https://golang.org/cl/7392053
2013-02-27 16:43:16 -05:00
Brad Fitzpatrick
d1d38c535d net: fix windows build
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7392054
2013-02-27 12:42:26 -08:00
Brad Fitzpatrick
752fec22bb net: add DialOpt, the extensible Dial w/ options dialer
Add DialOpt. So we have:

func Dial(net, addr string) (Conn, error)
func DialTimeout(net, addr string, timeout time.Duration) (Conn, error)
func DialOpt(addr string, opts ...DialOption) (Conn, error)

DialTimeout (and Dial) are regrettable in retrospect. Maybe
in a future Go we'll be back down to one Dial, with DialOpt
becoming Dial.

DialOpt looks like:

c, err := net.DialOpt("google.com:80")  // tcp is default
c, err := net.DialOpt("google.com:80", net.Timeout(30 * time.Second))
c, err := net.DialOpt("google.com:80", net.TCPFastOpen())
c, err := net.DialOpt("google.com:80", net.LocalAddr(..))
c, err := net.DialOpt("google.com:53", net.Network("udp6"))

And then: (clustered in godoc)

type DialOption interface { /* private only */ }
  func Deadline(time.Time) DialOption
  func LocalAddr(Addr) DialOption
  func Network(string) DialOption
  func TCPFastOpen() DialOption
  func Timeout(time.Duration) DialOption

I'm pretty confident we could add Happy Eyeballs to this too.

Fixes #3097
Update #3610
Update #4842

R=golang-dev, r, dave, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7365049
2013-02-27 11:59:36 -08:00
Dmitriy Vyukov
6cdfb00f4e runtime: more changes in preparation to the new scheduler
add per-P cache of dead G's
add global runnable queue (not used for now)
add list of idle P's (not used for now)

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7397061
2013-02-27 21:17:53 +02:00
Daniel Morsing
43c04ba1b8 cmd/gc: don't emit type instructions for nonexisting locals
If all locals are optimized away, the type instructions would stay in the instruction stream. Call fixautoused to scrub the output.

Fixes #4915.

R=rsc
CC=golang-dev
https://golang.org/cl/7385055
2013-02-27 19:47:14 +01:00
Volker Dobler
73c21b1312 sort: use proper mass unit in example
The values for the planet masses are given in
earth mass, not solar mass.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/7368054
2013-02-27 10:44:50 -08:00
Brad Fitzpatrick
839d47add5 net/http: add Transport.ResponseHeaderTimeout
Update #3362

R=golang-dev, adg, rsc
CC=golang-dev
https://golang.org/cl/7369055
2013-02-27 08:47:08 -08:00
Alan Donovan
37cb6f809a exp/ssa: resolve botched merge.
While submitting CL 7371051 I accidentally reverted much of CL
7395052.  This change restores it.

R=gri
TBR=gri
CC=golang-dev
https://golang.org/cl/7364051
2013-02-27 11:39:39 -05:00
Jan Ziak
01ab9a012a runtime: improve precision of GC_REGION
R=rsc
CC=golang-dev
https://golang.org/cl/7383054
2013-02-27 08:28:53 -08:00
Alan Donovan
5a09f1b3be exp/ssa: make invokation of deferred procedure calls explicit.
The correct semantics of named result parameters and deferred
procedures cannot be implemented with the existing Ret
instruction alone, since the required sequence is:
(1) evaluate return operands and parallel-assign them to
    named result parameters
(2) invoke deferred procedures
(3) load named result parameters to form result tuple.

We introduce a new 'rundefers' instruction that explicitly
invokes the deferred procedure calls, and we generate code
that follows the sequence above.

Most functions do not use deferred procedures but this cannot
be known in a single pass.  So, we add an optimisation to
eliminate redundant 'rundefers'; it is piggybacked on the
existing pass done for "lifting".

Added tests.

R=gri
CC=golang-dev
https://golang.org/cl/7411043
2013-02-27 10:35:23 -05:00
Alan Donovan
3fc8cd054a exp/ssa: perform all packages' BUILD phases in parallel.
Details:
- move Builder.nTo1Vars into package => thread-safe.
- add BuildSerially builder mode flag to disable concurrency.
- add Builder.BuildAllPackages method.

Benchmark: BuildAllPackages for $GOROOT/test/append.go drops
to 83ms from 190ms (GOMAXPROCS=8).

R=gri
CC=golang-dev
https://golang.org/cl/7371051
2013-02-27 10:26:24 -05:00
Marcel van Lohuizen
7add9b7f6a exp/locale/collate: fixed go vet error.
R=r, dave
CC=golang-dev
https://golang.org/cl/7403055
2013-02-27 14:09:42 +01:00
Marcel van Lohuizen
5afa271ce3 exp/locale/collate: several changes based on comments on CL 7060051
which was submitted earlier.

R=r
CC=golang-dev
https://golang.org/cl/7402048
2013-02-27 11:08:18 +01:00
Matthew Dempsky
f853e9aa4e syscall: Fix FD passing on OpenBSD
Fixes #3349.

R=bradfitz, dave, minux.ma
CC=golang-dev
https://golang.org/cl/7383056
2013-02-27 15:19:23 +11:00
Russ Cox
d21b1922c6 libmach: fix build (set and not used)
TBR=golang-dev
CC=golang-dev
https://golang.org/cl/7401053
2013-02-26 22:51:47 -05:00
Russ Cox
56a06db360 cmd/ld: change GC_CALL to 32-bit relative address
The current code uses 64-bit pc-relative on 64-bit systems,
but in ELF linkers there is no such thing, so we cannot
express this in a .o file. Change to 32-bit.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7383055
2013-02-26 19:42:56 -08:00
Russ Cox
c8dcaeb25d cmd/ld, runtime: adjust symbol table representation
This CL changes the encoding used for the Go symbol table,
stored in the binary and used at run time. It does not change
any of the semantics or structure: the bits are just packed
a little differently.

The comment at the top of runtime/symtab.c describes the new format.

Compared to the Go 1.0 format, the main changes are:

* Store symbol addresses as full-pointer-sized host-endian values.
  (For 6g, this means addresses are 64-bit little-endian.)

* Store other values (frame sizes and so on) varint-encoded.

The second change more than compensates for the first:
for the godoc binary on OS X/amd64, the new symbol table
is 8% smaller than the old symbol table (1,425,668 down from 1,546,276).

This is a required step for allowing the host linker (gcc) to write
the final Go binary, since it will have to fill in the symbol address slots
(so the slots must be host-endian) and on 64-bit systems it may
choose addresses above 4 GB.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7403054
2013-02-26 22:38:14 -05:00
Nigel Tao
15cce227c7 exp/cookiejar: add a test for canonicalHost errors.
R=dr.volker.dobler
CC=golang-dev
https://golang.org/cl/7389048
2013-02-27 13:05:57 +11:00
Rob Pike
2c2934eeb5 sort: add an example showing sorting struct by different keys
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7376058
2013-02-26 17:17:44 -08:00
Brad Fitzpatrick
65fcb39dc7 net/http: fix a bunch of test leaks
And one real leak in TimeoutHandler.

Fixes #4821

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7369056
2013-02-26 17:12:50 -08:00
Robert Griesemer
60066754fd go/types: be more robust in presence of multiple errors
- better documentation of Check
- better handling of (explicit) internal panics
- gotype: don't stop after 1st error

R=adonovan, r
CC=golang-dev
https://golang.org/cl/7406052
2013-02-26 14:33:24 -08:00
Dave Cheney
98d44d140d syscall: fix FD passing on FreeBSD and NetBSD
Fixes #3348.

R=devon.odell, minux.ma, bradfitz, mdempsky
CC=golang-dev
https://golang.org/cl/7406050
2013-02-27 09:13:15 +11:00
Alan Donovan
c8c16cfbb9 exp/ssa: support multiple labels on same statement.
Actually it already worked since the spec only requires that
the one immediately preceding a for/switch/... be usable as
the target of a break or continue statement.

Added a test.
Also: allocate Function.lblocks on first use.

R=gri
CC=golang-dev
https://golang.org/cl/7365058
2013-02-26 14:07:03 -05:00
Rob Pike
6c2cbdb142 cmd/vet: fix printf test for unsafe Pointer
And fix test. Pointer to unsafe.Pointer tests nothing important...
Also identify the incorrect type: go/types.Type is a Stringer.

Also fix a couple of incorrect format verbs found by new printf checker,
now that we can run it on more files.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7385051
2013-02-26 10:36:13 -08:00
Alan Donovan
bd92dd6a5f exp/ssa: reimplement logic for field selection.
The previous approach desugared the ast.SelectorExpr
to make implicit field selections explicit.  But:
1) it was clunky since it required allocating temporary
   syntax trees.
2) it was not thread-safe since it required poking
   types into the shared type map for the new ASTs.
3) the desugared syntax had no place to represent the
   package lexically enclosing each implicit field
   selection, so it was as if they all occurred in the
   same package as the explicit field selection.
   This meant unexported field names changed meaning.

This CL does what I should have done all along: just
generate the SSA instructions directly from the original
AST and the promoted field information.

Also:
- add logStack util for paired start/end log messages.
  Useful for debugging crashes.

R=gri
CC=golang-dev
https://golang.org/cl/7395052
2013-02-26 13:32:22 -05:00
Anthony Martin
16eb2c0b7a runtime: fix stack cache typos
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7370050
2013-02-26 09:59:17 -08:00
Anthony Martin
2b39e418be all: clean up C function prototypes
R=minux.ma, rsc, akumar, bradfitz
CC=golang-dev
https://golang.org/cl/7313070
2013-02-26 09:51:33 -08:00
Akshat Kumar
fa625fb39a os/exec: Pass tests on Plan 9
Adjust the exit status string for Plan 9.

Upon allocating >100 file descriptors, Plan 9
raises a warning. Moreover, the Go runtime for
32-bit version of Plan 9 keeps /dev/bintime
open for its implementation of runtime.nanotime().
This change accounts for these things in
TestExtraFiles.

R=rsc, rminnich, ality, bradfitz
CC=golang-dev
https://golang.org/cl/7363056
2013-02-26 09:40:55 -08:00
Anthony Martin
f08acae76e build: do not set GOBIN on Plan 9
Also, I synced the rc files with changes
that have been made to make.bash, etc.

R=seed, rminnich, r
CC=golang-dev
https://golang.org/cl/7389049
2013-02-26 09:25:46 -08:00
Anthony Martin
c14d255ac5 cmd/go: do not print GCC environment variables on Plan 9
R=seed, rminnich, r, minux.ma
CC=golang-dev
https://golang.org/cl/7397059
2013-02-26 08:34:47 -08:00
Robert Griesemer
a5e42f2611 go/types: fix sizeof computations
Context.Alignof/Offsetsof/Sizeof now provide means
to customize the type checker for a given platform.

- provide Context.Offsetsof to specify the
  offsets of struct fields
- use the correct sizes for ints, uint, uintptrs
  in constant computations
- moved all size computations into separate file
  (sizes.go)
- fixed a bug with string constant slicing

R=adonovan, axwalk
CC=golang-dev
https://golang.org/cl/7363054
2013-02-25 22:06:58 -08:00
Robert Griesemer
3f132a8236 go/types: more robust imports
- imported objects don't have position information
- gc exported data contains non-exported objects at
  the top-level, guard against them
- better error message when dot-imports conflict
  with local declarations

R=adonovan, r
CC=golang-dev
https://golang.org/cl/7379052
2013-02-25 20:43:35 -08:00
Robert Griesemer
1caaff6b5a go/types: embedded fields can be predeclared types
R=adonovan, r
CC=golang-dev
https://golang.org/cl/7376055
2013-02-25 20:42:29 -08:00
Cosmos Nicolaou
d6a057c90e cmd/godoc: add support for display Notes parsed by pkg/go/doc
pkg/go/doc: move BUG notes from Package.Bugs to the general Package.Notes field.
Removing .Bugs would break existing code so it's left in for now.

R=gri, gri, gary.burd, dsymonds, rsc, kevlar
CC=golang-dev
https://golang.org/cl/7341053
2013-02-25 20:34:09 -08:00
Alex Brainman
26498684cb os: use windows ReadConsole to read from console
Fixes #4760.

R=golang-dev, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/7312053
2013-02-26 14:18:48 +11:00
Akshat Kumar
d2326febd5 syscall, runtime: Plan 9: use nanotime syscall on amd64
Separates the implementation of nanotime on 64-bit
version of Plan 9 from that on the 32-bit version.
The former uses a syscall.

R=rsc, rminnich, ality
CC=golang-dev
https://golang.org/cl/7379051
2013-02-26 01:56:08 +01:00
Nigel Tao
ffa0f83060 exp/cookiejar: implement IDNA/Punycode's toASCII.
R=dr.volker.dobler
CC=golang-dev
https://golang.org/cl/7398049
2013-02-26 11:55:41 +11:00
Rob Pike
78b3ef261d cmd/vet: silence error from type checker unless verbose is set.
Also restores the checking of _test.go files, which disappeared
as a result of the package-at-a-time change.
Fixes #4895.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7399051
2013-02-25 16:29:09 -08:00
Akshat Kumar
b461fe660d net: Implement FileListener, FileConn, and File methods for Plan 9
Functions for representing network connections as files
and vice versa, on Plan 9.

Representing network connections as files is not so
straight-forward, because a network connection on Plan 9
is represented by a host of files rather than a single
file descriptor (as is the case on UNIX). We use the
type system to distinguish between listeners and
connections, returning the control file in the former
case and the data file in the latter case.

R=rsc, rminnich, ality, akumar, bradfitz
CC=golang-dev
https://golang.org/cl/7235068
2013-02-26 01:26:40 +01:00
Rob Pike
31444a796a cmd/vet: move the tests into separate files
Then mark them with a build tag so they're not compiled into the binary.
They are called test_*.go rather than *_test.go because they are not
for go test. Use make test to test the command.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7377052
2013-02-25 16:25:34 -08:00
Rémy Oudompheng
71b3b46073 cmd/gc: accept cases with same value but different types in switch.
Fixes #4781.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7365056
2013-02-26 00:45:43 +01:00
Rémy Oudompheng
9e66ee4562 cmd/gc: fix corruption in export of &T{} literals.
Composite literals using the &T{} form were incorrectly
exported, leading to weird errors at import time.

Fixes #4879.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7395054
2013-02-26 00:43:31 +01:00
Rémy Oudompheng
9fe60801ae cmd/gc: apply escape analysis results to closures.
This avoids an allocation when closures are used
as "macros", in Walk idioms, or as argument to defer.

benchmark                old ns/op    new ns/op    delta
BenchmarkSearchWrappers       1171          354  -69.77%
BenchmarkCallClosure             3            3  -12.54%
BenchmarkCallClosure1          119            7  -93.95%
BenchmarkCallClosure2          183           74  -59.18%
BenchmarkCallClosure3          187           75  -59.57%
BenchmarkCallClosure4          187           76  -58.98%

Compared to Go 1:
benchmark                  old ns/op    new ns/op    delta
BenchmarkSearchWrappers         3208          354  -88.97%

Fixes #3520.

R=daniel.morsing, bradfitz, minux.ma, dave, rsc
CC=golang-dev
https://golang.org/cl/7397056
2013-02-26 00:40:28 +01:00
Shenghou Ma
4692711d7f strconv, fmt: clarify behavior of CanBackquote and "%#q".
Fixes #4858.

R=golang-dev, bradfitz, r, rsc
CC=golang-dev
https://golang.org/cl/7387044
2013-02-26 06:33:59 +08:00
Andrew Gerrand
89cf67eb20 time: handle very large sleep durations
Fixes #4903.

R=golang-dev, daniel.morsing, dave, r
CC=golang-dev
https://golang.org/cl/7388056
2013-02-26 09:23:58 +11:00
Shenghou Ma
8cdee79063 libmach, cmd/5a, cmd/5c, cmd/5g, cmd/5l: enable DWARF type info for Linux/ARM
Fixes #3747.

Update #4912
This CL adds gotype into .5 object file.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7376054
2013-02-26 06:15:29 +08:00
Akshat Kumar
b6e322dcf5 syscall: Plan9, amd64: fix syscall error handling in assembly
Syscalls return `-1' on error and the representation is always
32-bits. The `$-1' literal in 64-bit assembly is always the
64-bit representation. So this change makes sure that we
always do a 32-bit comparison when checking for error.
Also makes sure that in the error case, we return a 64-bit
`-1' from runtime.seek.

Fixes the arithmetic for handling the error-string in
runtime.Syscall6.

R=golang-dev, rminnich, rsc, ality, minux.ma
CC=golang-dev
https://golang.org/cl/7399052
2013-02-25 22:40:14 +01:00
Dmitriy Vyukov
4eb7ba743d runtime/cgo: fix deadlock involving signals on darwin
sigprocmask() is process-wide on darwin, so two concurrent
libcgo_sys_thread_start() can result in all signals permanently
blocked, which in particular blocks handling of nil derefs.
Fixes #4833.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/7324058
2013-02-25 16:36:29 -05:00
Brad Fitzpatrick
e3ed4cace0 net/http/cgi: make tests compile on plan9
Don't reference the non-portable syscall.Signal(0).

Maybe they'll pass too. Untested. plan9 bit from
Akshat Kumar.

R=golang-dev, akumar
CC=golang-dev
https://golang.org/cl/7370049
2013-02-25 13:27:15 -08:00
Russ Cox
aa3efb28f0 cmd/gc: can stop tracking gotype in regopt
Now that the type information is in TYPE instructions
that are not rewritten by the optimization passes,
we don't have to try to preserve the type information
(no longer) attached to MOV instructions.

R=ken2
CC=golang-dev
https://golang.org/cl/7402054
2013-02-25 16:11:34 -05:00
Jan Ziak
a656f82071 runtime: precise garbage collection of channels
This changeset adds a mostly-precise garbage collection of channels.
The garbage collection support code in the linker isn't recognizing
channel types yet.

Fixes issue http://stackoverflow.com/questions/14712586/memory-consumption-skyrocket

R=dvyukov, rsc, bradfitz
CC=dave, golang-dev, minux.ma, remyoudompheng
https://golang.org/cl/7307086
2013-02-25 15:58:23 -05:00
Rob Pike
707ab1347f all: fix some vet-found printf errors
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7393059
2013-02-25 12:43:03 -08:00
Shenghou Ma
1a01ffd386 cmd/gc: fix mkbuiltin (gc -A always write all symbols to export section)
Regenerate cmd/gc/builtin.c.
Fixes #4908.

R=rsc
CC=golang-dev
https://golang.org/cl/7383053
2013-02-26 03:14:59 +08:00
Francisco Souza
f5afc7d44f cmd/go: fix vet
Now that vet does typechecking, it should use only pkg.gofiles, instead
of pkg.allgofiles. Ignored files should not be checked by vet, because
they wouldn't typecheck.

Fixes #4906.

R=rsc, r
CC=golang-dev
https://golang.org/cl/7401051
2013-02-25 10:43:04 -08:00
Russ Cox
f5dce6c853 cmd/5g: fix arm build
R=ken2
CC=golang-dev
https://golang.org/cl/7365057
2013-02-25 12:21:12 -05:00
Russ Cox
1d5dc4fd48 cmd/gc: emit explicit type information for local variables
The type information is (and for years has been) included
as an extra field in the address chunk of an instruction.
Unfortunately, suppose there is a string at a+24(FP) and
we have an instruction reading its length. It will say:

        MOVQ x+32(FP), AX

and the type of *that* argument is int (not slice), because
it is the length being read. This confuses the picture seen
by debuggers and now, worse, by the garbage collector.

Instead of attaching the type information to all uses,
emit an explicit list of TYPE instructions with the information.
The TYPE instructions are no-ops whose only role is to
provide an address to attach type information to.

For example, this function:

        func f(x, y, z int) (a, b string) {
                return
        }

now compiles into:

        --- prog list "f" ---
        0000 (/Users/rsc/x.go:3) TEXT    f+0(SB),$0-56
        0001 (/Users/rsc/x.go:3) LOCALS  ,
        0002 (/Users/rsc/x.go:3) TYPE    x+0(FP){int},$8
        0003 (/Users/rsc/x.go:3) TYPE    y+8(FP){int},$8
        0004 (/Users/rsc/x.go:3) TYPE    z+16(FP){int},$8
        0005 (/Users/rsc/x.go:3) TYPE    a+24(FP){string},$16
        0006 (/Users/rsc/x.go:3) TYPE    b+40(FP){string},$16
        0007 (/Users/rsc/x.go:3) MOVQ    $0,b+40(FP)
        0008 (/Users/rsc/x.go:3) MOVQ    $0,b+48(FP)
        0009 (/Users/rsc/x.go:3) MOVQ    $0,a+24(FP)
        0010 (/Users/rsc/x.go:3) MOVQ    $0,a+32(FP)
        0011 (/Users/rsc/x.go:4) RET     ,

The { } show the formerly hidden type information.
The { } syntax is used when printing from within the gc compiler.
It is not accepted by the assemblers.

The same type information is now included on global variables:

0055 (/Users/rsc/x.go:15) GLOBL   slice+0(SB){[]string},$24(AL*0)

This more accurate type information fixes a bug in the
garbage collector's precise heap collection.

The linker only cares about globals right now, but having the
local information should make things a little nicer for Carl
in the future.

Fixes #4907.

R=ken2
CC=golang-dev
https://golang.org/cl/7395056
2013-02-25 12:13:47 -05:00
Robert Griesemer
a411b104f0 go/parser: more precise comment
See also CL 7383051 for details.

R=adonovan, bradfitz
CC=golang-dev
https://golang.org/cl/7378063
2013-02-25 08:29:46 -08:00
Roger Peppe
7edd13355f net/rpc: avoid racy use of closing flag.
It's accessed without mutex protection
in a different goroutine from the one that
sets it.

Also make sure that Client.Call after Client.Close
will reliably return ErrShutdown, and that clients
see ErrShutdown rather than io.EOF when appropriate.

Suggestions welcome for a way to reliably test
the mutex issue.

R=r, iant
CC=golang-dev
https://golang.org/cl/7338045
2013-02-25 16:22:00 +00:00
Mikio Hara
cd81db8299 net: make use of testing.B.Skip and reflect.DeepEqual in test
This CL addresses the comments on CL 7368046 that I've overlooked.

Update #4866.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7369052
2013-02-25 23:05:40 +09:00
Rémy Oudompheng
670f6b602d go/types: unresolved literal keys must be looked up in universe.
Fixes #4888.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/7383051
2013-02-24 21:57:16 -08:00
Volker Dobler
d97b975d5c cmd/godoc: show examples in text mode
Added the command line flag -ex to godoc to print examples in
text output.

Samples from the generated output:

$ godoc -ex strings Index
...
func Index(s, sep string) int
    Index returns the index of the first instance of sep in s, or -1 if sep
    is not present in s.

    Example:
        fmt.Println(strings.Index("chicken", "ken"))
        fmt.Println(strings.Index("chicken", "dmr"))
        // Output:
        // 4
        // -1
...

$ godoc -ex container/heap
...
package heap
    import "container/heap"

    Package heap provides heap operations for any type that implements
    heap.Interface. A heap is a tree with the property that each node is the
    minimum-valued node in its subtree.

    Example:
        // This example demonstrates an integer heap built using the heap interface.
        package heap_test

        import (
            "container/heap"
            "fmt"
        ...

    Example:
        // This example demonstrates a priority queue built using the heap interface.
        package heap_test

        import (
            "container/heap"
            "fmt"
        )
...

Fixes #3587.

R=golang-dev, minux.ma, adg, rsc, gri
CC=golang-dev
https://golang.org/cl/7356043
2013-02-25 10:37:17 +11:00
Rob Pike
1174a18c3d cmd/vet: fix up some nits in print.go found by kamil.kisiel@gmail.com
R=golang-dev, kamil.kisiel, bradfitz
CC=golang-dev
https://golang.org/cl/7369049
2013-02-24 13:18:36 -08:00
Rob Pike
83e22f1a47 cmd/vet: eliminate false positives for slices in untagged literal test
Made possible by go/types, as long as the package type-checks OK.

Fixes #4684.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7407045
2013-02-24 13:18:21 -08:00
Rémy Oudompheng
b582ef3855 crypto/rsa: fix infinite loop in GenerateMultiPrimeKey for large nprimes
The heuristics for BitLen of a product of randomly generated primes
are wrong, and the generated candidates never match the required
size for nprimes > 10. This corner case is not expected to be used in
practice.

R=agl
CC=golang-dev
https://golang.org/cl/7397052
2013-02-24 17:19:09 +01:00
Shenghou Ma
5a8b7dc6d0 runtime: remove PROT_EXEC from mmap calls.
Executable heap is gone on Unix!

R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/7405045
2013-02-24 22:47:22 +08:00
Shenghou Ma
89ec3a610d cmd/dist: avoid using %ebx on i386.
Or gcc (-fPIC) will complain:
cmd/dist/unix.c: In function ‘cansse2’
cmd/dist/unix.c:774: error: can't find a register in class ‘BREG’ while reloading ‘asm’
cmd/dist/unix.c:774: error: ‘asm’ operand has impossible constraints

This affects bootstrapping on native Darwin/386 where all code is
compiled with -fPIC.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7394047
2013-02-24 22:45:53 +08:00
Mikio Hara
c5f5df4d98 syscall: add network interface announce support on BSD variants
This CL allows to receive network interface arrival and depature
notifications through routing sockets on BSD variants. So far
Darwin doesn't support this feature.

Also does small simplification.

Update #4866.

R=golang-dev, lucio.dere, dave
CC=golang-dev
https://golang.org/cl/7365055
2013-02-24 12:36:44 +09:00
Mikio Hara
6a41b9983c syscall: add if_announce support for openbsd
Update #4866.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7382053
2013-02-24 12:07:20 +09:00
Mikio Hara
d41dede280 syscall: add if_announce support for netbsd
Update #4866.

R=golang-dev, bradfitz, dave
CC=golang-dev
https://golang.org/cl/7382052
2013-02-24 12:06:24 +09:00
Mikio Hara
b1d51c63d6 syscall: add if_announce support for freebsd
Update #4866.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7398047
2013-02-24 12:04:48 +09:00
Rob Pike
72b6daa3ba cmd/vet: check argument types in printf formats
Fixes #4404.

R=gri, rsc
CC=golang-dev
https://golang.org/cl/7378061
2013-02-23 15:08:36 -08:00
Robin Eklind
39c476cbf8 archive/tar: simplify use of constants in test case.
Replace setsid with c_ISGID since the constant is already defined.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7403048
2013-02-23 11:39:01 -08:00
Shenghou Ma
eec961470f cmd/cgo, cmd/dist, cmd/go: cgo with clang fixes
1. Workaround the smart clang diagnostics with -Qunused-arguments:
clang: error: argument unused during compilation: '-XXX'
2. if "clang -print-libgcc-file-name" returns non-absolute path, don't
provide that on linker command line.
3. Fix dwarf.PtrType.Size() in cmd/cgo as clang doesn't generate
DW_AT_byte_size for pointer types.
4. Workaround warnings for -Wno-unneeded-internal-declaration with
-Wno-unknown-warning-option.
5. Add -Wno-unused-function.
6. enable race detector test on darwin with clang
(at least Apple clang version 1.7 (tags/Apple/clang-77) works).

Requires CL 7354043.

Update #4829
This should fix most parts of the problem, but one glitch still remains.
DWARF generated by newer clang doesn't differentiate these
two function types:
    void *malloc(size_t);
    void *malloc(unsigned long int);
so you might need to do this to make make.bash pass:
sed -i -e 's/C.malloc(C.size_t/C.malloc(C.ulong/' pkg/os/user/lookup_unix.go

R=golang-dev, dave, iant, rsc
CC=golang-dev
https://golang.org/cl/7351044
2013-02-23 20:24:38 +08:00
Dmitriy Vyukov
1e957b6245 runtime: fix windows cpu profiling
R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/7407044
2013-02-23 10:07:41 +04:00
Dmitriy Vyukov
353ce60f6e runtime: implement local work queues (in preparation for new scheduler)
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7402047
2013-02-23 08:48:02 +04:00
Dmitriy Vyukov
1d7faf91df runtime: minor changes
to minimize diffs of new scheduler

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7381048
2013-02-23 08:39:31 +04:00
Rob Pike
4434212f15 cmd/vet: use types to test Error methods correctly.
We need go/types to discriminate the Error method from
the error interface and the Error method of the testing package.
Fixes #4753.

R=golang-dev, bradfitz, gri
CC=golang-dev
https://golang.org/cl/7396054
2013-02-22 17:16:31 -08:00
Dave Cheney
d31dd089e6 testing: move Skip into *common
Move Skip and friends into *common so benchmarks can also be skipped.

R=golang-dev, gustav.paul, rsc
CC=golang-dev
https://golang.org/cl/7379046
2013-02-23 11:57:51 +11:00
Mikio Hara
e822860756 syscall: add netlink constants for linux
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7403049
2013-02-23 08:42:04 +09:00
Carl Shapiro
66ba4a85e4 cmd/gc: mark LOCALS argument as a constant to print correctly
Fixes #4875.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7376049
2013-02-22 15:32:54 -08:00
Akshat Kumar
046e035fca all.rc: make sure the Go tools end up in /bin
At least one test (in package runtime) depends
on `go' being in $path. We simply bind GOROOT/bin
before /bin to make sure the latest copy of the
binary is accessible there.

R=rsc, rminnich, ality
CC=golang-dev
https://golang.org/cl/7391047
2013-02-23 00:22:39 +01:00
Akshat Kumar
722ee1f479 os: Plan 9: avoid doing zero-length writes.
Plan 9 I/O preserves message boundaries, while Go
library code is written for UNIX-like operating
systems which do not. Avoid doing zero-length
writes in package os.

R=rsc, rminnich, ality, rminnich, r
CC=golang-dev
https://golang.org/cl/7406046
2013-02-22 23:06:25 +01:00
Russ Cox
56a0bafdb6 runtime: fix arm build
R=ken2
CC=golang-dev
https://golang.org/cl/7399050
2013-02-22 16:38:44 -05:00
Rob Pike
48f79a95d0 cmd/vet: restructure to be package-driven
This is a simple refactoring of main.go that will enable the type checker
to be used during vetting.
The change has an unimportant effect on the arguments: it now assumes
that all files named explicitly on the command line belong to the same
package. When run by the go command, this was true already.

Also restore a missing parenthesis from an error message.

R=golang-dev, gri, bradfitz
CC=golang-dev
https://golang.org/cl/7393052
2013-02-22 13:32:43 -08:00
Russ Cox
3d2dfc5a7b runtime: add cgocallback_gofunc that can call Go func value
For now, all the callbacks from C use top-level Go functions,
so they use the equivalent C function pointer, and will continue
to do so. But perhaps some day this will be useful for calling
a Go func value (at least if the type is already known).

More importantly, the Windows callback code needs to be able
to use cgocallback_gofunc to call a Go func value.
Should fix the Windows build.

R=ken2
CC=golang-dev
https://golang.org/cl/7388049
2013-02-22 16:08:56 -05:00
Rob Pike
96f57186ba exp/ssa: silence go vet
R=adonovan
CC=golang-dev
https://golang.org/cl/7386052
2013-02-22 13:02:00 -08:00
Russ Cox
a48ed66447 runtime: delete old closure code
Step 4 of http://golang.org/s/go11func.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7393049
2013-02-22 15:24:29 -05:00
Russ Cox
b1b67a36ac reflect: stop using run-time code generation
Step 3 of http://golang.org/s/go11func.

Fixes #3736.
Fixes #3738.
Fixes #4081.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7393050
2013-02-22 15:23:57 -05:00
Alan Donovan
18eb3cfdfd exp/ssa: support variadic synthetic methods.
We wrap the final '...' argument's type in types.Slice.
Added tests.

Also:
- Function.writeSignature: suppress slice '[]' when printing
  variadic arg '...'.
- Eliminate Package.ImportPath field; redundant
  w.r.t. Package.Types.Path.
- Use "TODO: (opt|fix)" notation more widely.
- Eliminate many redundant/stale TODOs.

R=gri
CC=golang-dev
https://golang.org/cl/7378057
2013-02-22 14:30:44 -05:00
Russ Cox
9f647288ef cmd/gc: avoid runtime code generation for closures
Change ARM context register to R7, to get out of the way
of the register allocator during the compilation of the
prologue statements (it wants to use R0 as a temporary).

Step 2 of http://golang.org/s/go11func.

R=ken2
CC=golang-dev
https://golang.org/cl/7369048
2013-02-22 14:25:50 -05:00
Russ Cox
d57fcbf05c cmd/5l, cmd/6l, cmd/8l: accept CALL reg, reg
The new src argument is ignored during linking
(that is, CALL r1, r2 is identical to CALL r2 for linking),
but it serves as a hint to the 5g/6g/8g optimizer
that the src register is live on entry to the called
function and must be preserved.

It is possible to avoid exposing this fact to the rest of
the toolchain, keeping it entirely within 5g/6g/8g,
but I think it will help to be able to look in object files
and assembly listings and linker -a / -W output to
see CALL instructions are "Go func value" calls and
which are "C function pointer" calls.

R=ken2
CC=golang-dev
https://golang.org/cl/7364045
2013-02-22 14:23:21 -05:00
Brad Fitzpatrick
9c7aa5fea9 mime/multipart: allow unescaped newlines through in quoted-printable
This makes Go's quoted-printable decoder more like other
popular ones, allowing through a bare \r or \n, and also
passes through \r\n which looked like a real bug before.

Fixes #4771

R=minux.ma
CC=golang-dev
https://golang.org/cl/7300092
2013-02-22 10:40:23 -08:00
Russ Cox
ec892be1af runtime: preserve DX during racefuncenter
R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/7382049
2013-02-22 13:06:43 -05:00
Alan Donovan
71c37e1c88 exp/ssa: fixed bug (typo) in findPromotedField.
By appending to the wrong (always empty) list, only the last
anonymous field was being considered for promotion.

Also:
- eliminated "function-local NamedTypes" TODO; nothing to do.
- fixed Function.DumpTo: printing of anon receivers was "( T)",
  now "(T)"; extracted writeSignature into own function.
- eliminated blockNames function;
  thanks to BasicBlock.String, "%s" of []*BasicBlock is fine.
- extracted buildReferrers into own function.

exp/ssa can now build its own transitive closure.

R=gri
CC=golang-dev
https://golang.org/cl/7384054
2013-02-22 12:35:45 -05:00
Russ Cox
0ba5f75513 runtime: avoid closure in parfor test
R=golang-dev, dvyukov
CC=golang-dev
https://golang.org/cl/7395051
2013-02-22 12:11:12 -05:00
Russ Cox
6066fdcf38 cmd/6g, cmd/8g: switch to DX for indirect call block
runtime: add context argument to gogocall

Too many other things use AX, and at least one
(stack zeroing) cannot be moved onto a different
register. Use the less special DX instead.

Preparation for step 2 of http://golang.org/s/go11func.
Nothing interesting here, just split out so that we can
see it's correct before moving on.

R=ken2
CC=golang-dev
https://golang.org/cl/7395050
2013-02-22 10:47:54 -05:00
Alan Donovan
d9001ef012 exp/ssa: cross off a few remaining TODO issues.
- append: nothing to do (nonsemantic change).
- delete: now performs correct conversion (+ test).
- emitCompare: nothing to do.
- emitArith (shifts): nothing to do (+ test).
- "banish untyped types": give up on that.
- real, imag: now do correct conversions.
- added comment to interp.go re zero-size values.

R=gri
CC=golang-dev
https://golang.org/cl/7391046
2013-02-22 00:09:21 -05:00
Anthony Martin
ed1ac05673 cmd/go: don't call ImportDir unnecessarily
This significantly speeds up the go tool on
slow file systems (or those with cold caches).

The following numbers were obtained using
an encrypted ext4 file system running on
Linux 3.7.9.

# Before
$ sudo sysctl -w 'vm.drop_caches=3'
$ time go list code.google.com/p/go.net/... | wc -l
9

real	0m16.921s
user	0m0.637s
sys	0m0.317s

# After
$ sudo sysctl -w 'vm.drop_caches=3'
$ time go list code.google.com/p/go.net/... | wc -l
9

real	0m8.175s
user	0m0.220s
sys	0m0.177s

R=rsc, r
CC=golang-dev
https://golang.org/cl/7369044
2013-02-21 20:09:31 -08:00
Anthony Martin
edc3126e98 exp/ssa/interp: fix build for Plan 9
R=adonovan, minux.ma, alex.brainman, akumar, rminnich
CC=golang-dev, lucio.dere
https://golang.org/cl/7300078
2013-02-21 20:06:26 -08:00
Olivier Duperray
2482ef7233 testing: document that example output must use line comments
Fixes #4812.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7396051
2013-02-22 12:23:19 +11:00
Alex Brainman
6ec551887a runtime: windows callback code to match new func value representation
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7393048
2013-02-22 12:21:42 +11:00
Rob Pike
dbd409afb5 bufio: add examples for Scanner
Mention Scanner in docs for ReadLine etc.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7375045
2013-02-21 15:55:40 -08:00
Dave Cheney
6138e368f8 cmd/gc: fix FreeBSD build
R=jsing, mikioh.mikioh, bradfitz
CC=golang-dev
https://golang.org/cl/7390048
2013-02-22 10:28:03 +11:00
Brad Fitzpatrick
0462aad9a4 net/url: fix URL Opaque notes on making client requests
Fixes #4860

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7375047
2013-02-21 14:39:16 -08:00
Robert Dinu
782cbb4f90 testing: fix output formatting
Revision 5e7fd762f356 has changed the output formatting in a way that
is no longer in line with the format described by the revision
ff0ade0b937b which has introduced this functionality.
When decorating the first line, instead of indenting the whole line,
the current implementation adds indentation right after the "decorate"
part and  before the "log" message.
The fix addresses this issue.

R=golang-dev, iant, minux.ma, r, rsc, remyoudompheng
CC=golang-dev
https://golang.org/cl/7304094
2013-02-21 14:17:43 -08:00
Russ Cox
1903ad7189 cmd/gc, reflect, runtime: switch to indirect func value representation
Step 1 of http://golang.org/s/go11func.

R=golang-dev, r, daniel.morsing, remyoudompheng
CC=golang-dev
https://golang.org/cl/7393045
2013-02-21 17:01:13 -05:00
Brad Fitzpatrick
4335e69af6 archive/tar: make test pass on setgid dirs
Fixes #4867

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/7382045
2013-02-21 14:00:03 -08:00
Carl Shapiro
f466617a62 cmd/5g, cmd/5l, cmd/6l, cmd/8l, cmd/gc, cmd/ld, runtime: accurate args and locals information
Previously, the func structure contained an inaccurate value for
the args member and a 0 value for the locals member.

This change populates the func structure with args and locals
values computed by the compiler.  The number of args was
already available in the ATEXT instruction.  The number of
locals is now passed through in the new ALOCALS instruction.

This change also switches the unit of args and locals to be
bytes, just like the frame member, instead of 32-bit words.

R=golang-dev, bradfitz, cshapiro, dave, rsc
CC=golang-dev
https://golang.org/cl/7399045
2013-02-21 12:52:26 -08:00
Brad Fitzpatrick
fb21bca012 net/http, net/url: deal with URL.Opaque beginning with //
Update #4860

R=adg, rsc, campoy
CC=golang-dev
https://golang.org/cl/7369045
2013-02-21 12:01:47 -08:00
Rob Pike
6f96a76cd1 unicode: use new Scanner interface in table creation
Update norm and local/collate as well.

R=mpvl
CC=golang-dev
https://golang.org/cl/7395045
2013-02-21 10:47:31 -08:00
Brad Fitzpatrick
bca3f5fca0 database/sql: check for nil Scan pointers
Return nice errors and don't panic.

Fixes #4859

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7383046
2013-02-21 10:43:00 -08:00
Russ Cox
5833c96b0a runtime: better error from TestGcSys when gc is disabled
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7390047
2013-02-21 13:30:31 -05:00
Dmitriy Vyukov
94fab3cad3 runtime: fix heap corruption
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7397049
2013-02-21 21:59:46 +04:00
Russ Cox
0cdc0b3b78 cmd/5g, cmd/6g: fix node dump formats
lvd changed the old %N to %+hN and these
never got updated.

R=ken2
CC=golang-dev
https://golang.org/cl/7391045
2013-02-21 12:53:25 -05:00
Alan Donovan
aa5aaabb0d exp/ssa/interp: (#6 of 5): test interpretation of SSA form of $GOROOT/test/*.go.
The interpreter's os.Exit now triggers a special panic rather
than kill the test process.  (It's semantically dubious, since
it will run deferred routines.)  Interpret now returns its
exit code rather than calling os.Exit.

Also:
- disabled parts of a few $GOROOT/tests via os.Getenv("GOSSAINTERP").
- remove unnecessary 'slots' param to external functions; they
  are never closures.

Most of the tests are disabled until go/types supports shifts.
They can be reenabled if you patch this workaround:
https://golang.org/cl/7312068

R=iant, bradfitz
CC=golang-dev, gri
https://golang.org/cl/7313062
2013-02-21 12:48:38 -05:00
Russ Cox
df93283d56 cmd/fix: delete pre-Go 1 fixes
Assume people who were going to update to Go 1 have done so.
Those with pre-Go 1 trees remaining will need to update first
to Go 1.0 (using its 'go fix') and then to Go 1.1.

Cuts the cmd/fix test time by 99% (3 seconds to 0.03 seconds).

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7402046
2013-02-21 12:19:54 -05:00
Alan Donovan
92cbf82f14 exp/ssa: add dedicated Panic instruction.
By avoiding the need for self-loops following calls to panic,
we reduce the number of basic blocks considerably.

R=gri
CC=golang-dev, iant
https://golang.org/cl/7403043
2013-02-21 12:14:33 -05:00
Mikio Hara
0ad88a481d net: add benchmarks for network interface identification
Current results on linux/amd64:
BenchmarkInterfaces                      20000             80902 ns/op
BenchmarkInterfaceByIndex                50000             71591 ns/op
BenchmarkInterfaceByName                 20000             79908 ns/op
BenchmarkInterfaceAddrs                   2000            836413 ns/op
BenchmarkInterfacesAndAddrs               5000            605946 ns/op
BenchmarkInterfacesAndMulticastAddrs     10000            169029 ns/op

Update #4866.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7368046
2013-02-22 01:19:04 +09:00
Alan Donovan
867121585a exp/ssa: build fully pruned SSA form.
Overview: Function.finish() now invokes the "lifting" pass which replaces local allocs and loads and stores to such cells by SSA registers.  We use very standard machinery:

(1) we build the dominator tree for the function's control flow graph (CFG) using the "Simple" Lengauer-Tarjan algorithm.  (Very "simple" in fact: even simple path compression is not yet implemented.)

In sanity-checking mode, we cross check the dominator tree against an alternative implementation using a simple iterative dataflow algorithm.
This all lives in dom.go, along with some diagnostic printing routines.

(2) we build the dominance frontier for the entire CFG using the Cytron et al algorithm.  The DF is represented as a slice of slices, keyed by block index.  See buildDomFrontier() in lift.go.

(3) we determine for each Alloc whether it can be lifted: is it only subject to loads and stores?  If so, we traverse the iterated dominance frontier (IDF) creating φ-nodes; they are not prepended to the blocks yet.
See liftAlloc() in lift.go.

(4) we perform the SSA renaming algorithm from Cytron et al, replacing all loads to lifted Alloc cells by the value stored by the dominating store operation, and deleting the stores and allocs.  See rename() in lift.go.

(5) we eliminate unneeded φ-nodes, then concatenate the remaining ones with the non-deleted instructions of the block into a new slice.  We eliminate any lifted allocs from Function.Locals.

To ease reviewing, I have avoided almost all optimisations at this point, though there are many opportunities to explore.  These will be easier to understand as follow-up changes.

All the existing tests (pending CL 7313062) pass.  (Faster!)

Details:

"NaiveForm" BuilderMode flag suppresses all the new logic.
Exposed as 'ssadump -build=N'.

BasicBlock:
- add .Index field (b.Func[b.Index]==b), simplifying
  algorithms such as Kildall-style dataflow with bitvectors.
- rename the Name field to Comment to better reflect its
  reduced purpose.  It now has a String() method.
- 'dom' field holds dominator tree node; private for now.
- new predIndex method.
- hasPhi is now a method

dom.go:
- domTree: a new struct for a node in a dominator tree.
- buildDomTree builds the dominator tree using the simple
  variant Lengauer/Tarjan algorithm with Georgiadis'
  bucket optimizations.
- sanityCheckDomTree builds dominance relation using
  Kildall-style dataflow and ensures the same result is
  obtained.
- printDomTreeDot prints the CFG/DomTree in GraphViz format.

blockopt.go:
- perform a mark/sweep pass to eliminate unreachable
  cycles; the previous prune() opt would only eliminate
  trivially dead blocks.  (Needed for LT algo.)
- using .Index, fuseblocks can now delete fused blocks directly.
- delete prune().

sanity.go: more consistency checks:
- Phi with missing edge value
- local Alloc instructions must appear in Function.Locals.
- BasicBlock.Index, Func consistency
- CFG edges are all intraprocedural.
- detect nils in BasicBlock.Instrs.
- detect Function.Locals with Heap flag set.
- check fn.Blocks is nil if empty.

Also:
- Phi now has Comment field for debugging.
- Fixed bug in Select.Operands()
  (took address of temporary copy of field)
- new Literal constructor zeroLiteral().
- algorithms steal private fields Alloc.index,
  BasicBlock.gaps to avoid allocating maps.
- We print Function.Locals in DumpTo.
- added profiling support to ssadump.

R=iant, gri
CC=golang-dev
https://golang.org/cl/7229074
2013-02-21 11:11:57 -05:00
Dmitriy Vyukov
a0955a2aa2 runtime: split minit() to mpreinit() and minit()
mpreinit() is called on the parent thread and with mcache (can allocate memory),
minit() is called on the child thread and can not allocate memory.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7389043
2013-02-21 16:24:38 +04:00
Brad Fitzpatrick
c53fab969c database/sql: clarify that DB.Prepare's stmt is safe for concurrent use
And add a test too, for Alex. :)

Fixes #3734

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7399046
2013-02-20 22:15:36 -08:00
Robert Griesemer
8473b4487c go/types: export data result types are always parenthesized
Minor simplification of gcimporter, removed TODO.

R=adonovan
CC=golang-dev
https://golang.org/cl/7363044
2013-02-20 17:37:13 -08:00
Brad Fitzpatrick
a2ade45205 net/http: improve test reliability
Fixes #4852

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7374045
2013-02-20 16:39:33 -08:00
Rob Pike
c6f23bb7c1 image/png: use Scanner in reader_test.
R=nigeltao
CC=golang-dev
https://golang.org/cl/7399044
2013-02-20 15:57:18 -08:00
Brad Fitzpatrick
f7a7716317 database/sql: refcounting and lifetime fixes
Simplifies the contract for Driver.Stmt.Close in
the process of fixing issue 3865.

Fixes #3865
Update #4459 (maybe fixes it; uninvestigated)

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7363043
2013-02-20 15:35:27 -08:00
Russ Cox
6c976393ae runtime: allow cgo callbacks on non-Go threads
Fixes #4435.

R=golang-dev, iant, alex.brainman, minux.ma, dvyukov
CC=golang-dev
https://golang.org/cl/7304104
2013-02-20 17:48:23 -05:00
Olivier Saingre
afde71cfbd encoding/xml: make sure Encoder.Encode reports Write errors.
Fixes #4112.

R=remyoudompheng, daniel.morsing, dave, rsc
CC=golang-dev
https://golang.org/cl/7085053
2013-02-20 14:41:23 -08:00
Rob Pike
35367cc641 mime: use Scanner to read mime files during init
Also close the file when we're done.

R=bradfitz
CC=golang-dev
https://golang.org/cl/7363045
2013-02-20 14:34:03 -08:00
Robert Dinu
cbd2c7a283 fmt: fix width for nil values
Apply width when using Printf with nil values.
Fixes #4772.

R=r, adg
CC=golang-dev
https://golang.org/cl/7314114
2013-02-20 14:30:15 -08:00
Rob Pike
f574371544 strconv: use Scanner in fp_test
R=rsc
CC=golang-dev
https://golang.org/cl/7385045
2013-02-20 13:38:19 -08:00
Rob Pike
f913830148 regexp: use Scanner in exec_test
R=rsc
CC=golang-dev
https://golang.org/cl/7381046
2013-02-20 13:37:45 -08:00
Robert Griesemer
9dcf3eee41 cmd/godoc: better console error message for example error
(per r's suggestion)

R=r
CC=golang-dev
https://golang.org/cl/7376045
2013-02-20 12:28:12 -08:00
Rob Pike
55ad7b9bfe bufio: new Scanner interface
Add a new, simple interface for scanning (probably textual) data,
based on a new type called Scanner. It does its own internal buffering,
so should be plausibly efficient even without injecting a bufio.Reader.
The format of the input is defined by a "split function", by default
splitting into lines. Other implemented split functions include single
bytes, single runes, and space-separated words.

Here's the loop to scan stdin as a file of lines:

        s := bufio.NewScanner(os.Stdin)
        for s.Scan() {
                fmt.Printf("%s\n", s.Bytes())
        }
        if s.Err() != nil {
                log.Fatal(s.Err())
        }

While we're dealing with spaces, define what space means to strings.Fields.

Fixes #4802.

R=adg, rogpeppe, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/7322088
2013-02-20 12:14:31 -08:00
Robert Griesemer
75e7308be8 go/types: support for customizable Alignof, Sizeof
(Offsetof is a function of Alignof and Sizeof.)

- removed IntSize, PtrSize from Context (set Sizeof instead)
- GcImporter needs a Context now (it needs to have
  access to Sizeof/Alignof)
- removed exported Size field from Basic (use Sizeof)
- added Offset to Field
- added Alignment, Size to Struct

R=adonovan
CC=golang-dev
https://golang.org/cl/7357046
2013-02-20 11:10:17 -08:00
Dmitriy Vyukov
1e063eea38 runtime: prepare for M's running w/o mcache
Can not happen ATM. In preparation for the new scheduler.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7388043
2013-02-20 21:17:56 +04:00
Dmitriy Vyukov
e25f19a638 runtime: introduce entersyscallblock()
In preparation for the new scheduler.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7386044
2013-02-20 20:21:45 +04:00
Dmitriy Vyukov
e5b0bcebdb runtime/debug: deflake TestFreeOSMemory
This is followup to https://golang.org/cl/7319050/

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7379043
2013-02-20 12:34:16 +04:00
Dmitriy Vyukov
06a488fa97 runtime: fix deadlock detector false negative
Fixes #4819.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7322086
2013-02-20 12:15:02 +04:00
Dmitriy Vyukov
a92e11a256 runtime: ensure forward progress of runtime.Gosched() for locked goroutines
The removed code leads to the situation when M executes the same locked G again
and again.
This is https://golang.org/cl/7310096 but with return instead of break
in the nested switch.
Fixes #4820.

R=golang-dev, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/7304102
2013-02-20 12:13:04 +04:00
Péter Surányi
b4109f801a path/filepath, os/exec: unquote PATH elements on Windows
On Windows, directory names in PATH can be fully or partially quoted
in double quotes ('"'), but the path names as used by most APIs must
be unquoted. In addition, quoted names can contain the semicolon
(';') character, which is otherwise used as ListSeparator.

This CL changes SplitList in path/filepath and LookPath in os/exec
to only	treat unquoted semicolons as separators, and to unquote the
separated elements.

(In addition, fix harmless test bug I introduced for LookPath on Unix.)

Related discussion thread:
https://groups.google.com/d/msg/golang-nuts/PXCr10DsRb4/sawZBM7scYgJ

R=rsc, minux.ma, mccoyst, alex.brainman, iant
CC=golang-dev
https://golang.org/cl/7181047
2013-02-20 16:19:52 +11:00
Brian Dellisanti
e378aef1de windows: fix syscall.SidTypeUser so following consts have correct values.
Fixes #4844.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/7366043
2013-02-20 15:38:35 +11:00
Carl Shapiro
7f9c02a10d runtime: add conversion specifier to printf for char values
R=r, golang-dev
CC=golang-dev
https://golang.org/cl/7327053
2013-02-19 18:05:44 -08:00
Akshat Kumar
66b69a1719 net: Plan 9: open data file and set remote-addr properly
The data file should be opened when a Conn is first
established, rather than waiting for the first Read or
Write.

Upon Close, we now make sure to try to close both, the
ctl as well as data files and set both to nil, even in
the face of errors, instead of returning early.

The Accept call was not setting the remote address
of the connection properly. Now, we read the correct
file.

Make functions that establish Conn use newTCPConn
or newUDPConn.

R=rsc, rminnich, ality, dave
CC=golang-dev
https://golang.org/cl/7228068
2013-02-19 17:11:17 -08:00
Mikio Hara
40c2fbf4f2 net: set up IPv6 scoped addressing zone for network facilities
This CL changes nothing to existing API behavior, just sets up
Zone in IPNet and IPAddr structures if possible.

Also does small simplification.

Update #4234.

R=rsc, dave
CC=golang-dev
https://golang.org/cl/7300081
2013-02-20 08:18:04 +09:00
Mikio Hara
e4890e57e1 net: return correct point-to-point interface address on linux
On Linux point-to-point interface an IFA_ADDRESS attribute
represents a peer address. For a correct interface address
we should take an IFA_LOCAL attribute instead.

Fixes #4839.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/7352045
2013-02-20 07:31:44 +09:00
Alan Donovan
a17c46169f go/types: include package import path in NamedType.String().
This avoids ambiguity and makes the diagnostics closer to
those issued by gc, but it is more verbose since it qualifies
intra-package references.

Without extra context---e.g. a 'from *Package' parameter to
Type.String()---we are forced to err on one side or the other.

Also, cosmetic changes to exp/ssa:
- Remove package-qualification workaround in Function.FullName.
- Always set go/types.Package.Path field to the import path,
  since we know the correct path at this point.
- In Function.DumpTo, show variadic '...' and result type info,
  and delete now-redundant "# Type: " line.

R=gri
CC=golang-dev
https://golang.org/cl/7325051
2013-02-19 14:42:05 -05:00
Robert Griesemer
5c3fb96be9 exp/README: update README
R=golang-dev, dsymonds, bradfitz
CC=golang-dev
https://golang.org/cl/7323073
2013-02-19 11:21:18 -08:00
Robert Griesemer
3ee87d02b0 cmd/godoc: use go/build to determine package and example files
Also:
- faster code for example extraction
- simplify handling of command documentation:
  all "main" packages are treated as commands
- various minor cleanups along the way

For commands written in Go, any doc.go file containing
documentation must now be part of package main (rather
then package documentation), otherwise the documentation
won't show up in godoc (it will still build, though).

For commands written in C, documentation may still be
in doc.go files defining package documentation, but the
recommended way is to explicitly ignore those files with
a +build ignore constraint to define package main.

Fixes #4806.

R=adg, rsc, dave, bradfitz
CC=golang-dev
https://golang.org/cl/7333046
2013-02-19 11:19:58 -08:00
Kamil Kisiel
0456729977 path/filepath: add examples for SplitList and Rel.
R=golang-dev, bradfitz, minux.ma
CC=golang-dev
https://golang.org/cl/7291043
2013-02-19 10:41:35 -08:00
Russ Cox
6df181a7f0 path/filepath: document Dir better
This comment matches the one in path.

Fixes #4837.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7305100
2013-02-19 13:24:03 -05:00