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

231 Commits

Author SHA1 Message Date
Adam Langley
4ca6e588e4 time: handle int64 overflow in ParseDuration.
Previously, passing a long duration to ParseDuration could result in
random, even negative, values.

LGTM=r
R=golang-codereviews, bradfitz, r
CC=golang-codereviews
https://golang.org/cl/72120043
2014-03-10 12:33:45 -04:00
Dave Cheney
7c8280c9ef all: merge NaCl branch (part 1)
See golang.org/s/go13nacl for design overview.

This CL is the mostly mechanical changes from rsc's Go 1.2 based NaCl branch, specifically 39cb35750369 to 500771b477cf from https://code.google.com/r/rsc-go13nacl. This CL does not include working NaCl support, there are probably two or three more large merges to come.

CL 15750044 is not included as it involves more invasive changes to the linker which will need to be merged separately.

The exact change lists included are

15050047: syscall: support for Native Client
15360044: syscall: unzip implementation for Native Client
15370044: syscall: Native Client SRPC implementation
15400047: cmd/dist, cmd/go, go/build, test: support for Native Client
15410048: runtime: support for Native Client
15410049: syscall: file descriptor table for Native Client
15410050: syscall: in-memory file system for Native Client
15440048: all: update +build lines for Native Client port
15540045: cmd/6g, cmd/8g, cmd/gc: support for Native Client
15570045: os: support for Native Client
15680044: crypto/..., hash/crc32, reflect, sync/atomic: support for amd64p32
15690044: net: support for Native Client
15690048: runtime: support for fake time like on Go Playground
15690051: build: disable various tests on Native Client

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/68150047
2014-02-25 09:47:42 -05:00
Dmitriy Vyukov
bb9531e11b time: use RunParallel in benchmarks
LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/68060043
2014-02-24 20:47:17 +04:00
Jay Weisskopf
86c976ffd0 runtime: use monotonic clock for timers (linux/386, linux/amd64)
This lays the groundwork for making Go robust when the system's
calendar time jumps around. All input values to the runtimeTimer
struct now use the runtime clock as a common reference point.
This affects net.Conn.Set[Read|Write]Deadline(), time.Sleep(),
time.Timer, etc. Under normal conditions, behavior is unchanged.

Each platform and architecture's implementation of runtime·nanotime()
should be modified to use a monotonic system clock when possible.

Platforms/architectures modified and tested with monotonic clock:
  linux/x86     - clock_gettime(CLOCK_MONOTONIC)

Update #6007

LGTM=dvyukov, rsc
R=golang-codereviews, dvyukov, alex.brainman, stephen.gutekanst, dave, rsc, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/53010043
2014-02-24 10:57:46 -05:00
Patrick Mézard
7403071ada time: explicitely mention Tickers have to be stopped
LGTM=rsc
R=golang-codereviews, gobot, rsc
CC=golang-codereviews
https://golang.org/cl/64770043
2014-02-24 10:18:40 -05:00
Dave Cheney
d98b3a7ee5 time: use an alternative method of yielding during Overflow timer test
Fixes #6874.

Use runtime.GC() as a stronger version of runtime.Gosched() which tends to bias the running goroutine in an otherwise idle system. This appears to reduce the worst case number of spins from 600 down to 30 on my 2 core system under high load.

LGTM=iant
R=golang-codereviews, lucio.dere, iant, dvyukov
CC=golang-codereviews
https://golang.org/cl/56540046
2014-02-02 16:05:07 +11:00
Ian Lance Taylor
fabd261fe2 time: use names for beginning and end of zone transition times
No functional changes, just more readable code.

