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

6979 Commits

Author SHA1 Message Date
Andrey Mirtchovski
be36ab339f utf8: fix typo.
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7063056
2013-01-09 11:07:13 -08:00
Brad Fitzpatrick
f38df4e879 net/http: don't buffer request writing if dest is already buffered
The old code made it impossible to implement a reverse proxy
with anything less than 4k write granularity to the backends.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7060059
2013-01-09 10:33:46 -08:00
Robert Griesemer
65cb1904c1 go/types: "inherit" type in constant declarations w/o initialization expressions (bug fix)
R=adonovan
CC=golang-dev
https://golang.org/cl/7060054
2013-01-08 15:03:30 -08:00
Brad Fitzpatrick
89a7c87e66 all: use io.ByteWriter now that it exists
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7079043
2013-01-08 12:15:19 -08:00
Alex Brainman
548e58781b net/http/cgi: make it work without REQUEST_URI environment variable
Fixes #4367.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7062052
2013-01-08 17:23:46 +11:00
Andrew Gerrand
60544b698e go/doc: recursively inspect selector expressions
Also adds a couple of simple tests for doc.Examples.

Fixes #4561.

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/7067048
2013-01-07 19:36:38 +11:00
Nigel Tao
30ff0636b7 image/jpeg: handle those (unusual) grayscale images whose sampling
ratio isn't 1x1.

Fixes #4259.

The test data was generated by
cjpeg -quality 50 -sample 2x2 video-005.gray.pgm > video-005.gray.q50.2x2.jpeg
cjpeg -quality 50 -sample 2x2 -progressive video-005.gray.pgm > video-005.gray.q50.2x2.progressive.jpeg

similarly to video-005.gray.q50.* from
http://code.google.com/p/go/source/detail?r=51f26e36ba98
the key difference being the "-sample 2x2".

R=rsc
CC=golang-dev
https://golang.org/cl/7069045
2013-01-07 16:16:11 +11:00
Andrew Gerrand
0f64a6ef8d os: document that Exit does not run deferred calls
Fixes #4101.

R=dsymonds, rsc
CC=golang-dev
https://golang.org/cl/7065048
2013-01-07 14:46:41 +11:00
Matthew Dempsky
2e24a737c5 bytes: Fix missing godoc punctuation.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7067047
2013-01-06 22:44:04 -05:00
Matthew Dempsky
8cf45909b5 bytes: Change Compare example to be consistent with sort.Search's.
R=rsc, adg
CC=golang-dev
https://golang.org/cl/7057049
2013-01-06 22:43:32 -05:00
Andrew Gerrand
a88bbbb771 go/doc: trim only first space or newline from example output comment
Fixes #4487.

R=rsc
CC=golang-dev
https://golang.org/cl/7057048
2013-01-07 13:42:25 +11:00
Andrew Wilkins
02370f6760 go/types: Set Signature.Recv for imported types
R=golang-dev, bradfitz, gri
CC=golang-dev
https://golang.org/cl/7065046
2013-01-06 18:08:58 -08:00
Alex Brainman
20e976073d os: fix Open for empty root directories on windows
Fixes #4601.

R=golang-dev, rsc, bradfitz, kardianos
CC=golang-dev
https://golang.org/cl/7033046
2013-01-07 12:48:32 +11:00
Robin Eklind
f36a53cd5d cmd/gofmt, bufio, image: Consistency and error handling.
cmd/gofmt: Add error handling for ioutil.WriteFile.
bufio: Consistency, rename e to err.
image: Consistency, fix comment for asReader.

R=golang-dev, dave, minux.ma, adg
CC=golang-dev
https://golang.org/cl/7029056
2013-01-07 11:15:53 +11:00
Nigel Tao
c753404886 bytes: fix docs: s/array/slice/.
R=rsc, mdempsky, dave
CC=golang-dev
https://golang.org/cl/7028051
2013-01-07 10:48:06 +11:00
Matthew Dempsky
46811d27ce src: Use bytes.Equal instead of bytes.Compare where possible.
bytes.Equal is simpler to read and should also be faster because
of short-circuiting and assembly implementations.

Change generated automatically using:
  gofmt -r 'bytes.Compare(a, b) == 0 -> bytes.Equal(a, b)'
  gofmt -r 'bytes.Compare(a, b) != 0 -> !bytes.Equal(a, b)'

