aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime/go-unsafe-newarray.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-11-21 07:03:38 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-11-21 07:03:38 +0000
commitfabcaa8df3d6eb852b87821ef090d31d222870b7 (patch)
tree72455aea0286937aa08cc141e5efc800e4626577 /libgo/runtime/go-unsafe-newarray.c
parenta51fb17f48428e7cfc96a72a9f9f87901363bb6b (diff)
downloadgcc-fabcaa8df3d6eb852b87821ef090d31d222870b7.zip
gcc-fabcaa8df3d6eb852b87821ef090d31d222870b7.tar.gz
gcc-fabcaa8df3d6eb852b87821ef090d31d222870b7.tar.bz2
libgo: Update to current version of master library.
From-SVN: r193688
Diffstat (limited to 'libgo/runtime/go-unsafe-newarray.c')
-rw-r--r--libgo/runtime/go-unsafe-newarray.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/libgo/runtime/go-unsafe-newarray.c b/libgo/runtime/go-unsafe-newarray.c
index 67399ea..47dcd84 100644
--- a/libgo/runtime/go-unsafe-newarray.c
+++ b/libgo/runtime/go-unsafe-newarray.c
@@ -5,28 +5,37 @@
license that can be found in the LICENSE file. */
#include "runtime.h"
-#include "go-alloc.h"
+#include "arch.h"
+#include "malloc.h"
#include "go-type.h"
#include "interface.h"
/* Implement unsafe_NewArray, called from the reflect package. */
-void *unsafe_NewArray (struct __go_empty_interface type, int n)
+void *unsafe_NewArray (const struct __go_type_descriptor *, intgo)
asm ("reflect.unsafe_NewArray");
/* The dynamic type of the argument will be a pointer to a type
descriptor. */
void *
-unsafe_NewArray (struct __go_empty_interface type, int n)
+unsafe_NewArray (const struct __go_type_descriptor *descriptor, intgo n)
{
- const struct __go_type_descriptor *descriptor;
-
- if (((uintptr_t) type.__type_descriptor & reflectFlags) != 0)
- runtime_panicstring ("invalid interface value");
-
- /* FIXME: We should check __type_descriptor to verify that this is
- really a type descriptor. */
- descriptor = (const struct __go_type_descriptor *) type.__object;
- return __go_alloc (descriptor->__size * n);
+ uint64 size;
+ void *ret;
+
+ size = n * descriptor->__size;
+ if (size == 0)
+ ret = &runtime_zerobase;
+ else if ((descriptor->__code & GO_NO_POINTERS) != 0)
+ ret = runtime_mallocgc (size, FlagNoPointers, 1, 1);
+ else
+ {
+ ret = runtime_mallocgc (size, 0, 1, 1);
+
+ if (UseSpanType)
+ runtime_settype (ret, (uintptr) descriptor | TypeInfo_Array);
+ }
+
+ return ret;
}