LGTM=r
R=golang-codereviews, gobot, r
CC=golang-codereviews
https://golang.org/cl/59240043
2014-01-31 17:22:10 -08:00
Ian Lance Taylor
52a73239bb time: correctly handle timezone before first transition time
LGTM=r
R=golang-codereviews, r, arnehormann, bradfitz
CC=golang-codereviews
https://golang.org/cl/58450043
2014-01-31 14:40:13 -08:00
David du Colombier
496c030c50 time: increase timeout of TestOverflowRuntimeTimer on Plan 9
LGTM=dvyukov
R=dvyukov
CC=golang-codereviews
https://golang.org/cl/53000043
2014-01-27 11:11:44 +01:00
Rob Pike
f8cd243669 time: break parse and formatting tests into a separate source file
No changes, just rearrangement. The tests were in need of a little
housekeeping.

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/53400043
2014-01-16 14:30:01 -08:00
Aram Hăvărneanu
f952d45508 all: add solaris build tags
R=golang-codereviews, minux.ma, gobot, rsc, dave
CC=golang-codereviews
https://golang.org/cl/36040043
2014-01-07 23:53:30 -05:00
Shawn Smith
16134060de time: add tests for Tick, NewTicker with negative duration
R=golang-codereviews, gobot, r, bradfitz
CC=golang-codereviews
https://golang.org/cl/37660044
2014-01-06 10:32:07 -08:00
Shawn Smith
b38da05ab1 time: add tests for Duration.Nanoseconds, Duration.Minutes, and Duration.Hours
R=golang-codereviews, rsc, dave
CC=golang-codereviews
https://golang.org/cl/42440043
2014-01-02 21:01:18 +11:00
Shenghou Ma
98f16ad112 time: fix test error in Chinese edition of Windows
On the Chinese Windows XP system that I'm using, GetTimeZoneInformation returns a struct containing "中国标准时间" (China Standard Time in Chinese) in both StandardName and DaylightName (which is correct, because China does not use DST). However, in registry, under key HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\China Standard Time, the key Std and Dlt contain "中国标准时间" (China Standard Time in Chinese) and "中国夏季时间" (China Summer Time in Chinese) respectively. This means that time.toEnglishName() cannot determine the abbreviation for the local timezone (CST) and causes test failures (time.Local is empty)

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/43210043
2013-12-17 02:43:14 -05:00
Russ Cox
a508381e89 time: correct path to time zone zip file on Unix
Most Unix systems have their own time zone data,
so we almost never get far enough in the list to
discover that we cannot fall back to the zip file.
Adjust testing to exercise the final fallback.

Plan 9 and Windows were already correct
(and are the main users of the zip file).

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/19280043
2013-10-29 17:11:51 -04:00
Shenghou Ma
d220c9957c time: fix ParseDuration overflow when given more than 9 digits on 32-bit arch
Fixes #6617.

R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/15080043
2013-10-22 18:33:05 -04:00
Alex Brainman
5f75314e18 time: allow more time for TestOverflowRuntimeTimer to succeed
Attempting to fix windows gobuilders

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/13507044
2013-09-09 15:50:11 +10:00
Anthony Martin
3548ab5ebb runtime: handle timer overflow in tsleep
Make sure we never pass a timer into timerproc with
a negative duration since it will cause other timers
to never expire.

Fixes #5321.

R=golang-dev, minux.ma, remyoudompheng, mikioh.mikioh, r, bradfitz, rsc, dvyukov
CC=golang-dev
https://golang.org/cl/9035047
2013-09-06 15:47:39 -04:00
Brad Fitzpatrick
8159b6901f time: add more docs on Sleep
Merge the comment from runtime/time.goc ("at least")
and also note that negative is okay and won't crash.
I see people going out of their way to avoid passing
a negative value to Sleep.

R=golang-dev, adg, r, alex.brainman
CC=golang-dev
https://golang.org/cl/13271045
2013-08-28 11:16:55 -07:00
Joel Sing
4186e9d313 all: dragonfly support
Enable remaining packages (crypto, mime, path, time) to build on dragonfly.

R=bradfitz
CC=golang-dev
https://golang.org/cl/13190043
2013-08-24 02:22:52 +10:00
Sokolov Yura
fcf6a7e5ce time: make timers heap 4-ary
This slightly improves performance when a lot of timers are present

$ misc/benchcmp ../old_timers_m.txt ../new_timers_m.txt
benchmark                           old ns/op    new ns/op    delta
BenchmarkAfterFunc                       6884         6605   -4.05%
BenchmarkAfterFunc-2                     4473         4144   -7.36%
BenchmarkAfterFunc-3                     8601         6185  -28.09%
BenchmarkAfterFunc-4                     9378         8773   -6.45%
BenchmarkAfter                           7237         7278   +0.57%
BenchmarkAfter-2                         4638         3923  -15.42%
BenchmarkAfter-3                         8751         6239  -28.71%
BenchmarkAfter-4                         9223         8737   -5.27%
BenchmarkStop                             603          496  -17.74%
BenchmarkStop-2                           795          577  -27.42%
BenchmarkStop-3                           982          680  -30.75%
BenchmarkStop-4                          1164          739  -36.51%
BenchmarkSimultaneousAfterFunc            657          593   -9.74%
BenchmarkSimultaneousAfterFunc-2          816          757   -7.23%
BenchmarkSimultaneousAfterFunc-3          844          830   -1.66%
BenchmarkSimultaneousAfterFunc-4          785          771   -1.78%
BenchmarkStartStop                        238          239   +0.42%
BenchmarkStartStop-2                      249          234   -6.02%
BenchmarkStartStop-3                      271          268   -1.11%
BenchmarkStartStop-4                      293          295   +0.68%

