diff options
author | Ian Lance Taylor <iant@google.com> | 2011-06-14 05:53:10 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-06-14 05:53:10 +0000 |
commit | 3b8dffe701e9a1f6641f3ff1f08899614ce38ae0 (patch) | |
tree | 075a60d271b289fa96fb47546b7be74d188590e1 /libgo/runtime | |
parent | 8365a060e613196d31719832af2a4cb2b9886a30 (diff) | |
download | gcc-3b8dffe701e9a1f6641f3ff1f08899614ce38ae0.zip gcc-3b8dffe701e9a1f6641f3ff1f08899614ce38ae0.tar.gz gcc-3b8dffe701e9a1f6641f3ff1f08899614ce38ae0.tar.bz2 |
Change builtin make to runtime call at lowering time.
Use kindNoPointers as 6g does.
* Make-lang.in (go/expressions.o): Depend on $(GO_RUNTIME_H).
From-SVN: r175008
Diffstat (limited to 'libgo/runtime')
-rw-r--r-- | libgo/runtime/go-new-channel.c | 13 | ||||
-rw-r--r-- | libgo/runtime/go-new-map.c | 4 | ||||
-rw-r--r-- | libgo/runtime/go-reflect-call.c | 2 | ||||
-rw-r--r-- | libgo/runtime/go-reflect-chan.c | 3 | ||||
-rw-r--r-- | libgo/runtime/go-reflect.c | 2 | ||||
-rw-r--r-- | libgo/runtime/go-type.h | 6 |
6 files changed, 21 insertions, 9 deletions
diff --git a/libgo/runtime/go-new-channel.c b/libgo/runtime/go-new-channel.c index e440e87..0c6f391 100644 --- a/libgo/runtime/go-new-channel.c +++ b/libgo/runtime/go-new-channel.c @@ -13,17 +13,26 @@ #include "channel.h" struct __go_channel* -__go_new_channel (const struct __go_type_descriptor *element_type, +__go_new_channel (const struct __go_type_descriptor *channel_type, uintptr_t entries) { + const struct __go_channel_type *ctd; + const struct __go_type_descriptor *element_type; uintptr_t element_size; + int ientries; struct __go_channel* ret; size_t alloc_size; int i; + __go_assert (channel_type->__code == GO_CHAN); + ctd = (const struct __go_channel_type *) channel_type; + element_type = ctd->__element_type; + element_size = element_type->__size; - if ((uintptr_t) (int) entries != entries + ientries = (int) entries; + if (ientries < 0 + || (uintptr_t) ientries != entries || entries > (uintptr_t) -1 / element_size) __go_panic_msg ("chan size out of range"); diff --git a/libgo/runtime/go-new-map.c b/libgo/runtime/go-new-map.c index 3a47129..05ac8a1 100644 --- a/libgo/runtime/go-new-map.c +++ b/libgo/runtime/go-new-map.c @@ -106,9 +106,11 @@ __go_map_next_prime (uintptr_t n) struct __go_map * __go_new_map (const struct __go_map_descriptor *descriptor, uintptr_t entries) { + int ientries; struct __go_map *ret; - if ((uintptr_t) (int) entries != entries) + ientries = (int) entries; + if (ientries < 0 || (uintptr_t) ientries != entries) __go_panic_msg ("map size out of range"); if (entries == 0) diff --git a/libgo/runtime/go-reflect-call.c b/libgo/runtime/go-reflect-call.c index a769142..27177e2 100644 --- a/libgo/runtime/go-reflect-call.c +++ b/libgo/runtime/go-reflect-call.c @@ -161,7 +161,7 @@ go_complex_to_ffi (ffi_type *float_type) static ffi_type * go_type_to_ffi (const struct __go_type_descriptor *descriptor) { - switch (descriptor->__code) + switch (descriptor->__code & GO_CODE_MASK) { case GO_BOOL: if (sizeof (_Bool) == 1) diff --git a/libgo/runtime/go-reflect-chan.c b/libgo/runtime/go-reflect-chan.c index d568024..61e3602 100644 --- a/libgo/runtime/go-reflect-chan.c +++ b/libgo/runtime/go-reflect-chan.c @@ -26,9 +26,6 @@ makechan (const struct __go_type_descriptor *typ, uint32_t size) struct __go_channel *channel; void *ret; - __go_assert (typ->__code == GO_CHAN); - typ = ((const struct __go_channel_type *) typ)->__element_type; - channel = __go_new_channel (typ, size); ret = __go_alloc (sizeof (void *)); diff --git a/libgo/runtime/go-reflect.c b/libgo/runtime/go-reflect.c index bf13a11..af7d5e8 100644 --- a/libgo/runtime/go-reflect.c +++ b/libgo/runtime/go-reflect.c @@ -57,7 +57,7 @@ extern const struct __go_type_descriptor ptr_struct_descriptor const struct __go_type_descriptor * get_descriptor (int code) { - switch (code) + switch (code & GO_CODE_MASK) { case GO_BOOL: return &ptr_bool_descriptor; diff --git a/libgo/runtime/go-type.h b/libgo/runtime/go-type.h index e048141..6e21939 100644 --- a/libgo/runtime/go-type.h +++ b/libgo/runtime/go-type.h @@ -53,13 +53,17 @@ #define GO_STRUCT 25 #define GO_UNSAFE_POINTER 26 +#define GO_NO_POINTERS (1 << 7) + +#define GO_CODE_MASK 0x7f + /* For each Go type the compiler constructs one of these structures. This is used for type reflectin, interfaces, maps, and reference counting. */ struct __go_type_descriptor { - /* The type code for this type, a value in enum __go_type_codes. + /* The type code for this type, one of the type kind values above. This is used by unsafe.Reflect and unsafe.Typeof to determine the type descriptor to return for this type itself. It is also used by reflect.toType when mapping to a reflect Type structure. */ |