Adds two more methods, Timeout and Temporary.
Implemented by os.Errno too. The intent is to make
the checks for os.EAGAIN a little less clunky.
It should also let us clean up a bug that Mike Solomon
pointed out: if a network server gets an "out of file descriptors"
error from Accept, the listener should not stop.
It will be able to check this because that error would
have Temporary() == true.
Also clean up some underscore names.
Fixes#442.
R=r
CC=golang-dev, msolo
https://golang.org/cl/957045
There was a bug in makeN that caused lots of unnecessary
allocations. Fixing this exposed a few bugs in other
functions which worked when makeN allocated a new slice, but
failed when it simply resized an existing slice. The result
is a pretty big performance improvement. When running
pidigits, here were the numbers I got on amd64:
Before this change:
pidigits 10000
gcc -O2 pidigits.c -lgmp 2.09u 0.02s 2.11r
gc pidigits 12.68u 0.04s 12.72r
gc_B pidigits 12.71u 0.03s 12.75r
After:
pidigits 10000
gcc -O2 pidigits.c -lgmp 2.09u 0.00s 2.10r
gc pidigits 6.82u 0.00s 6.85r
gc_B pidigits 6.55u 0.01s 6.59r
R=rsc, gri
CC=golang-dev
https://golang.org/cl/953042
Due to page boundary rounding, the header would have
been loaded as part of the text segment already, but this
change placates the "paxctl" tool on so-called hardened
Linux distributions (as if normal distributions weren't already
hard enough to use).
R=r
CC=golang-dev
https://golang.org/cl/954041
SETSID does return an errno - any reason why it has been done this
way in zsyscall_linux_* ? Otherwise it should be the same as darwin.
From SETSID(2) on my Linux box:
ERRORS
On error, -1 is returned, and errno is set.
Fixes#730
R=rsc
CC=golang-dev
https://golang.org/cl/878047
This is the first of probably four separate CLs
for the new implementation of the json package.
The scanner is the core of the new implementation.
The other CLs would be the new decoder,
the new encoder, and support for JSON streams.
R=r
CC=golang-dev
https://golang.org/cl/802051
$ godoc xml | grep Copy\(\)
func (c CharData) Copy() CharData
func (c Comment) Copy() Comment
func (d Directive) Copy() Directive
func (p ProcInst) Copy() ProcInst
func (e StartElement) Copy() StartElement
--------------------------------------------
$ godoc -src xml | grep Copy\(\)
func (c CharData) Copy() CharData
--------------------------------------------
$ godoc -src xml Copy
func (c CharData) Copy() CharData { return CharData(makeCopy(c)) }
--------------------------------------------
The command "godoc -src pkg_name" should output the interface of the named package, but it excludes all duplicate entries. Also the command "godoc -src pkg_name method_name" will output the source code only for one method even if there are more of them with the same name in the same package. This patch set fixes this issue.
R=gri
CC=golang-dev
https://golang.org/cl/883051
fmt.Printf("%b", int8(-1)) prints 64 ones instead of 8.
This happens only for signed integers (int8, in16 and int32). I guess it's because of the way the conversion between integer types works. From go spec: "Conversions between integer types. If the value is a signed quantity, it is sign extended to implicit infinite precision ....". And there are several conversions to int64 and uint64 in the fmt package. This pathch solves only half of the problem. On a 32 bit system, an fmt.Printf("%b", int(-1)) should still print 64 ones.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/891049
This is required to make cgo export work on Darwin. Note that
this corrects the stack alignment when calling initcgo to that
required by gcc on amd64.
R=rsc
CC=golang-dev
https://golang.org/cl/907041
The new //export comment marks a Go function as callable from
C. The syntax is "//export NAME" where NAME is the name of
the function as seen from C. If such a comment is seen, cgo
will generate two new files: _cgo_export.h and _cgo_export.c.
The _cgo_export.h file provides declarations which C code may
use to call Go functions. The _cgo_export.c file contains
wrappers, and is to be compiled with gcc.
The changes to Make.pkg support using this from a Go Makefile,
though it could probably be more convenient.
R=rsc
CC=golang-dev
https://golang.org/cl/853042
These functions are used to call from a C function back to a
Go function. This only includes 386 support.
R=rsc
CC=golang-dev
https://golang.org/cl/834045
tested on linux/amd64, linux/386, linux/arm, darwin/amd64, darwin/386.
freebsd untested; will finish in a separate CL.
for now all the panics are errorStrings.
richer structures can be added as necessary
once the mechanism is shaked out.
R=r
CC=golang-dev
https://golang.org/cl/906041
Could not take a signal on threads other than the main thread.
If you look at the spinning binary with dtrace, you can see a
fault happening over and over:
$ dtrace -n '
fbt::user_trap:entry /execname=="boot32" && self->count < 10/
{
self->count++;
printf("%s %x %x %x %x", probefunc, arg1, arg2, arg3, arg4);
stack();
tracemem(arg4, 256);
}'
dtrace: description 'fbt::user_trap:entry ' matched 1 probe
CPU ID FUNCTION:NAME
1 17015 user_trap:entry user_trap 0 10 79af0a0 79af0a0
mach_kernel`lo_alltraps+0x12a
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
0: 0e 00 00 00 37 00 00 00 00 00 00 00 1f 00 00 00 ....7...........
10: 1f 00 00 00 a8 33 00 00 00 00 00 01 00 00 00 00 .....3..........
20: 98 ba dc fe 07 09 00 00 00 00 00 00 98 ba dc fe ................
30: 06 00 00 00 0d 00 00 00 34 00 00 00 9e 1c 00 00 ........4.......
40: 17 00 00 00 00 02 00 00 ac 30 00 00 1f 00 00 00 .........0......
50: 00 00 00 00 00 00 00 00 0d 00 00 00 e0 e6 29 00 ..............).
60: 34 00 00 00 00 00 00 00 9e 1c 00 00 00 00 00 00 4...............
70: 17 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 ................
80: ac 30 00 00 00 00 00 00 1f 00 00 00 00 00 00 00 .0..............
90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
a0: 48 00 00 00 10 00 00 00 85 00 00 00 a0 f2 29 00 H.............).
b0: 69 01 00 02 00 00 00 00 e6 93 04 82 ff 7f 00 00 i...............
c0: 2f 00 00 00 00 00 00 00 06 02 00 00 00 00 00 00 /...............
d0: 78 ee 42 01 01 00 00 00 1f 00 00 00 00 00 00 00 x.B.............
e0: 00 ed 9a 07 00 00 00 00 00 00 00 00 00 00 00 00 ................
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
...
The memory dump shows a 32-bit exception frame:
x86_saved_state32
gs = 0x37
fs = 0
es = 0x1f
ds = 0x1f
edi = 0x33a8
esi = 0x01000000
ebp = 0
cr2 = 0xfedcba98
ebx = 0x0907
edx = 0
ecx = 0xfedcba98
eax = 0x06
trapno = 0x0d
err = 0x34
eip = 0x1c9e
cs = 0x17
efl = 0x0200
uesp = 0x30ac
ss = 0x1f
The cr2 of 0xfedcba98 is the address that the new thread read
to cause the fault, but note that the trap is now a GP fault with
error code 0x34, meaning it's moved past the cr2 problem and on
to an invaild segment selector. The 0x34 is suspiciously similar
to the 0x37 in gs, and sure enough, OS X forces gs to have
that value in the signal handler, and if your thread hasn't set
up that segment (known as USER_CTHREAD), you'll fault on the IRET
into the signal handler and never be able to handle a signal.
The kernel bug is that it forces segment 0x37 without making sure
it is a valid segment. Leopard also forced 0x37 but had the courtesy
to set it up first.
Since OS X requires us to set up that segment (using the
thread_fast_set_cthread_self system call), we might as well
use it instead of the more complicated i386_set_ldt call to
set up our per-OS thread storage.
Also add some more zeros to bsdthread_register for new arguments
in Snow Leopard (apparently unnecessary, but being careful).
Fixes#510.
R=r
CC=golang-dev
https://golang.org/cl/824046
data just read from the channel.
this will make it easier to
recognize when to garbage
collect and finalize.
R=rsc
CC=golang-dev
https://golang.org/cl/882043
The cycle is *netFD -> cw chanl *netFD in struct ->
same *netFD in channel read buffer.
Because channels are finalized, the cycle makes them
uncollectable. A better fix is to make channels not
finalized anymore, and that will happen, but this is
an easy, reasonable workaround until then.
Another good fix would be to zero the channel receive
buffer entry after the receive. That too will happen.
R=r
CC=golang-dev
https://golang.org/cl/875043
1. Fix bug in GOMAXPROCS when trying to cut number of procs
Race could happen on any system but was
manifesting only on Xen hosted Linux.
2. Fix recover on ARM, where FP != caller SP.
R=r
CC=golang-dev
https://golang.org/cl/880043
Instead of calling the package scope Lex function,
Parse now takes an argument which is used to
do the lexing.
I reverted to having the generated switch
code inside Parse rather than a separate function because
the function needs 7 arguments or a context structure,
which seems unnecessary.
I used yyrun(), not the original $A so that
it's possible to run the backquoted code through gofmt.
R=rsc, ken2, ken3
CC=golang-dev
https://golang.org/cl/879041
This is a documentation enhancement only, without any code
change.
The rationale for documenting this precisely is that Unix
programmers who "know" that errno's value is undefined after
a successful system call may be surprised otherwise and
search to be sure that a zero errno may be relied upon after
successful calls.
R=r, rsc1, rsc
CC=golang-dev
https://golang.org/cl/812044
log: add test of Caller
New regexp in log test is picky and will require some
maintenance, but it catches off-by-one mistakes too.
Fixes#710.
R=gri
CC=esko.luontola, golang-dev
https://golang.org/cl/887043
* correct symbol table size
* do not reorder functions in output
* traceback
* signal handling
* use same code for go + defer
* handle leaf functions in symbol table
R=kaib, dpx
CC=golang-dev
https://golang.org/cl/884041
* adds pass 3 to dequeue from channels eagerly
various other cleanup/churn:
* use switch on cas->send in each pass to
factor out common code.
* longer goto labels, commented at target
* be more agressive about can't happen:
throw instead of print + cope.
* use "select" instead of "selectgo" in errors
* use printf for debug prints when possible
R=ken2, ken3
CC=golang-dev, r
https://golang.org/cl/875041
factor out environment variable checks.
infer $GOROOT etc during build if not set.
it's still necessary to set them for yourself
to use the standard Makefiles.
when running all.bash, don't recompile all the
go packages in run.bash, since make.bash already did.
R=r
CC=golang-dev
https://golang.org/cl/609042
in character and string case mapping routines.
Add a custom mapper for Turkish and Azeri.
A more general solution for deriving the case information from Unicode's
SpecialCasing.txt will require more work.
Fixes#703.
R=rsc, rsc1
CC=golang-dev, mdakin
https://golang.org/cl/824043
instead use pure substring matching to find template values.
this makes stdZulu unnecessary and allows formats
like "20060102 030405" (used in some internet protocols).
this makes Parse not handle years < 0000 or > 9999 anymore.
that seems like an okay price to pay, trading hypothetical
functionality for real functionality.
also changed the comments on the Time struct to use the
same reference date as the format and parse routines.
R=r
CC=golang-dev
https://golang.org/cl/833045
main semantic change is to enforce single argument to panic.
runtime: change to 1-argument panic.
use String method on argument if it has one.
R=ken2, r
CC=golang-dev
https://golang.org/cl/812043
note that sortmain.go has been run through hg gofmt;
only the formatting of the day initializers changed.
i'm happy to revert that formatting if you'd prefer.
stop on error in doc/progs/run
R=r
CC=golang-dev
https://golang.org/cl/850041
the set() method and add() functions. But we rename add() to Var() for consistency.
Also rename FlagValue to Value for simplicity.
Also, delete the check for multiple settings for a flag. This makes it possible to
define a flag that collects values, such as into a slice of strings.
type flagVar []string
func (f *flagVar) String() string {
return fmt.Sprint(v)
}
func (f *flagVar) Set(value string) bool {
if v == nil {
v = make(flagVar, 1)
} else {
nv := make(flagVar, len(v)+1)
copy(nv, v)
v = nv
}
v[len(v)-1] = value
return true
}
var v flagVar
func main() {
flag.Var(&v, "testV", "multiple values build []string")
flag.Parse()
fmt.Printf("v = %v\n", v)
}
R=rsc
CC=golang-dev
https://golang.org/cl/842041
This is a modified version of the open source pprof
from code.google.com/p/google-perftools.
That version is likely to catch up to this one,
but it's still useful to ship our own copy since
we only need the one script from that project,
not all the C++ libraries.
R=r
CC=golang-dev
https://golang.org/cl/783041
In this change I'd like to combine the common code that is
present in syscall_darwin.go and syscall_freebsd.go. I
have three reasons for wanting to do this now:
1. reducing code duplication is nearly always good :-)
2. the duplication will get worse if I duplicate this code
a third time for the NetBSD port I'm working on, which
I need to do almost immediately
3. by making this change all in one lump and ignoring any
commonality with the syscall_linux*.go files the diff
is long but, I think, readable
In future it may be possible to cherry pick functions that
also apply to Linux and put them in (say) syscall_unix.go,
and of course some functions may diverge in future and have
to move out to OS or architecture specific files, but today
I want just the low hanging fruit.
Tested and passed on:
Darwin (Snow Leopard, 10.6): amd64 and 386
FreeBSD (8.0-RELEASE): 386 only(*)
(*) All my virtualisation software has stopped playing nice
with FreeBSD for the moment, so I don't have facilities to
test the amd64 port. As the OS X port is OK and the diff
looks all right to my eyes I shall keep my fingers crossed.
If someone with a FreeBSD/amd64 system cares to test and
report I would be appreciative.
2010-03-27 update: I have replaced my virtualisation software, and have working FreeBSD/i386 and FreeBSD/amd64 virtual machines again.
As I hoped (and expected -- programmers are optimists :-) the code built and passed all but the two currently known to fail tests on FreeBSD/amd64. I rechecked FreeBSD/i386 too: same results.
R=rsc
CC=golang-dev
https://golang.org/cl/751041
- new heuristic: if both the opening { and closing } braces are on the
same line, and the function body doesn't contain comments or is other-
wise too long (e.g. signature too long), it is formatted as a one-line
function
- related cleanups along the way
- gofmt -w src misc led to no additional changes as expected
R=rsc, rsc1
CC=golang-dev, ken2, r
https://golang.org/cl/758041
up to date.
No functional change, but when these files are regenerated
they change, leading to noisy diffs when working in the
syscall package.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/705043
- change the various url-xxx formatters to return a relative URL path
- make the leading '/' for URLs explicit in the template
- on the way change some |html formatters to |html-esc
(html should only be used for formatting AST nodes)
R=rsc, r
CC=golang-dev
https://golang.org/cl/740041
Instead of returning the index lookup result via
RPC which has to be corrected for the client,
simply render it on the server and return the
final output.
R=rsc, r
CC=golang-dev
https://golang.org/cl/669041
and highlight special words, if provided. Also:
- related cleanups in src/pkg/go/doc/comment.go
- fix typos in src/cmd/goinstall/doc.go
Fixes#672.
R=rsc
CC=adg, golang-dev
https://golang.org/cl/601042
The command-line search is using a running webserver
as index server; i.e., the search result is reflecting
the index at the server. See the documentation for
details.
Usage: godoc -q query1 query2 ...
Known issue: Results don't show the all-important
line numbers yet due to the way the index is organized.
Next CL.
R=rsc, r
CC=golang-dev
https://golang.org/cl/648041
- mkall now generates syscall stabs automatically
- we can call unicode versions of winapi now
- introduce GetErrstr function to fetch error text given errno
- general cleanup
R=rsc
CC=golang-dev
https://golang.org/cl/562041
for identifiers in Go source code
- at the moment just show identifier kind (var, func, etc.) and name
(eventually should show declaration, type, etc.)
- JavaScript parts by adg
R=rsc
CC=adg, golang-dev
https://golang.org/cl/578042
a /*-style comment at the end of a file
Some minor cleanups/typo fixes along the way.
Fixes an issue where that newline was removed
after applying gofmt.
R=r
CC=golang-dev
https://golang.org/cl/476043
visible only when enabling internal debug mode:
- in rare cases expression depth can underflow
- when printing a single labeled statement, indentation
may underflow if not setup correctly
R=rsc
CC=golang-dev
https://golang.org/cl/484041
- on the commandline: godoc -x big
- in a webpage: provide form parameter ?m=src
Known issues:
- Positioning of comments incorrect in several cases. Separate CL.
- Need a link/menu to switch between different modes of presentation
in the web view.
R=rsc
CC=golang-dev
https://golang.org/cl/376041
2. add complex algorithm for map/chan
3. test for use of complex in
array, slice, field, chan, map,
field, pointer.
R=rsc
CC=golang-dev
https://golang.org/cl/384041
trivial stuff
lex.c: these prototypes are in a.h
asm.c: unused variables
arm-pass.txt deal w/ sieve.go rename and addition of sieve2.go
R=kaib, rsc
CC=golang-dev
https://golang.org/cl/244041
This keeps fragmentation from delaying
garbage collections (and causing more fragmentation).
Cuts fresh godoc (with indexes) from 261M to 166M (120M live).
Cuts toy wc program from 50M to 8M.
Fixes#647.
R=r, cw
CC=golang-dev
https://golang.org/cl/257041
Previously we would require safe primes for our RSA key generation.
Since this took rather a long time, this removes the requirement that
the primes be safe.
OpenSSL doesn't use safe primes for RSA key generation either
(openssl-0.9.8l/crypto/rsa/rsa_gen.c:122)
Fixes#649.
R=rsc
CC=golang-dev
https://golang.org/cl/253041
Use hardware sqrt for faster hypot; preserve software-only
hypot as hypotGo (like sqrtGo); enable benchmarking of
hypotGo.
R=rsc
CC=golang-dev
https://golang.org/cl/229049
probablyPrime would return false negatives in some cases.
This code has now been tested against GMP for several million iterations without issues.
Fixes#638.
R=rsc
CC=golang-dev
https://golang.org/cl/252041
- only manual changes are in src/pkg/go/printer/nodes.go
- use a heuristic to determine "outliers" such that not entire composites are
forced to align with them
- improves several places that were not unligned before due too simple heuristic
- unalignes some cases that contain "outliers"
- gofmt -w src misc
Fixes#644.
R=rsc, r
CC=golang-dev
https://golang.org/cl/241041
Set defaults to the same values as various C DNS resolver libraries.
Use the timeout value from the configuration.
Fixes#632.
R=rsc
CC=golang-dev
https://golang.org/cl/223094
This permits more flexibility with cgo and swig in cases where
the program is run on a machine other than the one on which it
is built. Rather than storing the absolute path to the shared
library in the DT_NEEDED entry, we can store just the name,
and let the dynamic linker find it using DT_RUNPATH or the
LD_LIBRARY_PATH environment variable.
R=rsc
CC=golang-dev
https://golang.org/cl/223068
Background: This didn't matter until recently, because '\n' don't appear as token starts
in source code and thus the exact position was irrelevant (and set as was easiest in the
code). With auto semicolon insertion, a virtual semicolon may be inserted when a '\n' is
seen. The position of the semicolon is the position of the '\n'. Without this fix, these
semicolons appeared on the next line instead of the line where they were inserted. This
affected the association of comments to declarations in the parser. As a result, some
lead comments where considered line comments, not collected in the ast, and not shown in
godoc pages. (This affected only godoc pages, not gofmt-formatted programs).
Fixes#592.
R=rsc
CC=golang-dev
https://golang.org/cl/224068
- gofmt -w src misc
- improves several lists and fixes minor degradation introduced
with the fix for issue 628
- removed some dead code (stringList)
R=rsc
CC=golang-dev
https://golang.org/cl/223058
- applied gofmt to src and misc
Note: This fix improved formatting of src/pkg/math/all_test.go but leads
to a degradation in src/pkg/exp/4s/xs.go. The latter happened to "work"
before accidentally. Fixing the alignment in that case in general will
be a separate CL.
Fixes#628.
R=rsc
CC=golang-dev
https://golang.org/cl/223054
path.Match() errors out when testing "*x" against "xxx"
because it matches the star non-greedily. Ensure that
the last chunk consumes the rest of the name.
R=r, rsc
CC=golang-dev
https://golang.org/cl/223050
- always include position information about opening/closing parens/braces
- replace uses of []*ast.Field with *ast.FieldList
Fixes#473.
R=rsc
CC=golang-dev
https://golang.org/cl/223043
- remove several TODOs
- as a side-effect, comment stylers are now used always and comments
will be properly colored in godoc pkg documentation pages (and not
only when looking at source text)
R=rsc
CC=golang-dev
https://golang.org/cl/222041