diff options
author | Russ Cox <rsc@golang.org> | 2014-09-08 00:08:51 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-09-08 00:08:51 -0400 |
commit | 8528da672cc093d4dd06732819abc1f7b6b5a46e (patch) | |
tree | 334be80d4a4c85b77db6f6fdb67cbf0528cba5f5 /src/runtime/mgc0.go | |
parent | 73bcb69f272cbf34ddcc9daa56427a8683b5a95d (diff) | |
download | go-8528da672cc093d4dd06732819abc1f7b6b5a46e.tar.gz |
build: move package sources from src/pkg to src
Preparation was in CL 134570043.
This CL contains only the effect of 'hg mv src/pkg/* src'.
For more about the move, see golang.org/s/go14nopkg.
Diffstat (limited to 'src/runtime/mgc0.go')
-rw-r--r-- | src/runtime/mgc0.go | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/runtime/mgc0.go b/src/runtime/mgc0.go new file mode 100644 index 000000000..2d9d76a47 --- /dev/null +++ b/src/runtime/mgc0.go @@ -0,0 +1,70 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package runtime + +// Called from C. Returns the Go type *m. +func gc_m_ptr(ret *interface{}) { + *ret = (*m)(nil) +} + +// Called from C. Returns the Go type *g. +func gc_g_ptr(ret *interface{}) { + *ret = (*g)(nil) +} + +// Called from C. Returns the Go type *itab. +func gc_itab_ptr(ret *interface{}) { + *ret = (*itab)(nil) +} + +// Type used for "conservative" allocations in C code. +type notype [8]*byte + +// Called from C. Returns the Go type used for C allocations w/o type. +func gc_notype_ptr(ret *interface{}) { + var x notype + *ret = x +} + +func timenow() (sec int64, nsec int32) + +func gc_unixnanotime(now *int64) { + sec, nsec := timenow() + *now = sec*1e9 + int64(nsec) +} + +func freeOSMemory() { + gogc(2) // force GC and do eager sweep + onM(scavenge_m) +} + +var poolcleanup func() + +func registerPoolCleanup(f func()) { + poolcleanup = f +} + +func clearpools() { + // clear sync.Pools + if poolcleanup != nil { + poolcleanup() + } + + for _, p := range &allp { + if p == nil { + break + } + // clear tinyalloc pool + if c := p.mcache; c != nil { + c.tiny = nil + c.tinysize = 0 + c.sudogcache = nil + } + // clear defer pools + for i := range p.deferpool { + p.deferpool[i] = nil + } + } +} |