aboutsummaryrefslogtreecommitdiff
path: root/src/pkg
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2009-08-25 15:54:25 -0700
committerRob Pike <r@golang.org>2009-08-25 15:54:25 -0700
commit87f2208bdaa983a7b3de9de98aa88b1f2cd1a4f9 (patch)
treef3913b178bfbc73429efbd39df31e880769d1c3d /src/pkg
parent67815ef65b462b60006ee361538e04fe6913a2bd (diff)
downloadgo-87f2208bdaa983a7b3de9de98aa88b1f2cd1a4f9.tar.xz
rename runtime internals to have modern names (array->slice etc)
R=rsc DELTA=444 (179 added, 177 deleted, 88 changed) OCL=33847 CL=33849
Diffstat (limited to 'src/pkg')
-rw-r--r--src/pkg/runtime/Makefile2
-rw-r--r--src/pkg/runtime/cgo2c.c6
-rw-r--r--src/pkg/runtime/chan.c8
-rw-r--r--src/pkg/runtime/hashmap.c12
-rw-r--r--src/pkg/runtime/iface.c8
-rw-r--r--src/pkg/runtime/reflect.cgo2
-rw-r--r--src/pkg/runtime/runtime.c10
-rw-r--r--src/pkg/runtime/runtime.h12
-rw-r--r--src/pkg/runtime/slice.c (renamed from src/pkg/runtime/array.c)54
-rw-r--r--src/pkg/runtime/string.cgo10
-rw-r--r--src/pkg/runtime/symtab.c22
-rw-r--r--src/pkg/runtime/type.h4
12 files changed, 75 insertions, 75 deletions
diff --git a/src/pkg/runtime/Makefile b/src/pkg/runtime/Makefile
index 7356bd765e..efd3f37de3 100644
--- a/src/pkg/runtime/Makefile
+++ b/src/pkg/runtime/Makefile
@@ -35,7 +35,6 @@ OFILES_arm=\
vlrt.$O\
OFILES=\
- array.$O\
asm.$O\
cgocall.$O\
chan.$O\
@@ -60,6 +59,7 @@ OFILES=\
rt0.$O\
sema.$O\
signal.$O\
+ slice.$O\
string.$O\
symtab.$O\
sys.$O\
diff --git a/src/pkg/runtime/cgo2c.c b/src/pkg/runtime/cgo2c.c
index e6c7634ff7..3b452b78b3 100644
--- a/src/pkg/runtime/cgo2c.c
+++ b/src/pkg/runtime/cgo2c.c
@@ -45,7 +45,7 @@ enum {
Uint,
Uintptr,
String,
- Array,
+ Slice,
};
static struct {
@@ -61,7 +61,7 @@ static struct {
"uint", 4,
"uintptr", 4,
"String", 8,
- "Array", 12,
+ "Slice", 12,
/* fixed size */
"float32", 4,
@@ -710,7 +710,7 @@ main(int argc, char **argv)
if(goarch != NULL && strcmp(goarch, "amd64") == 0) {
type_table[Uintptr].size = 8;
type_table[String].size = 16;
- type_table[Array].size = 8+4+4;
+ type_table[Slice].size = 8+4+4;
structround = 8;
}
}
diff --git a/src/pkg/runtime/chan.c b/src/pkg/runtime/chan.c
index c72ea1dff9..ceebebf8b3 100644
--- a/src/pkg/runtime/chan.c
+++ b/src/pkg/runtime/chan.c
@@ -95,7 +95,7 @@ makechan(uint32 elemsize, uint32 elemalg, uint32 hint)
if(elemalg >= nelem(algarray)) {
printf("chan(alg=%d)\n", elemalg);
- throw("sys·newchan: unsupported elem type");
+ throw("sys·makechan: unsupported elem type");
}
c = mal(sizeof(*c));
@@ -124,7 +124,7 @@ makechan(uint32 elemsize, uint32 elemalg, uint32 hint)
}
if(debug) {
- prints("newchan: chan=");
+ prints("makechan: chan=");
sys·printpointer(c);
prints("; elemsize=");
sys·printint(elemsize);
@@ -138,9 +138,9 @@ makechan(uint32 elemsize, uint32 elemalg, uint32 hint)
return c;
}
-// newchan(elemsize uint32, elemalg uint32, hint uint32) (hchan *chan any);
+// makechan(elemsize uint32, elemalg uint32, hint uint32) (hchan *chan any);
void
-sys·newchan(uint32 elemsize, uint32 elemalg, uint32 hint, Hchan *ret)
+sys·makechan(uint32 elemsize, uint32 elemalg, uint32 hint, Hchan *ret)
{
ret = makechan(elemsize, elemalg, hint);
FLUSH(&ret);
diff --git a/src/pkg/runtime/hashmap.c b/src/pkg/runtime/hashmap.c
index 91be38443a..8c642d9d4d 100644
--- a/src/pkg/runtime/hashmap.c
+++ b/src/pkg/runtime/hashmap.c
@@ -664,7 +664,7 @@ donothing(uint32 s, void *a, void *b)
static int32 debug = 0;
-// newmap(keysize uint32, valsize uint32,
+// makemap(keysize uint32, valsize uint32,
// keyalg uint32, valalg uint32,
// hint uint32) (hmap *map[any]any);
Hmap*
@@ -675,12 +675,12 @@ makemap(uint32 keysize, uint32 valsize,
if(keyalg >= nelem(algarray) || algarray[keyalg].hash == nohash) {
printf("map(keyalg=%d)\n", keyalg);
- throw("sys·newmap: unsupported map key type");
+ throw("sys·makemap: unsupported map key type");
}
if(valalg >= nelem(algarray)) {
printf("map(valalg=%d)\n", valalg);
- throw("sys·newmap: unsupported map value type");
+ throw("sys·makemap: unsupported map value type");
}
h = mal(sizeof(*h));
@@ -720,18 +720,18 @@ makemap(uint32 keysize, uint32 valsize,
h->po2 = rnd(h->vo2+valsize, 1);
if(debug) {
- printf("newmap: map=%p; keysize=%d; valsize=%d; keyalg=%d; valalg=%d; offsets=%d,%d; %d,%d,%d; %d,%d,%d\n",
+ printf("makemap: map=%p; keysize=%d; valsize=%d; keyalg=%d; valalg=%d; offsets=%d,%d; %d,%d,%d; %d,%d,%d\n",
h, keysize, valsize, keyalg, valalg, h->ko0, h->vo0, h->ko1, h->vo1, h->po1, h->ko2, h->vo2, h->po2);
}
return h;
}
-// newmap(keysize uint32, valsize uint32,
+// makemap(keysize uint32, valsize uint32,
// keyalg uint32, valalg uint32,
// hint uint32) (hmap *map[any]any);
void
-sys·newmap(uint32 keysize, uint32 valsize,
+sys·makemap(uint32 keysize, uint32 valsize,
uint32 keyalg, uint32 valalg, uint32 hint,
Hmap *ret)
{
diff --git a/src/pkg/runtime/iface.c b/src/pkg/runtime/iface.c
index 63093ad881..6bd2f93ff2 100644
--- a/src/pkg/runtime/iface.c
+++ b/src/pkg/runtime/iface.c
@@ -45,7 +45,7 @@ itab(InterfaceType *inter, Type *type, int32 canfail)
Itab *m;
UncommonType *x;
- if(inter->mhdr.nel == 0)
+ if(inter->mhdr.len == 0)
throw("internal error - misuse of itab");
// easy case
@@ -90,7 +90,7 @@ itab(InterfaceType *inter, Type *type, int32 canfail)
}
}
- ni = inter->mhdr.nel;
+ ni = inter->mhdr.len;
m = malloc(sizeof(*m) + ni*sizeof m->fun[0]);
m->inter = inter;
m->type = type;
@@ -100,9 +100,9 @@ search:
// so can iterate over both in lock step;
// the loop is O(ni+nt) not O(ni*nt).
i = inter->m;
- ei = i + inter->mhdr.nel;
+ ei = i + inter->mhdr.len;
t = x->m;
- et = t + x->mhdr.nel;
+ et = t + x->mhdr.len;
for(; i < ei; i++) {
ihash = i->hash;
iname = i->name;
diff --git a/src/pkg/runtime/reflect.cgo b/src/pkg/runtime/reflect.cgo
index af74662db3..016b9e9ec0 100644
--- a/src/pkg/runtime/reflect.cgo
+++ b/src/pkg/runtime/reflect.cgo
@@ -87,7 +87,7 @@ func setiface(typ *byte, x *byte, ret *byte) {
InterfaceType *t;
t = (InterfaceType*)gettype(typ);
- if(t->mhdr.nel == 0) {
+ if(t->mhdr.len == 0) {
// already an empty interface
*(Eface*)ret = *(Eface*)x;
return;
diff --git a/src/pkg/runtime/runtime.c b/src/pkg/runtime/runtime.c
index c5ba3e6a5e..50a94ec921 100644
--- a/src/pkg/runtime/runtime.c
+++ b/src/pkg/runtime/runtime.c
@@ -142,8 +142,8 @@ rnd(uint32 n, uint32 m)
static int32 argc;
static uint8** argv;
-Array os·Args;
-Array os·Envs;
+Slice os·Args;
+Slice os·Envs;
void
args(int32 c, uint8 **v)
@@ -168,13 +168,13 @@ goargs(void)
for(i=0; i<argc; i++)
gargv[i] = gostring(argv[i]);
os·Args.array = (byte*)gargv;
- os·Args.nel = argc;
+ os·Args.len = argc;
os·Args.cap = argc;
for(i=0; i<envc; i++)
genvv[i] = gostring(argv[argc+1+i]);
os·Envs.array = (byte*)genvv;
- os·Envs.nel = envc;
+ os·Envs.len = envc;
os·Envs.cap = envc;
}
@@ -189,7 +189,7 @@ getenv(int8 *s)
bs = (byte*)s;
len = findnull(bs);
envv = (String*)os·Envs.array;
- envc = os·Envs.nel;
+ envc = os·Envs.len;
for(i=0; i<envc; i++){
if(envv[i].len <= len)
continue;
diff --git a/src/pkg/runtime/runtime.h b/src/pkg/runtime/runtime.h
index 48c98f2181..c346c692f6 100644
--- a/src/pkg/runtime/runtime.h
+++ b/src/pkg/runtime/runtime.h
@@ -42,7 +42,6 @@ typedef uint32 uintptr;
typedef uint8 bool;
typedef uint8 byte;
typedef struct Alg Alg;
-typedef struct Array Array;
typedef struct Func Func;
typedef struct G G;
typedef struct Gobuf Gobuf;
@@ -50,6 +49,7 @@ typedef struct Lock Lock;
typedef struct M M;
typedef struct Mem Mem;
typedef union Note Note;
+typedef struct Slice Slice;
typedef struct Stktop Stktop;
typedef struct String String;
typedef struct Usema Usema;
@@ -140,10 +140,10 @@ struct Eface
void* data;
};
-struct Array
+struct Slice
{ // must not move anything
byte* array; // actual data
- uint32 nel; // number of elements
+ uint32 len; // number of elements
uint32 cap; // allocated number of elements
};
struct Gobuf
@@ -252,7 +252,7 @@ struct Func
String src; // src file name
uint64 entry; // entry pc
int64 frame; // stack frame size
- Array pcln; // pc/ln tab for this func
+ Slice pcln; // pc/ln tab for this func
int64 pc0; // starting pc, ln for table
int32 ln0;
int32 args; // number of 32-bit in/out args
@@ -426,7 +426,7 @@ void notewakeup(Note*);
#define sys_memclr sys·memclr
#define sys_getcallerpc sys·getcallerpc
#define sys_mmap sys·mmap
-#define sys_printarray sys·printarray
+#define sys_printslice sys·printslice
#define sys_printbool sys·printbool
#define sys_printfloat sys·printfloat
#define sys_printhex sys·printhex
@@ -461,7 +461,7 @@ void sys_printpc(void*);
void sys_printpointer(void*);
void sys_printuint(uint64);
void sys_printhex(uint64);
-void sys_printarray(Array);
+void sys_printslice(Slice);
/*
* wrapped for go users
diff --git a/src/pkg/runtime/array.c b/src/pkg/runtime/slice.c
index bbd57b03e1..d7a5a062f1 100644
--- a/src/pkg/runtime/array.c
+++ b/src/pkg/runtime/slice.c
@@ -6,9 +6,9 @@
static int32 debug = 0;
-// newarray(nel int, cap int, width int) (ary []any);
+// makeslice(nel int, cap int, width int) (ary []any);
void
-sys·newarray(uint32 nel, uint32 cap, uint32 width, Array ret)
+sys·makeslice(uint32 nel, uint32 cap, uint32 width, Slice ret)
{
uint64 size;
@@ -16,21 +16,21 @@ sys·newarray(uint32 nel, uint32 cap, uint32 width, Array ret)
cap = nel;
size = cap*width;
- ret.nel = nel;
+ ret.len = nel;
ret.cap = cap;
ret.array = mal(size);
FLUSH(&ret);
if(debug) {
- prints("newarray: nel=");
+ prints("makeslice: nel=");
sys·printint(nel);
prints("; cap=");
sys·printint(cap);
prints("; width=");
sys·printint(width);
prints("; ret=");
- sys·printarray(ret);
+ sys·printslice(ret);
prints("\n");
}
}
@@ -48,15 +48,15 @@ throwslice(uint32 lb, uint32 hb, uint32 n)
throw("array slice");
}
-// arraysliced(old []any, lb int, hb int, width int) (ary []any);
+// sliceslice(old []any, lb int, hb int, width int) (ary []any);
void
-sys·arraysliced(Array old, uint32 lb, uint32 hb, uint32 width, Array ret)
+sys·sliceslice(Slice old, uint32 lb, uint32 hb, uint32 width, Slice ret)
{
if(hb > old.cap || lb > hb) {
if(debug) {
- prints("sys·arraysliced: old=");
- sys·printarray(old);
+ prints("sys·sliceslice: old=");
+ sys·printslice(old);
prints("; lb=");
sys·printint(lb);
prints("; hb=");
@@ -66,7 +66,7 @@ sys·arraysliced(Array old, uint32 lb, uint32 hb, uint32 width, Array ret)
prints("\n");
prints("oldarray: nel=");
- sys·printint(old.nel);
+ sys·printint(old.len);
prints("; cap=");
sys·printint(old.cap);
prints("\n");
@@ -75,15 +75,15 @@ sys·arraysliced(Array old, uint32 lb, uint32 hb, uint32 width, Array ret)
}
// new array is inside old array
- ret.nel = hb-lb;
+ ret.len = hb-lb;
ret.cap = old.cap - lb;
ret.array = old.array + lb*width;
FLUSH(&ret);
if(debug) {
- prints("sys·arraysliced: old=");
- sys·printarray(old);
+ prints("sys·sliceslice: old=");
+ sys·printslice(old);
prints("; lb=");
sys·printint(lb);
prints("; hb=");
@@ -91,19 +91,19 @@ sys·arraysliced(Array old, uint32 lb, uint32 hb, uint32 width, Array ret)
prints("; width=");
sys·printint(width);
prints("; ret=");
- sys·printarray(ret);
+ sys·printslice(ret);
prints("\n");
}
}
-// arrayslices(old *any, nel int, lb int, hb int, width int) (ary []any);
+// slicearray(old *any, nel int, lb int, hb int, width int) (ary []any);
void
-sys·arrayslices(byte* old, uint32 nel, uint32 lb, uint32 hb, uint32 width, Array ret)
+sys·slicearray(byte* old, uint32 nel, uint32 lb, uint32 hb, uint32 width, Slice ret)
{
if(hb > nel || lb > hb) {
if(debug) {
- prints("sys·arrayslices: old=");
+ prints("sys·slicearray: old=");
sys·printpointer(old);
prints("; nel=");
sys·printint(nel);
@@ -119,14 +119,14 @@ sys·arrayslices(byte* old, uint32 nel, uint32 lb, uint32 hb, uint32 width, Arra
}
// new array is inside old array
- ret.nel = hb-lb;
+ ret.len = hb-lb;
ret.cap = nel-lb;
ret.array = old + lb*width;
FLUSH(&ret);
if(debug) {
- prints("sys·arrayslices: old=");
+ prints("sys·slicearray: old=");
sys·printpointer(old);
prints("; nel=");
sys·printint(nel);
@@ -137,37 +137,37 @@ sys·arrayslices(byte* old, uint32 nel, uint32 lb, uint32 hb, uint32 width, Arra
prints("; width=");
sys·printint(width);
prints("; ret=");
- sys·printarray(ret);
+ sys·printslice(ret);
prints("\n");
}
}
-// arrays2d(old *any, nel int) (ary []any)
+// arraytoslice(old *any, nel int) (ary []any)
void
-sys·arrays2d(byte* old, uint32 nel, Array ret)
+sys·arraytoslice(byte* old, uint32 nel, Slice ret)
{
// new dope to old array
- ret.nel = nel;
+ ret.len = nel;
ret.cap = nel;
ret.array = old;
FLUSH(&ret);
if(debug) {
- prints("sys·arrays2d: old=");
+ prints("sys·slicearrayp: old=");
sys·printpointer(old);
prints("; ret=");
- sys·printarray(ret);
+ sys·printslice(ret);
prints("\n");
}
}
void
-sys·printarray(Array a)
+sys·printslice(Slice a)
{
prints("[");
- sys·printint(a.nel);
+ sys·printint(a.len);
prints("/");
sys·printint(a.cap);
prints("]");
diff --git a/src/pkg/runtime/string.cgo b/src/pkg/runtime/string.cgo
index c91a7507e6..3134cbbfe6 100644
--- a/src/pkg/runtime/string.cgo
+++ b/src/pkg/runtime/string.cgo
@@ -157,26 +157,26 @@ func intstring(v int64) (s String) {
s.len = runetochar(s.str, v);
}
-func arraystring(b Array) (s String) {
- s = gostringsize(b.nel);
+func slicebytetostring(b Slice) (s String) {
+ s = gostringsize(b.len);
mcpy(s.str, b.array, s.len);
}
-func arraystringi(b Array) (s String) {
+func sliceinttostring(b Slice) (s String) {
int32 siz1, siz2, i;
int32 *a;
byte dum[8];
a = (int32*)b.array;
siz1 = 0;
- for(i=0; i<b.nel; i++) {
+ for(i=0; i<b.len; i++) {
siz1 += runetochar(dum, a[i]);
}
s = gostringsize(siz1+4);
siz2 = 0;
- for(i=0; i<b.nel; i++) {
+ for(i=0; i<b.len; i++) {
// check for race
if(siz2 >= siz1)
break;
diff --git a/src/pkg/runtime/symtab.c b/src/pkg/runtime/symtab.c
index a03c165af8..97501623d3 100644
--- a/src/pkg/runtime/symtab.c
+++ b/src/pkg/runtime/symtab.c
@@ -27,23 +27,23 @@
// Return a pointer to a byte array containing the symbol table segment.
void
-sys·symdat(Array *symtab, Array *pclntab)
+sys·symdat(Slice *symtab, Slice *pclntab)
{
- Array *a;
+ Slice *a;
int32 *v;
v = SYMCOUNTS;
a = mal(sizeof *a);
- a->nel = v[0];
- a->cap = a->nel;
+ a->len = v[0];
+ a->cap = a->len;
a->array = SYMDATA;
symtab = a;
FLUSH(&symtab);
a = mal(sizeof *a);
- a->nel = v[1];
- a->cap = a->nel;
+ a->len = v[1];
+ a->cap = a->len;
a->array = SYMDATA + v[0];
pclntab = a;
FLUSH(&pclntab);
@@ -274,8 +274,8 @@ splitpcln(void)
line = 0;
for(; p < ep; p++) {
if(f < ef && pc > (f+1)->entry) {
- f->pcln.nel = p - f->pcln.array;
- f->pcln.cap = f->pcln.nel;
+ f->pcln.len = p - f->pcln.array;
+ f->pcln.cap = f->pcln.len;
f++;
f->pcln.array = p;
f->pc0 = pc;
@@ -295,8 +295,8 @@ splitpcln(void)
pc += PcQuant;
}
if(f < ef) {
- f->pcln.nel = p - f->pcln.array;
- f->pcln.cap = f->pcln.nel;
+ f->pcln.len = p - f->pcln.array;
+ f->pcln.cap = f->pcln.len;
}
}
@@ -311,7 +311,7 @@ funcline(Func *f, uint64 targetpc)
int32 line;
p = f->pcln.array;
- ep = p + f->pcln.nel;
+ ep = p + f->pcln.len;
pc = f->pc0;
line = f->ln0;
for(; p < ep && pc <= targetpc; p++) {
diff --git a/src/pkg/runtime/type.h b/src/pkg/runtime/type.h
index 10d0068eac..86e31ba2ae 100644
--- a/src/pkg/runtime/type.h
+++ b/src/pkg/runtime/type.h
@@ -39,7 +39,7 @@ struct UncommonType
{
String *name;
String *pkgPath;
- Array mhdr;
+ Slice mhdr;
Method m[];
};
@@ -62,7 +62,7 @@ struct IMethod
struct InterfaceType
{
Type;
- Array mhdr;
+ Slice mhdr;
IMethod m[];
};