summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/slice.c
diff options
context:
space:
mode:
authorKen Thompson <ken@golang.org>2009-11-17 20:41:44 -0800
committerKen Thompson <ken@golang.org>2009-11-17 20:41:44 -0800
commit0d80123b63a92941a559e23bae9fcfbd0998fc22 (patch)
treedfdc104b3b9cdcd9ff53faf54ca5e1042b085e3e /src/pkg/runtime/slice.c
parent276d8a083f089962440cc0aa10c14df3691b94f9 (diff)
downloadgolang-0d80123b63a92941a559e23bae9fcfbd0998fc22.tar.gz
install copy predefined
did not test 386, but should work shouldnt matter if copy is not used R=rsc http://codereview.appspot.com/156055
Diffstat (limited to 'src/pkg/runtime/slice.c')
-rw-r--r--src/pkg/runtime/slice.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/pkg/runtime/slice.c b/src/pkg/runtime/slice.c
index 722802c00..00d9724fb 100644
--- a/src/pkg/runtime/slice.c
+++ b/src/pkg/runtime/slice.c
@@ -177,6 +177,39 @@ runtime·arraytoslice(byte* old, uint32 nel, Slice ret)
}
}
+// slicecopy(to any, fr any, wid uint32) int
+void
+runtime·slicecopy(Slice to, Slice fm, uintptr width, int32 ret)
+{
+ if(fm.array == nil || fm.len == 0 ||
+ to.array == nil || to.len == 0 ||
+ width == 0) {
+ ret = 0;
+ goto out;
+ }
+
+ ret = fm.len;
+ if(to.len > ret)
+ ret = to.len;
+
+ memmove(to.array, fm.array, ret*width);
+
+out:
+ FLUSH(&ret);
+
+ if(debug) {
+ prints("main·copy: to=");
+ runtime·printslice(to);
+ prints("; fm=");
+ runtime·printslice(fm);
+ prints("; width=");
+ runtime·printint(width);
+ prints("; ret=");
+ runtime·printint(ret);
+ prints("\n");
+ }
+}
+
void
runtime·printslice(Slice a)
{