Peter Collingbourne | 594c10d | 2014-11-27 00:12:26 +0000 | [diff] [blame] | 1 | /* go-new.c -- the generic go new() function. |
| 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 "go-alloc.h" |
| 8 | #include "runtime.h" |
| 9 | #include "arch.h" |
| 10 | #include "malloc.h" |
Andrew Wilkins | 6436a4a | 2016-03-15 05:36:43 +0000 | [diff] [blame] | 11 | #include "go-type.h" |
Peter Collingbourne | 594c10d | 2014-11-27 00:12:26 +0000 | [diff] [blame] | 12 | |
| 13 | void * |
| 14 | __go_new (const struct __go_type_descriptor *td, uintptr_t size) |
| 15 | { |
| 16 | return runtime_mallocgc (size, |
| 17 | (uintptr) td | TypeInfo_SingleObject, |
Andrew Wilkins | 6436a4a | 2016-03-15 05:36:43 +0000 | [diff] [blame] | 18 | td->__code & GO_NO_POINTERS ? FlagNoScan : 0); |
Peter Collingbourne | 594c10d | 2014-11-27 00:12:26 +0000 | [diff] [blame] | 19 | } |