R=golang-dev, dvyukov, bradfitz, r
CC=golang-dev
https://golang.org/cl/13094043
2013-08-21 18:51:37 +04:00
Rob Pike
f578726de1 all: protect alloc count tests by -testing.short
Update #5000
Should reduce the flakiness a little. Malloc counting is important
to general testing but not to the build dashboard, which uses -short.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12866047
2013-08-21 14:00:45 +10:00
Rob Pike
4c855f3830 time: fix time zones yet again.
This time we're going for 5!
http://goo.gl/3ETYH7

Fixes #3790
Yeah, right.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13002044
2013-08-16 14:57:49 +10:00
Rob Pike
a454d2fd2e time: expand acceptance of time zones when parsing
I tried to make it absolutely correct but there are too many
conflicting definitions for the official list of time zones.
Since when we're parsing we know when to expect
a time zone and we know what they look like if not exactly
what the definitive set is, we compromise. We accept any
three-character sequence of upper case letters, possibly
followed by a capital T (all four-letter zones end in T).

There is one crazy special case (ChST) and the possibility
of a signed hour offset for GMT.

Fixes #3790
I hope forever, but I doubt that very much.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/12969043
2013-08-15 16:42:54 +10:00
Rob Pike
727b2b6f7d time: handle GMT possibly with offset
Update #3790
Handle time zones like GMT-8.
The more general time zone-matching problem is not yet resolved.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12922043
2013-08-15 10:10:49 +10:00
Russ Cox
071e44e4e4 time: make Time implement encoding interfaces
See golang.org/s/go12encoding for design.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12706043
2013-08-14 00:34:00 -04:00
Rob Pike
af8426eebe time: match month and day names only when not followed immediately by a lower-case letter
Avoids seeing "Janet" as "Januaryet".

Fixes #6020.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12448044
2013-08-05 10:53:46 +10:00
Rob Pike
16c9d3616a various: deleted unused items
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12396043
2013-08-03 16:01:04 +10:00
Ulf Holm Nielsen
aa38aeaeaf time: Allow Parse and Format to handle time zone offsets with seconds
Adds layout cases with seconds for stdISO8601 and stdNumTZ with and without colons. Update time.Format to append seconds for those cases.

Fixes #4934.

R=golang-dev, r, bradfitz
CC=golang-dev
https://golang.org/cl/8132044
2013-07-31 16:11:02 +10:00
Alex Brainman
231dfd9049 time: find correct zone abbreviations even on non-English windows systems
Fixes #5783

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10956043
2013-07-10 15:34:24 +10:00
Jeff R. Allen
0286b4738e time: prevent a panic from leaving the timer mutex held
When deleting a timer, a panic due to nil deref
would leave a lock held, possibly leading to a deadlock
in a defer. Instead return false on a nil timer.

Fixes #5745.

R=golang-dev, daniel.morsing, dvyukov, rsc, iant
CC=golang-dev
https://golang.org/cl/10373047
2013-07-01 21:42:29 -04:00
Russ Cox
f21bc7920d time: avoid garbage collector aliasing bug
Time is a tiny struct, so the compiler copies a Time by
copying each of the three fields.

The layout of a time on amd64 is [ptr int32 gap32 ptr].
Copying a Time onto a location that formerly held a pointer in the
second word changes only the low 32 bits, creating a different
but still plausible pointer. This confuses the garbage collector
when it appears in argument or result frames.

To avoid this problem, declare nsec as uintptr, so that there is
no gap on amd64 anymore, and therefore no partial pointers.

Note that rearranging the fields to put the int32 last still leaves
a gap - [ptr ptr int32 gap32] - because Time must have a total
size that is ptr-width aligned.

Update #5749

This CL is enough to fix the problem, but we should still do
the other actions listed in the initial report. We're not too far
from completely precise collection.

