aboutsummaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2012-02-08 06:18:41 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2012-02-08 06:18:41 +0000
commit047cff816d1457fa3894b7cd2a61752f669704c7 (patch)
tree0079e628bdcefa4ba284ae32a63173c4c470d869 /libgo
parent7f57843fbebc7b50cfad7cc5bd3459a2d1077035 (diff)
downloadgcc-047cff816d1457fa3894b7cd2a61752f669704c7.zip
gcc-047cff816d1457fa3894b7cd2a61752f669704c7.tar.gz
gcc-047cff816d1457fa3894b7cd2a61752f669704c7.tar.bz2
compiler, runtime: Check make int64 args for overflow.
From-SVN: r183994
Diffstat (limited to 'libgo')
-rw-r--r--libgo/runtime/chan.c6
-rw-r--r--libgo/runtime/go-make-slice.c24
-rw-r--r--libgo/runtime/go-new-map.c14
3 files changed, 44 insertions, 0 deletions
diff --git a/libgo/runtime/chan.c b/libgo/runtime/chan.c
index a246992..4fc2d60 100644
--- a/libgo/runtime/chan.c
+++ b/libgo/runtime/chan.c
@@ -130,6 +130,12 @@ __go_new_channel(ChanType *t, uintptr hint)
return runtime_makechan_c(t, hint);
}
+Hchan*
+__go_new_channel_big(ChanType *t, uint64 hint)
+{
+ return runtime_makechan_c(t, hint);
+}
+
/*
* generic single channel send/recv
* if the bool pointer is nil,
diff --git a/libgo/runtime/go-make-slice.c b/libgo/runtime/go-make-slice.c
index 765e7c0..42b412c 100644
--- a/libgo/runtime/go-make-slice.c
+++ b/libgo/runtime/go-make-slice.c
@@ -57,3 +57,27 @@ __go_make_slice1 (const struct __go_type_descriptor *td, uintptr_t len)
{
return __go_make_slice2 (td, len, len);
}
+
+struct __go_open_array
+__go_make_slice2_big (const struct __go_type_descriptor *td, uint64_t len,
+ uint64_t cap)
+{
+ uintptr_t slen;
+ uintptr_t scap;
+
+ slen = (uintptr_t) len;
+ if ((uint64_t) slen != len)
+ runtime_panicstring ("makeslice: len out of range");
+
+ scap = (uintptr_t) cap;
+ if ((uint64_t) scap != cap)
+ runtime_panicstring ("makeslice: cap out of range");
+
+ return __go_make_slice2 (td, slen, scap);
+}
+
+struct __go_open_array
+__go_make_slice1_big (const struct __go_type_descriptor *td, uint64_t len)
+{
+ return __go_make_slice2_big (td, len, len);
+}
diff --git a/libgo/runtime/go-new-map.c b/libgo/runtime/go-new-map.c
index 288e188..eef71dd 100644
--- a/libgo/runtime/go-new-map.c
+++ b/libgo/runtime/go-new-map.c
@@ -125,3 +125,17 @@ __go_new_map (const struct __go_map_descriptor *descriptor, uintptr_t entries)
__builtin_memset (ret->__buckets, 0, entries * sizeof (void *));
return ret;
}
+
+/* Allocate a new map when the argument to make is a large type. */
+
+struct __go_map *
+__go_new_map_big (const struct __go_map_descriptor *descriptor,
+ uint64_t entries)
+{
+ uintptr_t sentries;
+
+ sentries = (uintptr_t) entries;
+ if ((uint64_t) sentries != entries)
+ runtime_panicstring ("map size out of range");
+ return __go_new_map (descriptor, sentries);
+}