Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / libgo / runtime / go-unsafe-new.c
blobe55d415becb36b1d66e7f03bee383a5a23372dcb
1 /* go-unsafe-new.c -- unsafe.New function for Go.
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. */
7 #include "go-alloc.h"
8 #include "go-type.h"
9 #include "interface.h"
11 /* Implement unsafe.New. */
13 void *New (struct __go_empty_interface type) asm ("libgo_unsafe.unsafe.New");
15 /* The dynamic type of the argument will be a pointer to a type
16 descriptor. */
18 void *
19 New (struct __go_empty_interface type)
21 const struct __go_type_descriptor *descriptor;
23 /* FIXME: We should check __type_descriptor to verify that this is
24 really a type descriptor. */
25 descriptor = (const struct __go_type_descriptor *) type.__object;
26 return __go_alloc (descriptor->__size);