R=golang-dev, dvyukov, r
CC=golang-dev
https://golang.org/cl/10504043
2013-06-24 14:49:35 -04:00
Rick Arnold
fc0b5ef0fd time: handle integer overflow in Sub
If time.Sub results in a value that won't fit in a Duration (int64),
return either the min or max int64 value as appropriate.

Fixes #5011.

R=golang-dev, bradfitz, r, rsc
CC=golang-dev
https://golang.org/cl/10328043
2013-06-21 18:07:57 -07:00
Rob Pike
0bc7e79afd all: excise some warts found by vet -shadow
These are not erroneous, just poor or confusing.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/10448043
2013-06-20 16:14:40 -07:00
Alex Brainman
07ea243d50 time: provide timezone abbreviations on windows
Use http://unicode.org/cldr/data/common/supplemental/windowsZones.xml
to generate the map.

Fixes #4838.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/9997043
2013-06-06 16:30:25 +10:00
Brad Fitzpatrick
509a1173a3 time: remove Time.FormatAppend
undo CL 8478044 / 0d28fd55e721

Lack of consensus.

««« original CL description
time: add Time.FormatAppend

This is a version of Time.Format that doesn't require allocation.

Fixes #5192
Update #5195

R=r
CC=gobot, golang-dev
https://golang.org/cl/8478044
»»»

R=r
CC=golang-dev
https://golang.org/cl/9462049
2013-05-21 14:32:09 -07:00
Brad Fitzpatrick
0af302f507 time: add Time.FormatAppend
This is a version of Time.Format that doesn't require allocation.

Fixes #5192
Update #5195

R=r
CC=gobot, golang-dev
https://golang.org/cl/8478044
2013-05-15 17:23:40 -07:00
Dmitriy Vyukov
489addd250 time: stop 1ns timer in test
R=golang-dev, adg, r
CC=golang-dev
https://golang.org/cl/8819046
2013-04-26 11:08:50 +04:00
Christian Himpel
237cee7834 time: fix typo in comment
R=r
CC=golang-dev
https://golang.org/cl/8889045
2013-04-22 22:09:11 -07:00
Rob Pike
14234c23a8 time: fix typo in comment
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/8915043
2013-04-22 15:41:06 -07:00
Rob Pike
c285789059 time: improve the explanation of the working of Format and Parse
Change the term 'standard time', which already means something,
to 'reference time', and add a couple of sentences and clarifications.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/8799047
2013-04-22 11:36:17 -07: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
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
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
Russ Cox
6b4cf2b367 time: fix error message from Parse
Was incorrectly discarding the offending text in some cases.

Fixes #4493.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7277050
2013-02-04 00:00:36 -05:00
Russ Cox
1d9f67daf0 time: deal a bit better with time zones in Parse
* Document Parse's zone interpretation.
* Add ParseInLocation (API change).
* Recognize "wrong" time zone names, like daylight savings time in winter.
* Disambiguate time zone names using offset (like winter EST vs summer EST in Sydney).

The final two are backwards-incompatible changes, but I believe
they are both buggy behavior in the Go 1.0 versions; the old results
were more wrong than the new ones.

Fixes #3604.
Fixes #3653.
Fixes #4001.

R=adg
CC=golang-dev
https://golang.org/cl/7288052
2013-02-03 23:02:12 -05:00
Russ Cox
6a003d7589 time: handle zone file with no transitions
Code fix by Alex Bramley.

Fixes #4064.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7289049
2013-02-03 22:41:00 -05:00
Kyle Lemons
9bfd3c3937 testing: add AllocsPerRun
This CL also replaces similar loops in other stdlib
package tests with calls to AllocsPerRun.

Fixes #4461.

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7002055
2013-02-02 22:52:29 -05:00
Brad Fitzpatrick
86a8d59a01 time: make TestReset more reliable
Fixes #4690

R=golang-dev, alex.brainman, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7181052
2013-01-22 17:25:58 -08:00
Caleb Spare
657168fb17 time: standard time doc fix and format example
This fixes the incorrect unix timestamp of the standard time and adds
an example for (Time) Format to clarify how timezones work in format strings.

Fixes #4364.

R=golang-dev, remyoudompheng, kevlar, rsc
CC=golang-dev
https://golang.org/cl/7069046
2013-01-22 14:44:49 -05:00