diff options
author | Russ Cox <rsc@golang.org> | 2009-06-06 22:04:39 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2009-06-06 22:04:39 -0700 |
commit | 8257be5f9d4a4bdbb0ff096756a0e48401d620c8 (patch) | |
tree | 1195452c472b99bfd365ee1cc057e870178e63e0 /src/runtime/array.c | |
parent | af9643dcc1336bcb6e6ed0817e68a9c2db2c5613 (diff) | |
download | golang-8257be5f9d4a4bdbb0ff096756a0e48401d620c8.tar.gz |
move src/runtime -> src/lib/runtime;
only automatic g4 mv here.
R=r
OCL=30002
CL=30007
Diffstat (limited to 'src/runtime/array.c')
-rw-r--r-- | src/runtime/array.c | 175 |
1 files changed, 0 insertions, 175 deletions
diff --git a/src/runtime/array.c b/src/runtime/array.c deleted file mode 100644 index bbd57b03e..000000000 --- a/src/runtime/array.c +++ /dev/null @@ -1,175 +0,0 @@ -// 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" - -static int32 debug = 0; - -// newarray(nel int, cap int, width int) (ary []any); -void -sys·newarray(uint32 nel, uint32 cap, uint32 width, Array ret) -{ - uint64 size; - - if(cap < nel) - cap = nel; - size = cap*width; - - ret.nel = nel; - ret.cap = cap; - ret.array = mal(size); - - FLUSH(&ret); - - if(debug) { - prints("newarray: nel="); - sys·printint(nel); - prints("; cap="); - sys·printint(cap); - prints("; width="); - sys·printint(width); - prints("; ret="); - sys·printarray(ret); - prints("\n"); - } -} - -static void -throwslice(uint32 lb, uint32 hb, uint32 n) -{ - prints("slice["); - sys·printint(lb); - prints(":"); - sys·printint(hb); - prints("] of ["); - sys·printint(n); - prints("] array\n"); - throw("array slice"); -} - -// arraysliced(old []any, lb int, hb int, width int) (ary []any); -void -sys·arraysliced(Array old, uint32 lb, uint32 hb, uint32 width, Array ret) -{ - - if(hb > old.cap || lb > hb) { - if(debug) { - prints("sys·arraysliced: old="); - sys·printarray(old); - prints("; lb="); - sys·printint(lb); - prints("; hb="); - sys·printint(hb); - prints("; width="); - sys·printint(width); - prints("\n"); - - prints("oldarray: nel="); - sys·printint(old.nel); - prints("; cap="); - sys·printint(old.cap); - prints("\n"); - } - throwslice(lb, hb, old.cap); - } - - // new array is inside old array - ret.nel = 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("; lb="); - sys·printint(lb); - prints("; hb="); - sys·printint(hb); - prints("; width="); - sys·printint(width); - prints("; ret="); - sys·printarray(ret); - prints("\n"); - } -} - -// arrayslices(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) -{ - - if(hb > nel || lb > hb) { - if(debug) { - prints("sys·arrayslices: old="); - sys·printpointer(old); - prints("; nel="); - sys·printint(nel); - prints("; lb="); - sys·printint(lb); - prints("; hb="); - sys·printint(hb); - prints("; width="); - sys·printint(width); - prints("\n"); - } - throwslice(lb, hb, nel); - } - - // new array is inside old array - ret.nel = hb-lb; - ret.cap = nel-lb; - ret.array = old + lb*width; - - FLUSH(&ret); - - if(debug) { - prints("sys·arrayslices: old="); - sys·printpointer(old); - prints("; nel="); - sys·printint(nel); - prints("; lb="); - sys·printint(lb); - prints("; hb="); - sys·printint(hb); - prints("; width="); - sys·printint(width); - prints("; ret="); - sys·printarray(ret); - prints("\n"); - } -} - -// arrays2d(old *any, nel int) (ary []any) -void -sys·arrays2d(byte* old, uint32 nel, Array ret) -{ - - // new dope to old array - ret.nel = nel; - ret.cap = nel; - ret.array = old; - - FLUSH(&ret); - - if(debug) { - prints("sys·arrays2d: old="); - sys·printpointer(old); - prints("; ret="); - sys·printarray(ret); - prints("\n"); - } -} - -void -sys·printarray(Array a) -{ - prints("["); - sys·printint(a.nel); - prints("/"); - sys·printint(a.cap); - prints("]"); - sys·printpointer(a.array); -} |