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. */
10 #include "interface.h"
12 /* Implement unsafe.New. */
14 void *New (struct __go_empty_interface type
) asm ("libgo_unsafe.unsafe.New");
16 /* The dynamic type of the argument will be a pointer to a type
20 New (struct __go_empty_interface type
)
22 const struct __go_type_descriptor
*descriptor
;
24 if (((uintptr_t) type
.__type_descriptor
& reflectFlags
) != 0)
25 __go_panic_msg ("invalid interface value");
27 /* FIXME: We should check __type_descriptor to verify that this is
28 really a type descriptor. */
29 descriptor
= (const struct __go_type_descriptor
*) type
.__object
;
30 return __go_alloc (descriptor
->__size
);