R=golang-dev, dave, adg, rsc
CC=golang-dev
https://golang.org/cl/7038051
2013-01-07 10:03:49 +11:00
Matthew Dempsky
56961274bb bytes: Examples recommending bytes.Compare(a, b) rel_op 0 to test a rel_op b.
R=golang-dev, minux.ma, rsc, adg
CC=golang-dev
https://golang.org/cl/7042045
2013-01-07 09:59:37 +11:00
Caleb Spare
396c957a32 encoding/json: documented that ,string applies only to string and numeric fields.
Fixes #4437.

R=golang-dev, adg
CC=golang-dev, rsc
https://golang.org/cl/7064045
2013-01-07 09:44:35 +11:00
Rémy Oudompheng
0f545d9ab2 go/types: less closure creations in gcimporter.
Closures are incredibly expensive on linux/arm due to
repetitive flush of instruction cache.

go test -short on ODROID-X:

Before:
ok      exp/gotype      17.091s
ok      go/types        2.225s

After:
ok      exp/gotype      7.193s
ok      go/types        1.143s

R=dave, minux.ma, rsc
CC=golang-dev, remy
https://golang.org/cl/7062045
2013-01-06 23:38:38 +01:00
Russ Cox
4e2aa9bff0 cmd/ld: use native-endian symbol values in symbol table
The Plan 9 symbol table format defines big-endian symbol values
for portability, but we want to be able to generate an ELF object file
and let the host linker link it, as part of the solution to issue 4069.
The symbol table itself, since it is loaded into memory at run time,
must be filled in by the final host linker, using relocation directives
to set the symbol values. On a little-endian machine, the linker will
only fill in little-endian values during relocation, so we are forced
to use little-endian symbol values.

To preserve most of the original portability of the symbol table
format, we make the table itself say whether it uses big- or
little-endian values. If the table begins with the magic sequence
        fe ff ff ff 00 00
then the actual table begins after those six bytes and contains
little-endian symbol values. Otherwise, the table is in the original
format and contains big-endian symbol values. The magic sequence
looks like an "end of table" entry (the fifth byte is zero), so legacy
readers will see a little-endian table as an empty table.

All the gc architectures are little-endian today, so the practical
effect of this CL is to make all the generated tables little-endian,
but if a big-endian system comes along, ld will not generate
the magic sequence, and the various readers will fall back to the
original big-endian interpretation.

R=ken2
CC=golang-dev
https://golang.org/cl/7066043
2013-01-04 17:03:57 -05:00
Ian Lance Taylor
63bee953a2 runtime: always incorporate hash seed at start of hash computation
Otherwise we can get predictable collisions.

R=golang-dev, dave, patrick, rsc
CC=golang-dev
https://golang.org/cl/7051043
2013-01-04 07:53:42 -08:00
John Graham-Cumming
c09649890f log/syslog: remove RFC5424 version number for greater compatibility
RFC5424 specifies a version number (currently 1) after the facility and
severity in a syslog message (e.g. <7>1 TIMESTAMP ...).  This causes
rsyslog to fail to parse syslog message because the rest of the message
is not fully compliant with RFC5424.

