From ede6718cd78853d409b8a7dccf8e7f4cedb6dd51 Mon Sep 17 00:00:00 2001 From: Jan Ziak <0xe2.0x9a.0x9b@gmail.com> Date: Wed, 6 Jun 2012 17:20:02 -0400 Subject: [PATCH] runtime: move type kinds into a separate file R=rsc CC=golang-dev https://golang.org/cl/6285047 --- src/pkg/runtime/iface.c | 1 + src/pkg/runtime/malloc.goc | 1 + src/pkg/runtime/slice.c | 1 + src/pkg/runtime/type.h | 32 +------------------------------- src/pkg/runtime/typekind.h | 38 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 42 insertions(+), 31 deletions(-) create mode 100644 src/pkg/runtime/typekind.h diff --git a/src/pkg/runtime/iface.c b/src/pkg/runtime/iface.c index b7eb2c18d1..358cdcbbb6 100644 --- a/src/pkg/runtime/iface.c +++ b/src/pkg/runtime/iface.c @@ -5,6 +5,7 @@ #include "runtime.h" #include "arch_GOARCH.h" #include "type.h" +#include "typekind.h" #include "malloc.h" void diff --git a/src/pkg/runtime/malloc.goc b/src/pkg/runtime/malloc.goc index c2727bf2b4..44b68a728d 100644 --- a/src/pkg/runtime/malloc.goc +++ b/src/pkg/runtime/malloc.goc @@ -13,6 +13,7 @@ package runtime #include "malloc.h" #include "defs_GOOS_GOARCH.h" #include "type.h" +#include "typekind.h" #pragma dataflag 16 /* mark mheap as 'no pointers', hiding from garbage collector */ MHeap runtime·mheap; diff --git a/src/pkg/runtime/slice.c b/src/pkg/runtime/slice.c index 3c7c8be0e9..9cb1ccb788 100644 --- a/src/pkg/runtime/slice.c +++ b/src/pkg/runtime/slice.c @@ -5,6 +5,7 @@ #include "runtime.h" #include "arch_GOARCH.h" #include "type.h" +#include "typekind.h" #include "malloc.h" static int32 debug = 0; diff --git a/src/pkg/runtime/type.h b/src/pkg/runtime/type.h index ca81e84657..ec2299692d 100644 --- a/src/pkg/runtime/type.h +++ b/src/pkg/runtime/type.h @@ -19,6 +19,7 @@ typedef struct IMethod IMethod; typedef struct SliceType SliceType; typedef struct FuncType FuncType; +// Needs to be in sync with typekind.h/CommonSize struct CommonType { uintptr size; @@ -34,37 +35,6 @@ struct CommonType Type *ptrto; }; -enum { - KindBool = 1, - KindInt, - KindInt8, - KindInt16, - KindInt32, - KindInt64, - KindUint, - KindUint8, - KindUint16, - KindUint32, - KindUint64, - KindUintptr, - KindFloat32, - KindFloat64, - KindComplex64, - KindComplex128, - KindArray, - KindChan, - KindFunc, - KindInterface, - KindMap, - KindPtr, - KindSlice, - KindString, - KindStruct, - KindUnsafePointer, - - KindNoPointers = 1<<7, -}; - struct Method { String *name; diff --git a/src/pkg/runtime/typekind.h b/src/pkg/runtime/typekind.h new file mode 100644 index 0000000000..8c58872e17 --- /dev/null +++ b/src/pkg/runtime/typekind.h @@ -0,0 +1,38 @@ +// 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. + +enum { + KindBool = 1, + KindInt, + KindInt8, + KindInt16, + KindInt32, + KindInt64, + KindUint, + KindUint8, + KindUint16, + KindUint32, + KindUint64, + KindUintptr, + KindFloat32, + KindFloat64, + KindComplex64, + KindComplex128, + KindArray, + KindChan, + KindFunc, + KindInterface, + KindMap, + KindPtr, + KindSlice, + KindString, + KindStruct, + KindUnsafePointer, + + KindNoPointers = 1<<7, + + // size of Type interface header + CommonType structure. + CommonSize = 2*sizeof(void*) + 6*sizeof(void*) + 8, +}; + -- 2.48.1