s390.c: Rename cfun_set_fpr_bit to cfun_set_fpr_save and cfun_fpr_bit_p to cfun_fpr_s...
[gcc.git] / libgo / runtime / go-unsafe-new.c
1 /* go-unsafe-new.c -- unsafe.New function for Go.
2
3 Copyright 2009 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
6
7 #include "runtime.h"
8 #include "arch.h"
9 #include "malloc.h"
10 #include "go-type.h"
11 #include "interface.h"
12
13 /* Implement unsafe_New, called from the reflect package. */
14
15 void *unsafe_New (const struct __go_type_descriptor *)
16 __asm__ (GOSYM_PREFIX "reflect.unsafe_New");
17
18 /* The dynamic type of the argument will be a pointer to a type
19 descriptor. */
20
21 void *
22 unsafe_New (const struct __go_type_descriptor *descriptor)
23 {
24 uint32 flag;
25 void *ret;
26
27 flag = (descriptor->__code & GO_NO_POINTERS) != 0 ? FlagNoPointers : 0;
28 ret = runtime_mallocgc (descriptor->__size, flag, 1, 1);
29
30 if (UseSpanType && flag == 0)
31 runtime_settype (ret, (uintptr) descriptor | TypeInfo_SingleObject);
32
33 return ret;
34 }