From d2574e2adb658b46ea2d8e22b3195cc14da1affe Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 16 Sep 2014 10:22:15 -0400 Subject: runtime: remove duplicated Go constants The C header files are the single point of truth: every C enum constant Foo is available to Go as _Foo. Remove or redirect duplicate Go declarations so they cannot be out of sync. Eventually we will need to put constants in Go, but for now having them be out of sync with C is too risky. These predate the build support for auto-generating Go constants from the C definitions. LGTM=iant R=iant CC=golang-codereviews https://golang.org/cl/141510043 --- src/runtime/malloc.go | 48 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) (limited to 'src/runtime/malloc.go') diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index d6f1a1a4a2..7bb85057f4 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -11,49 +11,41 @@ import ( const ( debugMalloc = false - flagNoScan = 1 << 0 // GC doesn't have to scan object - flagNoZero = 1 << 1 // don't zero memory + flagNoScan = _FlagNoScan + flagNoZero = _FlagNoZero - maxTinySize = 16 - tinySizeClass = 2 - maxSmallSize = 32 << 10 + maxTinySize = _TinySize + tinySizeClass = _TinySizeClass + maxSmallSize = _MaxSmallSize - pageShift = 13 - pageSize = 1 << pageShift - pageMask = pageSize - 1 + pageShift = _PageShift + pageSize = _PageSize + pageMask = _PageMask - bitsPerPointer = 2 - bitsMask = 1<>pageShift) type pageID uintptr -// All zero-sized allocations return a pointer to this byte. -var zeroObject byte - -// Maximum possible heap size. -var maxMem uintptr +// base address for all 0-byte allocations +var zerobase uintptr // Allocate an object of size bytes. // Small objects are allocated from the per-P cache's free lists. // Large objects (> 32 kB) are allocated straight from the heap. func mallocgc(size uintptr, typ *_type, flags int) unsafe.Pointer { if size == 0 { - return unsafe.Pointer(&zeroObject) + return unsafe.Pointer(&zerobase) } size0 := size @@ -357,7 +349,7 @@ func newarray(typ *_type, n uintptr) unsafe.Pointer { if typ.kind&kindNoPointers != 0 { flags |= flagNoScan } - if int(n) < 0 || (typ.size > 0 && n > maxMem/uintptr(typ.size)) { + if int(n) < 0 || (typ.size > 0 && n > maxmem/uintptr(typ.size)) { panic("runtime: allocation size out of range") } return mallocgc(uintptr(typ.size)*n, typ, flags) -- cgit v1.3