2008-08-27 18:28:30 -06:00
|
|
|
// Copyright 2009 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.
|
|
|
|
|
|
|
|
#include "runtime.h"
|
2011-12-16 13:33:58 -07:00
|
|
|
#include "arch_GOARCH.h"
|
2009-12-04 22:44:05 -07:00
|
|
|
#include "type.h"
|
|
|
|
#include "malloc.h"
|
2008-08-27 18:28:30 -06:00
|
|
|
|
|
|
|
static int32 debug = 0;
|
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
static void makeslice1(SliceType*, int32, int32, Slice*);
|
2011-05-11 08:35:11 -06:00
|
|
|
static void growslice1(SliceType*, Slice, int32, Slice *);
|
2011-12-05 07:40:22 -07:00
|
|
|
void runtime·copy(Slice to, Slice fm, uintptr width, int32 ret);
|
2010-10-27 18:56:32 -06:00
|
|
|
|
2009-12-07 16:51:58 -07:00
|
|
|
// see also unsafe·NewArray
|
2010-05-01 14:15:42 -06:00
|
|
|
// makeslice(typ *Type, len, cap int64) (ary []any);
|
2008-08-27 18:28:30 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·makeslice(SliceType *t, int64 len, int64 cap, Slice ret)
|
2008-08-27 18:28:30 -06:00
|
|
|
{
|
2010-05-01 14:15:42 -06:00
|
|
|
if(len < 0 || (int32)len != len)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·panicstring("makeslice: len out of range");
|
2011-07-27 14:47:45 -06:00
|
|
|
if(cap < len || (int32)cap != cap || t->elem->size > 0 && cap > ((uintptr)-1) / t->elem->size)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·panicstring("makeslice: cap out of range");
|
2008-08-27 18:28:30 -06:00
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
makeslice1(t, len, cap, &ret);
|
2010-10-27 18:56:32 -06:00
|
|
|
|
|
|
|
if(debug) {
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·printf("makeslice(%S, %D, %D); ret=",
|
2010-10-27 18:56:32 -06:00
|
|
|
*t->string, len, cap);
|
2011-10-12 07:59:23 -06:00
|
|
|
runtime·printslice(ret);
|
2010-10-27 18:56:32 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-15 10:05:25 -07:00
|
|
|
// Dummy word to use as base pointer for make([]T, 0).
|
|
|
|
// Since you cannot take the address of such a slice,
|
|
|
|
// you can't tell that they all have the same base pointer.
|
|
|
|
static uintptr zerobase;
|
|
|
|
|
2010-10-27 18:56:32 -06:00
|
|
|
static void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
makeslice1(SliceType *t, int32 len, int32 cap, Slice *ret)
|
2011-10-12 07:59:23 -06:00
|
|
|
{
|
2010-10-27 18:56:32 -06:00
|
|
|
uintptr size;
|
|
|
|
|
2009-12-04 22:44:05 -07:00
|
|
|
size = cap*t->elem->size;
|
2008-08-27 18:28:30 -06:00
|
|
|
|
2010-10-27 18:56:32 -06:00
|
|
|
ret->len = len;
|
|
|
|
ret->cap = cap;
|
2009-12-04 22:44:05 -07:00
|
|
|
|
2011-11-15 10:05:25 -07:00
|
|
|
if(cap == 0)
|
|
|
|
ret->array = (byte*)&zerobase;
|
|
|
|
else if((t->elem->kind&KindNoPointers))
|
2011-02-02 21:03:47 -07:00
|
|
|
ret->array = runtime·mallocgc(size, FlagNoPointers, 1, 1);
|
2009-12-04 22:44:05 -07:00
|
|
|
else
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
ret->array = runtime·mal(size);
|
2010-10-27 18:56:32 -06:00
|
|
|
}
|
2008-08-27 18:28:30 -06:00
|
|
|
|
2010-10-27 18:56:32 -06:00
|
|
|
// appendslice(type *Type, x, y, []T) []T
|
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·appendslice(SliceType *t, Slice x, Slice y, Slice ret)
|
2010-10-27 18:56:32 -06:00
|
|
|
{
|
2011-10-12 07:59:23 -06:00
|
|
|
int32 m;
|
|
|
|
uintptr w;
|
|
|
|
|
|
|
|
m = x.len+y.len;
|
|
|
|
|
|
|
|
if(m < x.len)
|
|
|
|
runtime·throw("append: slice overflow");
|
|
|
|
|
|
|
|
if(m > x.cap)
|
|
|
|
growslice1(t, x, m, &ret);
|
|
|
|
else
|
|
|
|
ret = x;
|
|
|
|
|
|
|
|
w = t->elem->size;
|
|
|
|
runtime·memmove(ret.array + ret.len*w, y.array, y.len*w);
|
|
|
|
ret.len += y.len;
|
|
|
|
FLUSH(&ret);
|
2010-10-27 18:56:32 -06:00
|
|
|
}
|
|
|
|
|
2011-10-12 07:59:23 -06:00
|
|
|
|
|
|
|
// appendstr([]byte, string) []byte
|
|
|
|
void
|
|
|
|
runtime·appendstr(SliceType *t, Slice x, String y, Slice ret)
|
2010-10-27 18:56:32 -06:00
|
|
|
{
|
|
|
|
int32 m;
|
|
|
|
|
2011-05-11 08:35:11 -06:00
|
|
|
m = x.len+y.len;
|
|
|
|
|
|
|
|
if(m < x.len)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·throw("append: slice overflow");
|
2010-10-27 18:56:32 -06:00
|
|
|
|
2011-05-11 08:35:11 -06:00
|
|
|
if(m > x.cap)
|
2011-10-12 07:59:23 -06:00
|
|
|
growslice1(t, x, m, &ret);
|
2011-05-11 08:35:11 -06:00
|
|
|
else
|
2011-10-12 07:59:23 -06:00
|
|
|
ret = x;
|
2011-05-11 08:35:11 -06:00
|
|
|
|
2011-10-12 07:59:23 -06:00
|
|
|
runtime·memmove(ret.array + ret.len, y.str, y.len);
|
|
|
|
ret.len += y.len;
|
|
|
|
FLUSH(&ret);
|
2011-05-11 08:35:11 -06:00
|
|
|
}
|
|
|
|
|
2011-10-12 07:59:23 -06:00
|
|
|
|
2011-05-11 08:35:11 -06:00
|
|
|
// growslice(type *Type, x, []T, n int64) []T
|
|
|
|
void
|
|
|
|
runtime·growslice(SliceType *t, Slice old, int64 n, Slice ret)
|
|
|
|
{
|
|
|
|
int64 cap;
|
|
|
|
|
|
|
|
if(n < 1)
|
|
|
|
runtime·panicstring("growslice: invalid n");
|
|
|
|
|
|
|
|
cap = old.cap + n;
|
|
|
|
|
|
|
|
if((int32)cap != cap || cap > ((uintptr)-1) / t->elem->size)
|
|
|
|
runtime·panicstring("growslice: cap out of range");
|
|
|
|
|
|
|
|
growslice1(t, old, cap, &ret);
|
|
|
|
|
|
|
|
FLUSH(&ret);
|
|
|
|
|
|
|
|
if(debug) {
|
|
|
|
runtime·printf("growslice(%S,", *t->string);
|
2011-10-12 07:59:23 -06:00
|
|
|
runtime·printslice(old);
|
2011-05-11 08:35:11 -06:00
|
|
|
runtime·printf(", new cap=%D) =", cap);
|
2011-10-12 07:59:23 -06:00
|
|
|
runtime·printslice(ret);
|
2008-08-27 18:28:30 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-11 08:35:11 -06:00
|
|
|
static void
|
|
|
|
growslice1(SliceType *t, Slice x, int32 newcap, Slice *ret)
|
|
|
|
{
|
|
|
|
int32 m;
|
2010-10-27 18:56:32 -06:00
|
|
|
|
2011-05-11 08:35:11 -06:00
|
|
|
m = x.cap;
|
|
|
|
if(m == 0)
|
|
|
|
m = newcap;
|
|
|
|
else {
|
|
|
|
do {
|
|
|
|
if(x.len < 1024)
|
|
|
|
m += m;
|
|
|
|
else
|
|
|
|
m += m/4;
|
|
|
|
} while(m < newcap);
|
|
|
|
}
|
|
|
|
makeslice1(t, x.len, m, ret);
|
|
|
|
runtime·memmove(ret->array, x.array, ret->len * t->elem->size);
|
|
|
|
}
|
2010-10-27 18:56:32 -06:00
|
|
|
|
2010-08-03 01:26:02 -06:00
|
|
|
// sliceslice(old []any, lb uint64, hb uint64, width uint64) (ary []any);
|
2008-08-27 18:28:30 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·sliceslice(Slice old, uint64 lb, uint64 hb, uint64 width, Slice ret)
|
2008-08-27 18:28:30 -06:00
|
|
|
{
|
2008-12-18 21:06:28 -07:00
|
|
|
if(hb > old.cap || lb > hb) {
|
2008-08-27 18:28:30 -06:00
|
|
|
if(debug) {
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints("runtime.sliceslice: old=");
|
|
|
|
runtime·printslice(old);
|
|
|
|
runtime·prints("; lb=");
|
|
|
|
runtime·printint(lb);
|
|
|
|
runtime·prints("; hb=");
|
|
|
|
runtime·printint(hb);
|
|
|
|
runtime·prints("; width=");
|
|
|
|
runtime·printint(width);
|
|
|
|
runtime·prints("\n");
|
|
|
|
|
|
|
|
runtime·prints("oldarray: nel=");
|
|
|
|
runtime·printint(old.len);
|
|
|
|
runtime·prints("; cap=");
|
|
|
|
runtime·printint(old.cap);
|
|
|
|
runtime·prints("\n");
|
2008-08-27 18:28:30 -06:00
|
|
|
}
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·panicslice();
|
2008-08-27 18:28:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// new array is inside old array
|
2009-11-20 10:11:46 -07:00
|
|
|
ret.len = hb - lb;
|
2008-12-18 21:06:28 -07:00
|
|
|
ret.cap = old.cap - lb;
|
|
|
|
ret.array = old.array + lb*width;
|
2008-08-27 18:28:30 -06:00
|
|
|
|
2008-12-17 13:13:19 -07:00
|
|
|
FLUSH(&ret);
|
2008-08-27 18:28:30 -06:00
|
|
|
|
|
|
|
if(debug) {
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints("runtime.sliceslice: old=");
|
|
|
|
runtime·printslice(old);
|
|
|
|
runtime·prints("; lb=");
|
|
|
|
runtime·printint(lb);
|
|
|
|
runtime·prints("; hb=");
|
|
|
|
runtime·printint(hb);
|
|
|
|
runtime·prints("; width=");
|
|
|
|
runtime·printint(width);
|
|
|
|
runtime·prints("; ret=");
|
|
|
|
runtime·printslice(ret);
|
|
|
|
runtime·prints("\n");
|
2008-08-27 18:28:30 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-03 01:26:02 -06:00
|
|
|
// sliceslice1(old []any, lb uint64, width uint64) (ary []any);
|
2009-11-20 10:11:46 -07:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·sliceslice1(Slice old, uint64 lb, uint64 width, Slice ret)
|
2009-11-20 10:11:46 -07:00
|
|
|
{
|
|
|
|
if(lb > old.len) {
|
|
|
|
if(debug) {
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints("runtime.sliceslice: old=");
|
|
|
|
runtime·printslice(old);
|
|
|
|
runtime·prints("; lb=");
|
|
|
|
runtime·printint(lb);
|
|
|
|
runtime·prints("; width=");
|
|
|
|
runtime·printint(width);
|
|
|
|
runtime·prints("\n");
|
|
|
|
|
|
|
|
runtime·prints("oldarray: nel=");
|
|
|
|
runtime·printint(old.len);
|
|
|
|
runtime·prints("; cap=");
|
|
|
|
runtime·printint(old.cap);
|
|
|
|
runtime·prints("\n");
|
2009-11-20 10:11:46 -07:00
|
|
|
}
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·panicslice();
|
2009-11-20 10:11:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// new array is inside old array
|
|
|
|
ret.len = old.len - lb;
|
|
|
|
ret.cap = old.cap - lb;
|
|
|
|
ret.array = old.array + lb*width;
|
|
|
|
|
|
|
|
FLUSH(&ret);
|
|
|
|
|
|
|
|
if(debug) {
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints("runtime.sliceslice: old=");
|
|
|
|
runtime·printslice(old);
|
|
|
|
runtime·prints("; lb=");
|
|
|
|
runtime·printint(lb);
|
|
|
|
runtime·prints("; width=");
|
|
|
|
runtime·printint(width);
|
|
|
|
runtime·prints("; ret=");
|
|
|
|
runtime·printslice(ret);
|
|
|
|
runtime·prints("\n");
|
2009-11-20 10:11:46 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-03 01:26:02 -06:00
|
|
|
// slicearray(old *any, nel uint64, lb uint64, hb uint64, width uint64) (ary []any);
|
2008-08-27 18:28:30 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·slicearray(byte* old, uint64 nel, uint64 lb, uint64 hb, uint64 width, Slice ret)
|
2008-08-27 18:28:30 -06:00
|
|
|
{
|
2009-10-20 09:03:43 -06:00
|
|
|
if(nel > 0 && old == nil) {
|
|
|
|
// crash if old == nil.
|
|
|
|
// could give a better message
|
|
|
|
// but this is consistent with all the in-line checks
|
|
|
|
// that the compiler inserts for other uses.
|
|
|
|
*old = 0;
|
|
|
|
}
|
2008-08-27 18:28:30 -06:00
|
|
|
|
|
|
|
if(hb > nel || lb > hb) {
|
|
|
|
if(debug) {
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints("runtime.slicearray: old=");
|
|
|
|
runtime·printpointer(old);
|
|
|
|
runtime·prints("; nel=");
|
|
|
|
runtime·printint(nel);
|
|
|
|
runtime·prints("; lb=");
|
|
|
|
runtime·printint(lb);
|
|
|
|
runtime·prints("; hb=");
|
|
|
|
runtime·printint(hb);
|
|
|
|
runtime·prints("; width=");
|
|
|
|
runtime·printint(width);
|
|
|
|
runtime·prints("\n");
|
2008-08-27 18:28:30 -06:00
|
|
|
}
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·panicslice();
|
2008-08-27 18:28:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// new array is inside old array
|
2009-08-25 16:54:25 -06:00
|
|
|
ret.len = hb-lb;
|
2008-12-18 21:06:28 -07:00
|
|
|
ret.cap = nel-lb;
|
|
|
|
ret.array = old + lb*width;
|
2008-08-27 18:28:30 -06:00
|
|
|
|
2008-12-17 13:13:19 -07:00
|
|
|
FLUSH(&ret);
|
2008-08-27 18:28:30 -06:00
|
|
|
|
|
|
|
if(debug) {
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints("runtime.slicearray: old=");
|
|
|
|
runtime·printpointer(old);
|
|
|
|
runtime·prints("; nel=");
|
|
|
|
runtime·printint(nel);
|
|
|
|
runtime·prints("; lb=");
|
|
|
|
runtime·printint(lb);
|
|
|
|
runtime·prints("; hb=");
|
|
|
|
runtime·printint(hb);
|
|
|
|
runtime·prints("; width=");
|
|
|
|
runtime·printint(width);
|
|
|
|
runtime·prints("; ret=");
|
|
|
|
runtime·printslice(ret);
|
|
|
|
runtime·prints("\n");
|
2008-08-27 18:28:30 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-05 07:40:22 -07:00
|
|
|
// copy(to any, fr any, wid uint32) int
|
2009-11-17 21:41:44 -07:00
|
|
|
void
|
2011-12-05 07:40:22 -07:00
|
|
|
runtime·copy(Slice to, Slice fm, uintptr width, int32 ret)
|
2009-11-17 21:41:44 -07:00
|
|
|
{
|
2010-05-03 18:47:40 -06:00
|
|
|
if(fm.len == 0 || to.len == 0 || width == 0) {
|
2009-11-17 21:41:44 -07:00
|
|
|
ret = 0;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = fm.len;
|
2009-11-17 21:44:35 -07:00
|
|
|
if(to.len < ret)
|
2009-11-17 21:41:44 -07:00
|
|
|
ret = to.len;
|
|
|
|
|
2009-12-07 12:28:02 -07:00
|
|
|
if(ret == 1 && width == 1) { // common case worth about 2x to do here
|
|
|
|
*to.array = *fm.array; // known to be a byte pointer
|
|
|
|
} else {
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·memmove(to.array, fm.array, ret*width);
|
2009-12-07 12:28:02 -07:00
|
|
|
}
|
2009-11-17 21:41:44 -07:00
|
|
|
|
|
|
|
out:
|
|
|
|
FLUSH(&ret);
|
|
|
|
|
|
|
|
if(debug) {
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints("main·copy: to=");
|
|
|
|
runtime·printslice(to);
|
|
|
|
runtime·prints("; fm=");
|
|
|
|
runtime·printslice(fm);
|
|
|
|
runtime·prints("; width=");
|
|
|
|
runtime·printint(width);
|
|
|
|
runtime·prints("; ret=");
|
|
|
|
runtime·printint(ret);
|
|
|
|
runtime·prints("\n");
|
2009-11-17 21:41:44 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-26 09:36:07 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·slicestringcopy(Slice to, String fm, int32 ret)
|
2010-10-26 09:36:07 -06:00
|
|
|
{
|
|
|
|
if(fm.len == 0 || to.len == 0) {
|
|
|
|
ret = 0;
|
|
|
|
goto out;
|
|
|
|
}
|
2011-10-12 07:59:23 -06:00
|
|
|
|
2010-10-26 09:36:07 -06:00
|
|
|
ret = fm.len;
|
|
|
|
if(to.len < ret)
|
|
|
|
ret = to.len;
|
2011-10-12 07:59:23 -06:00
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·memmove(to.array, fm.str, ret);
|
2010-10-26 09:36:07 -06:00
|
|
|
|
|
|
|
out:
|
|
|
|
FLUSH(&ret);
|
|
|
|
}
|
|
|
|
|
2008-12-17 13:13:19 -07:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·printslice(Slice a)
|
2008-12-17 13:13:19 -07:00
|
|
|
{
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints("[");
|
|
|
|
runtime·printint(a.len);
|
|
|
|
runtime·prints("/");
|
|
|
|
runtime·printint(a.cap);
|
|
|
|
runtime·prints("]");
|
|
|
|
runtime·printpointer(a.array);
|
2008-12-17 13:13:19 -07:00
|
|
|
}
|