For the widest compatibility, drop the version (messages are in the
RFC3164 BSD syslog format (e.g. <7>TIMESTAMP ...). Have tested this with
syslog-ng, rsyslog and syslogd.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7036050
2013-01-04 10:21:43 -05:00
Jan Ziak
89ec208ee8 runtime: introduce typedefs and delete struct keywords in mgc0.c
R=rsc
CC=golang-dev
https://golang.org/cl/7029055
2013-01-04 10:20:50 -05:00
Matthew Dempsky
98edf09e67 net/http: Sync TimeoutHandler godoc with code.
TimeoutHandler was changed from "ns int64" to "dt time.Duration" on
Nov 30, 2011, but the godoc still refers to "ns".

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7031050
2013-01-03 10:06:04 -08:00
Dave Cheney
14b654369d go/types: add more logging to gc import test
* Extended deadline to 30 seconds
* Added logging of the duration of each package import
* Fail the test immediately if directories cannot be read

R=gri, minux.ma
CC=golang-dev
https://golang.org/cl/7030055
2013-01-03 16:30:25 +11:00
Nigel Tao
699b99fa75 net: fix docs for type IP: s/array/slice/.
R=rsc
CC=golang-dev
https://golang.org/cl/6930047
2013-01-03 14:25:13 +11:00
Brad Fitzpatrick
5e8ca201d1 net/http: make NewRequest pick a ContentLength from a *bytes.Reader too
It already did so for its sibling, *strings.Reader, as well as *bytes.Buffer.

R=edsrzf, dave, adg, kevlar, remyoudompheng, adg, rsc
CC=golang-dev
https://golang.org/cl/7031045
2013-01-02 14:40:27 -08:00
Thomas Kappler
cdec0850f8 encoding/json: don't panic marshaling anonymous non-struct field
Add a check for this case and don't try to follow the anonymous
type's non-existent fields.

Fixes #4474.

R=rsc
CC=golang-dev
https://golang.org/cl/6945065
2013-01-02 17:39:41 -05:00
Rick Arnold
948f0b7a0b net/http: document Request.URL
Request.URL had no documentation before and some people were expecting all fields to be populated.

Fixes #3805.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7008046
2013-01-02 17:37:27 -05:00
Russ Cox
64a0017d6e sync/atomic: document that users must deal with 64-bit alignment
Update #599.

R=dvyukov, iant, minux.ma
CC=golang-dev
https://golang.org/cl/7001056
2013-01-02 15:44:00 -05:00
Robert Griesemer
a846d479b3 go/types: remove most remaining uses of ast.Object from exported API
Also: Return first error whether an error handler is set in the
      context or not (bug fix).

R=adonovan
CC=golang-dev
https://golang.org/cl/7024043
2013-01-02 09:27:33 -08:00
Dave Cheney
c2d2bfcc49 runtime: fix freebsd/arm instruction cache flush
sysarch requires arguments to be passed on the stack, not in registers.

Credit to Shenghou Ma (minux) for the fix.

R=minux.ma, devon.odell
CC=golang-dev
https://golang.org/cl/7037043
2013-01-01 21:47:42 +11:00
Dave Cheney
52dc13b5f3 go/build: disable cgo on freebsd/arm
Under FreeBSD-CURRENT on arm, cgo enabled binaries segfault. Disable cgo support for the moment so we can have a freebsd/arm builder on the dashboard.

R=minux.ma, rsc, iant
CC=golang-dev
https://golang.org/cl/7031044
2013-01-01 21:46:18 +11:00
Ryan Slade
a4600126d9 encoding/json: encode map key is of string kind, decode only of string type
Allows encoding and decoding of maps with key of string kind, not just string type.
Fixes #3519.

R=rsc, dave
CC=golang-dev
https://golang.org/cl/6943047
2012-12-30 15:40:42 +11:00
Russ Cox
a22389ec38 runtime: say 'fatal error' instead of 'throw'
Fixes #4597.

R=ken2
CC=golang-dev
https://golang.org/cl/7032043
2012-12-29 21:48:25 -05:00
Sébastien Paolacci
e786829e83 runtime: handle locked mmap failure on Linux
Used to then die on a nil pointer situation. Most Linux standard setups are rather
restrictive regarding the default amount of lockable memory.

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6997049
2012-12-29 14:34:06 -05:00
Adam Langley
975bf6d323 crypto/rsa: ensure that RSA keys use the full number of bits.
While half of all numbers don't have their most-significant bit set,
this is becoming increasingly impermissible for RSA moduli. In an
attempt to exclude weak keys, several bits of software either do, or
will, enforce that RSA moduli are >= 1024-bits.

However, Go often generates 1023-bit RSA moduli which this software
would then reject.

This change causes crypto/rsa to regenerate the primes in the event
that the result is shorter than requested.

It also alters crypto/rand in order to remove the performance impact
of this:

The most important change to crypto/rand is that it will now set the
top two bits in a generated prime (OpenSSL does the same thing).
Multiplying two n/2 bit numbers, where each have the top two bits set,
will always result in an n-bit product. (The effectively makes the
crypto/rsa change moot, but that seems too fragile to depend on.)

Also this change adds code to crypto/rand to rapidly eliminate some
obviously composite numbers and reduce the number of Miller-Rabin
tests needed to generate a prime.

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/7002050
2012-12-28 19:11:37 -05:00
Robert Griesemer
c8eb71b057 go/types: Steps towards removing ast.Object from exported API.
- introduced type Method for methods
- renamed StructField -> Field
- removed ObjList
- methods are not sorted anymore in interfaces (for now)

R=adonovan
CC=golang-dev
https://golang.org/cl/7023043
2012-12-28 14:30:36 -08:00
Robert Griesemer
73aaa44c24 go/types: moved from exp/types
This is a just a file move with no other changes
besides the manual import path adjustments in these
two files:

src/pkg/exp/gotype/gotype.go
src/pkg/exp/gotype/gotype_test.go

Note: The go/types API continues to be subject to
possibly significant changes until Go 1.1. Do not
rely on it being stable at this point.

R=adonovan
CC=golang-dev
https://golang.org/cl/7013049
2012-12-28 11:41:44 -08:00
Robert Griesemer
d0428379e7 exp/types: resolve composite literal keys
The parser/resolver cannot accurately resolve
composite literal keys that are identifiers;
it needs type information.
Instead, try to resolve them but leave final
judgement to the type checker.

R=adonovan
CC=golang-dev
https://golang.org/cl/6994047
2012-12-28 10:40:36 -08:00
Brad Fitzpatrick
eb43ce2d77 io/ioutil: fix Discard data race
Fixes #4589

R=golang-dev, iant, dvyukov
CC=golang-dev
https://golang.org/cl/7011047
2012-12-28 09:33:22 -08:00
Dmitriy Vyukov
91484c6c48 runtime: fix potential crash in sigqueue
Fixes #4383.

R=golang-dev, minux.ma, rsc, iant
CC=golang-dev
https://golang.org/cl/6996060
2012-12-28 15:36:06 +04:00
Dave Cheney
7c4183ac24 net: consolidate fd_{free,net,open}bsd.go into fd_bsd.go
These files are identical, so probably pre date // +build.

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

R=mikioh.mikioh, jsing, devon.odell, lucio.dere, minux.ma
CC=golang-dev
https://golang.org/cl/7004053
2012-12-28 21:01:52 +11:00
Jan Ziak
90f9beca15 reflect: declare slice as *[]unsafe.Pointer instead of *[]byte
The new garbage collector (CL 6114046) may find the fake *[]byte value
and interpret its contents as bytes rather than as potential pointers.
This may lead the garbage collector to free memory blocks that
shouldn't be freed.

R=dvyukov, rsc, dave, minux.ma, remyoudompheng, iant
CC=golang-dev
https://golang.org/cl/7000059
2012-12-28 02:35:04 +08:00
Akshat Kumar
5bcb9707b6 log/syslog: add stub for Plan 9
Proper local system log semantics still need to be
created for Plan 9. In the meantime, the test suite
(viz., exp/gotype) expects there to be some Go
source for each import path. Thus, here is a stub,
equivalent to syslog_windows, for this purpose.

R=golang-dev, rsc, alex.brainman
CC=golang-dev
https://golang.org/cl/7000062
2012-12-27 11:45:03 +11:00
Robert Griesemer
3e8304b377 exp/types: some comment fixes
R=adonovan, bradfitz
CC=golang-dev
https://golang.org/cl/7018046
2012-12-26 14:04:50 -08:00
Robert Griesemer
888111e081 exp/types: configurable types.Check API
- added Context type for configuration of type checker
- type check all function and method bodies
- (partial) fixes to shift hinting (still not complete)
- revamped test harness - does not rely on specific position
  representation anymore, just a standard (compiler) error
  message
- lots of bug fixes

R=adonovan, rsc
CC=golang-dev
https://golang.org/cl/6948071
2012-12-26 12:48:26 -08:00
Oling Cat
f296adf819 fmt: update an old comment; fix a typo.
R=golang-dev, iant
CC=golang-dev, minux.ma
https://golang.org/cl/6998055
2012-12-25 14:54:24 -08:00
Dmitriy Vyukov
4380fa6d99 runtime: diagnose double wakeup on Note
Double wakeup is prohibited by the Note interface
and checked in lock_sema.c.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6976054
2012-12-24 21:06:57 +04:00
Marcel van Lohuizen
cfcc3ebfa4 exp/norm: changed API of Iter.
Motivations:
 - Simpler UI. Previous API proved a bit awkward for practical purposes.
 - Iter is often used in cases where one want to be able to bail out early.
   The old implementaton had too much look-ahead to be efficient.
Disadvantages:
 - ASCII performance is bad. This is unavoidable for tiny iterations.
   Example is included to show how to work around this.

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

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

R=rsc
CC=golang-dev
https://golang.org/cl/6873072
2012-12-24 16:53:25 +01:00
Marcel van Lohuizen
9aa70984a9 exp/locale/collate: include composed characters into the table. This eliminates
the need to decompose characters for the majority of cases.  This considerably
speeds up collation while increasing the table size minimally.

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

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

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

R=rsc, mpvl
CC=golang-dev
https://golang.org/cl/6971044
2012-12-24 16:42:29 +01:00
Dmitriy Vyukov
43f2fc308b runtime/race: make test driver print compilation errors
Currently it silently "succeeds" saying that it run 0 tests
if there are compilations errors.
With this change it fails and outputs the compilation error.

R=golang-dev, remyoudompheng
CC=golang-dev
https://golang.org/cl/7002058
2012-12-24 15:33:32 +04:00
Rémy Oudompheng
ecbf99ad97 cmd/gc: fix race instrumentation of unaddressable arrays.
Fixes #4578.

R=dvyukov, golang-dev
CC=golang-dev
https://golang.org/cl/7005050
2012-12-24 12:14:41 +01:00
Brad Fitzpatrick
82ae6434b3 net/http: match curl and others' NO_PROXY wildcard handling
NO_PROXY="example.com" should match "foo.example.com", just
the same as NO_PROXY=".example.com".  This is what curl and
Python do.

Fixes #4574

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7005049
2012-12-22 17:41:00 -08:00
Russ Cox
403f012534 runtime: zero d.free field
Not programming in Go anymore:
have to clear fields in local variables.

R=ken2
CC=golang-dev
https://golang.org/cl/7002053
2012-12-22 18:23:26 -05:00
Russ Cox
e49a183b76 runtime/debug: document that Stack is deprecated
Fixes #4070.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7004050
2012-12-22 17:23:50 -05:00
Russ Cox
ec59b840f9 runtime: coalesce 0-size allocations
Fixes #3996.

R=ken2
CC=golang-dev
https://golang.org/cl/7001052
2012-12-22 16:42:22 -05:00
Russ Cox
295a4d8e64 runtime: ignore failure from madvise
When we release memory to the OS, if the OS doesn't want us
to release it (for example, because the program executed
mlockall(MCL_FUTURE)), madvise will fail. Ignore the failure
instead of crashing.

Fixes #3435.

R=ken2
CC=golang-dev
https://golang.org/cl/6998052
2012-12-22 15:06:28 -05:00
Russ Cox
0de71619ce runtime: aggregate defer allocations
benchmark             old ns/op    new ns/op    delta
BenchmarkDefer              165          113  -31.52%
BenchmarkDefer10            155          103  -33.55%
BenchmarkDeferMany          216          158  -26.85%

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

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

Fixes #2364.

R=ken2
CC=golang-dev
https://golang.org/cl/7001051
2012-12-22 14:54:39 -05:00
Emil Hessman
4b7c2dfcea testing: fix example test fd leak
Close the read side of the pipe.
Fixes #4551.

R=rsc
CC=golang-dev
https://golang.org/cl/6962049
2012-12-22 13:41:01 -05:00
Stéphane Travostino
475f3df43f encoding/json: A JSON tag can be any valid JSON string.
Fixes #3887.

R=golang-dev, daniel.morsing, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/6997045
2012-12-22 13:36:55 -05:00
Russ Cox
1cad1f8d1c fmt: document width and flags a bit more
Fixes #4581.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7000052
2012-12-22 13:36:39 -05:00
Rick Arnold
a6d986bd8a flag: add implicit boolFlag interface
Any flag.Value that has an IsBoolFlag method that returns true
will be treated as a bool flag type during parsing.

Fixes #4262.

R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6944064
2012-12-22 13:34:48 -05:00
Erik St. Martin
54b7ccd514 regexp: fix index panic in Replace
When using subexpressions ($1) as replacements, when they either don't exist or values weren't found causes a panic.
This patch ensures that the match location isn't -1, to prevent out of bounds errors.
Fixes #3816.

R=franciscossouza, rsc
CC=golang-dev
https://golang.org/cl/6931049
2012-12-22 11:14:56 -05:00
Adam Langley
8f1d170fc6 crypto/des: add an example to demonstrate EDE2 operation.
EDE2 is a rare DES mode that can be implemented with crypto/des, but
it's somewhat non-obvious so this CL adds an example of doing so.

Fixes #3537.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6721056
2012-12-22 10:50:11 -05:00
Russ Cox
d324c4af87 encoding/gob: document that structs only encode/decode exported fields
Fixes #4579.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7000051
2012-12-22 10:43:47 -05:00
Chris Jones
a9121a19f0 encoding/xml: Marshal ",any" fields
Fixes #3559.

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

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

R=rsc
CC=golang-dev, n13m3y3r
https://golang.org/cl/6938068
2012-12-22 10:00:36 -05:00
Mikio Hara
9622f5032e net: fix timeout tests
R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/7003049
2012-12-22 14:56:02 +09:00
Robert Griesemer
4f79cef7f2 go/ast: ast.DeclStmt.Decl must be an *ast.GenDecl node (documentation)
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6996046
2012-12-21 11:52:21 -08:00
Dmitriy Vyukov
080d31cc50 runtime/race: update linux runtime to r170876.
This disables checks for limited address space
and unlimited stack. They are not required for Go.
Fixes #4577.

R=golang-dev, iant
CC=golang-dev, kamil.kisiel, minux.ma
https://golang.org/cl/7003045
2012-12-21 19:12:00 +04:00
Mikio Hara
ebcaf081a7 net: make unix connection tests more robust
Avoids unlink the underlying file before the socket close.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/7004044
2012-12-21 14:19:33 +09:00
Alex Brainman
9ad0348403 os: remove dead code
R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6944066
2012-12-21 16:02:39 +11:00
Dave Cheney
c850d0f34a net/http: simplify serve() connection close
Followup to 6971049.

R=bradfitz
CC=golang-dev
https://golang.org/cl/6970049
2012-12-21 15:14:38 +11:00
Andrew Gerrand
ff27cdb625 go/doc: don't synthesize code for examples that are not self-contained
Fixes #4309.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6974045
2012-12-21 07:06:38 +11:00
Russ Cox
a3677b5f22 math: handle exponent separately in Log2
This guarantees that powers of two return exact answers.

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

Fixes #4567.

R=golang-dev, iant, remyoudompheng
CC=golang-dev
https://golang.org/cl/6943074
2012-12-20 12:23:27 -05:00
Joel Sing
708db79011 cgo: enable cgo on openbsd
Enable cgo on OpenBSD.

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

Joint work with Shenghou Ma (minux).

Requires change 6846064.

Fixes #3205.

R=golang-dev, minux.ma, iant, rsc, iant
CC=golang-dev
https://golang.org/cl/6853059
2012-12-21 01:43:19 +11:00
Joakim Sernbrant
d0283ab62a net/http: only call client SetCookie when needed
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6968049
2012-12-19 16:24:38 -08:00
Andrew Gerrand
ff5d47ebba testing: only capture stdout when running examples
Fixes #4550.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6973048
2012-12-20 10:48:33 +11:00
Brad Fitzpatrick
91934ff5d8 net/http: fix server connection leak on Handler's panic(nil)
If a handler did a panic(nil), the connection was never closed.

Fixes #4050

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/6971049
2012-12-19 15:39:19 -08:00
Dave Cheney
07e706f8ce go/token: fix data race on FileSet.last
Fixes #4345.

Benchmarks are promising,

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

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

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

Also includes additional tests to improve token.FileSet coverage.

R=dvyukov, gri
CC=golang-dev
https://golang.org/cl/6968044
2012-12-20 08:26:24 +11:00
Dave Cheney
4e406a2372 go/token: add test for concurrent use of FileSet.Pos
Update #4354.

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

R=dvyukov, gri
CC=fullung, golang-dev
https://golang.org/cl/6940078
2012-12-18 16:38:00 -08:00
Shenghou Ma
d1ef9b56fb all: fix typos
caught by https://github.com/lyda/misspell-check.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/6949072
2012-12-19 03:04:09 +08:00
Jingcheng Zhang
70e967b7bc runtime: use "mp" and "gp" instead of "m" and "g" for local variable name to avoid confusion with the global "m" and "g".
R=golang-dev, minux.ma, rsc
CC=bradfitz, golang-dev
https://golang.org/cl/6939064
2012-12-19 00:30:29 +08:00
Shenghou Ma
7777bac6e4 runtime: use clock_gettime to get ns resolution for time.now & runtime.nanotime
For Linux/{386,arm}, FreeBSD/{386,amd64,arm}, NetBSD/{386,amd64}, OpenBSD/{386,amd64}.
Note: our Darwin implementation already has ns resolution.

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

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

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

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

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

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

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

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

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

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

R=jsing, dave, rsc
CC=golang-dev
https://golang.org/cl/6820120
2012-12-18 22:57:25 +08:00
David Symonds
5b46fc417f go/doc: add "hdr-" prefix to headers generated from package overviews.
R=golang-dev, bradfitz, gri
CC=golang-dev
https://golang.org/cl/6935071
2012-12-18 12:19:04 +11:00
Robert Griesemer
acbf011d96 exp/gotype: disable failing tests and add a few more
R=rsc, alex.brainman
CC=golang-dev
https://golang.org/cl/6948066
2012-12-17 14:32:46 -08:00
Dave Cheney
7e9d9eb17b debug/elf: handle missing shstrndx in core files
Fixes #4481.

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

Also: add support for gz compressed test fixtures.

R=minux.ma, rsc, iant
CC=golang-dev
https://golang.org/cl/6936058
2012-12-18 07:58:22 +11:00
Dave Cheney
2d3bdab0d6 time: fix panic with time.Parse(time.StampNano, ... )
Fixes #4502.

R=rsc
CC=golang-dev
https://golang.org/cl/6949058
2012-12-18 07:52:23 +11:00
Brad Fitzpatrick
7c3577e48f net/http: fix goroutine leak in error case
Fixes #4531

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6937069
2012-12-17 12:01:00 -08:00
Robert Griesemer
50d8787822 exp/types: completed typechecking of parameter passing
Details:
- fixed variadic parameter passing and calls of the form f(g())
- fixed implementation of ^x for unsigned constants x
- fixed assignability of untyped booleans
- resolved a few TODOs, various minor fixes
- enabled many more tests (only 6 std packages don't typecheck)

R=rsc
CC=golang-dev
https://golang.org/cl/6930053
2012-12-17 11:35:59 -08:00
Shenghou Ma
5a2c275be1 fmt, encoding/gob: fix misuse of Read
reader.Read() can return both 0,nil and len(buf),err.
To be safe, we use io.ReadFull instead of doing reader.Read directly.

Fixes #3472.

R=bradfitz, rsc, ality
CC=golang-dev
https://golang.org/cl/6285050
2012-12-18 01:26:48 +08:00
Anthony Martin
2ad6714793 syscall: lazily populate the environment cache on Plan 9
This decreases the amount of system calls during the
first call to Getenv. Calling Environ will still read
in all environment variables and populate the cache.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6939048
2012-12-17 08:33:51 -08:00
Anthony Martin
432f18221f runtime: implement getenv for Plan 9
With this change the runtime can now read GOMAXPROCS, GOGC, etc.

I'm not quite sure how we missed this.

R=seed, lucio.dere, rsc
CC=golang-dev
https://golang.org/cl/6935062
2012-12-17 11:07:40 -05:00
Rick Arnold
bcb495b39a net/smtp: remove data race from TestSendMail.
A data race was found in TestSendMail by the race detector.

Fixes #4559.

R=golang-dev, bradfitz, dave, rsc
CC=golang-dev
https://golang.org/cl/6944057
2012-12-17 10:45:33 -05:00
Shenghou Ma
57ae2e7371 os: fix docs for Expand
there is no concept of “undefined” variables for Expand。

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6946063
2012-12-17 23:37:02 +08:00
Shenghou Ma
a89aaad195 net/http/pprof: fix doc for /debug/pprof/
Fixes #4548.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6944053
2012-12-17 23:32:08 +08:00
Christopher Nielsen
39835b4aa0 syscall: document that documentation is platform specific
Fixes #4051

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6943063
2012-12-17 22:50:00 +08:00
Dmitriy Vyukov
ca4b868e9a cmd/gc: racewalk: fix compiler crash
The code:
func main() {
        v := make([]int64, 10)
        i := 1
        _ = v[(i*4)/3]
}
crashes compiler with:

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

The problem is nil init passed to mkcall().

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6940045
2012-12-17 12:55:41 +04:00
Oling Cat
6dd7da8566 fmt: fix a typo
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6937065
2012-12-17 18:13:12 +11:00
Rémy Oudompheng
8c86f1f331 encoding/json: cleanup leftover redundant variables.
Those variables come from ancient times when reflect.Value was
an interface.

R=dave, rsc
CC=golang-dev
https://golang.org/cl/6946059
2012-12-17 02:34:49 +01:00