summaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-04-13 21:00:59 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2011-04-13 21:00:59 +0000
commit9581e91dbb7fa66fee457ad404e908d3d4130ad6 (patch)
tree32a57ad9ca89c95394a45e92649f097c96b50924 /libgo
parent4c35e34cb7b64a3351bdf41eb63cffb51307fb18 (diff)
downloadgcc-9581e91dbb7fa66fee457ad404e908d3d4130ad6.tar.gz
Unify handling of runtime support functions.
This introduces the new approach, and rewrites the lowering code which uses runtime functions. The code which calls runtime functions at GENERIC conversion time is not yet rewritten. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@172396 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r--libgo/runtime/channel.h6
-rw-r--r--libgo/runtime/go-append.c10
-rw-r--r--libgo/runtime/go-byte-array-to-string.c2
-rw-r--r--libgo/runtime/go-chan-cap.c4
-rw-r--r--libgo/runtime/go-chan-len.c6
-rw-r--r--libgo/runtime/go-construct-map.c8
-rw-r--r--libgo/runtime/go-copy.c5
-rw-r--r--libgo/runtime/go-int-array-to-string.c8
-rw-r--r--libgo/runtime/go-map-len.c8
-rw-r--r--libgo/runtime/go-new-channel.c6
-rw-r--r--libgo/runtime/go-new-map.c4
-rw-r--r--libgo/runtime/go-new.c4
-rw-r--r--libgo/runtime/go-select.c68
-rw-r--r--libgo/runtime/go-trampoline.c2
-rw-r--r--libgo/runtime/map.h2
15 files changed, 75 insertions, 68 deletions
diff --git a/libgo/runtime/channel.h b/libgo/runtime/channel.h
index cd439bf4ccb..ac791746e17 100644
--- a/libgo/runtime/channel.h
+++ b/libgo/runtime/channel.h
@@ -79,7 +79,7 @@ struct __go_channel
acquired while this mutex is held. */
extern pthread_mutex_t __go_select_data_mutex;
-extern struct __go_channel *__go_new_channel (size_t, size_t);
+extern struct __go_channel *__go_new_channel (uintptr_t, uintptr_t);
extern _Bool __go_synch_with_select (struct __go_channel *, _Bool);
@@ -138,6 +138,6 @@ extern _Bool __go_builtin_closed (struct __go_channel *);
extern void __go_builtin_close (struct __go_channel *);
-extern size_t __go_chan_len (struct __go_channel *);
+extern int __go_chan_len (struct __go_channel *);
-extern size_t __go_chan_cap (struct __go_channel *);
+extern int __go_chan_cap (struct __go_channel *);
diff --git a/libgo/runtime/go-append.c b/libgo/runtime/go-append.c
index 91493b1b78d..e501f3066a9 100644
--- a/libgo/runtime/go-append.c
+++ b/libgo/runtime/go-append.c
@@ -19,18 +19,18 @@ __go_append (struct __go_open_array, void *, size_t, size_t)
__attribute__ ((no_split_stack));
struct __go_open_array
-__go_append (struct __go_open_array a, void *bvalues, size_t bcount,
- size_t element_size)
+__go_append (struct __go_open_array a, void *bvalues, uintptr_t bcount,
+ uintptr_t element_size)
{
- size_t ucount;
+ uintptr_t ucount;
int count;
if (bvalues == NULL || bcount == 0)
return a;
- ucount = (size_t) a.__count + bcount;
+ ucount = (uintptr_t) a.__count + bcount;
count = (int) ucount;
- if ((size_t) count != ucount || count <= a.__count)
+ if ((uintptr_t) count != ucount || count <= a.__count)
__go_panic_msg ("append: slice overflow");
if (count > a.__capacity)
diff --git a/libgo/runtime/go-byte-array-to-string.c b/libgo/runtime/go-byte-array-to-string.c
index 1b9ac2d7964..ab9e28388bc 100644
--- a/libgo/runtime/go-byte-array-to-string.c
+++ b/libgo/runtime/go-byte-array-to-string.c
@@ -9,7 +9,7 @@
#include "malloc.h"
struct __go_string
-__go_byte_array_to_string (const void* p, size_t len)
+__go_byte_array_to_string (const void* p, int len)
{
const unsigned char *bytes;
unsigned char *retdata;
diff --git a/libgo/runtime/go-chan-cap.c b/libgo/runtime/go-chan-cap.c
index df603bf102f..2c7958dd9fc 100644
--- a/libgo/runtime/go-chan-cap.c
+++ b/libgo/runtime/go-chan-cap.c
@@ -13,11 +13,11 @@
buffer. This could be done inline but I'm doing it as a function
for now to make it easy to change the channel structure. */
-size_t
+int
__go_chan_cap (struct __go_channel *channel)
{
int i;
- size_t ret;
+ int ret;
if (channel == NULL)
return 0;
diff --git a/libgo/runtime/go-chan-len.c b/libgo/runtime/go-chan-len.c
index 5aebae141bc..b3ced98aa05 100644
--- a/libgo/runtime/go-chan-len.c
+++ b/libgo/runtime/go-chan-len.c
@@ -14,11 +14,11 @@
as a function for now to make it easy to change the channel
structure. */
-size_t
+int
__go_chan_len (struct __go_channel *channel)
{
int i;
- size_t ret;
+ int ret;
if (channel == NULL)
return 0;
@@ -35,7 +35,7 @@ __go_chan_len (struct __go_channel *channel)
% channel->num_entries);
i = pthread_mutex_unlock (&channel->lock);
- __go_assert (i == 0);
+ __go_assert (i == 0);
return ret;
}
diff --git a/libgo/runtime/go-construct-map.c b/libgo/runtime/go-construct-map.c
index 15497eadb5d..5e459d07ac4 100644
--- a/libgo/runtime/go-construct-map.c
+++ b/libgo/runtime/go-construct-map.c
@@ -5,18 +5,20 @@
license that can be found in the LICENSE file. */
#include <stddef.h>
+#include <stdint.h>
#include <stdlib.h>
#include "map.h"
struct __go_map *
__go_construct_map (const struct __go_map_descriptor *descriptor,
- size_t count, size_t entry_size, size_t val_offset,
- size_t val_size, const void *ventries)
+ uintptr_t count, uintptr_t entry_size,
+ uintptr_t val_offset, uintptr_t val_size,
+ const void *ventries)
{
struct __go_map *ret;
const unsigned char *entries;
- size_t i;
+ uintptr_t i;
ret = __go_new_map (descriptor, count);
diff --git a/libgo/runtime/go-copy.c b/libgo/runtime/go-copy.c
index 998aeb927d4..05e16acbf1c 100644
--- a/libgo/runtime/go-copy.c
+++ b/libgo/runtime/go-copy.c
@@ -5,17 +5,18 @@
license that can be found in the LICENSE file. */
#include <stddef.h>
+#include <stdint.h>
/* We should be OK if we don't split the stack here, since we are just
calling memmove which shouldn't need much stack. If we don't do
this we will always split the stack, because of memmove. */
extern void
-__go_copy (void *, void *, size_t)
+__go_copy (void *, void *, uintptr_t)
__attribute__ ((no_split_stack));
void
-__go_copy (void *a, void *b, size_t len)
+__go_copy (void *a, void *b, uintptr_t len)
{
__builtin_memmove (a, b, len);
}
diff --git a/libgo/runtime/go-int-array-to-string.c b/libgo/runtime/go-int-array-to-string.c
index c16589f01a2..ec07b873907 100644
--- a/libgo/runtime/go-int-array-to-string.c
+++ b/libgo/runtime/go-int-array-to-string.c
@@ -10,11 +10,11 @@
#include "malloc.h"
struct __go_string
-__go_int_array_to_string (const void* p, size_t len)
+__go_int_array_to_string (const void* p, int len)
{
const int *ints;
- size_t slen;
- size_t i;
+ int slen;
+ int i;
unsigned char *retdata;
struct __go_string ret;
unsigned char *s;
@@ -79,7 +79,7 @@ __go_int_array_to_string (const void* p, size_t len)
}
}
- __go_assert ((size_t) (s - retdata) == slen);
+ __go_assert (s - retdata == slen);
return ret;
}
diff --git a/libgo/runtime/go-map-len.c b/libgo/runtime/go-map-len.c
index 75b7473390d..01df5b41c6c 100644
--- a/libgo/runtime/go-map-len.c
+++ b/libgo/runtime/go-map-len.c
@@ -6,16 +6,18 @@
#include <stddef.h>
+#include "go-assert.h"
#include "map.h"
/* Return the length of a map. This could be done inline, of course,
- but I'm doing it as a function for now to make it easy to chang the
- map structure. */
+ but I'm doing it as a function for now to make it easy to change
+ the map structure. */
-size_t
+int
__go_map_len (struct __go_map *map)
{
if (map == NULL)
return 0;
+ __go_assert (map->__element_count == (size_t) (int) map->__element_count);
return map->__element_count;
}
diff --git a/libgo/runtime/go-new-channel.c b/libgo/runtime/go-new-channel.c
index 3ddc205e05d..028715e3b1d 100644
--- a/libgo/runtime/go-new-channel.c
+++ b/libgo/runtime/go-new-channel.c
@@ -5,6 +5,7 @@
license that can be found in the LICENSE file. */
#include <stddef.h>
+#include <stdint.h>
#include "go-alloc.h"
#include "go-assert.h"
@@ -12,13 +13,14 @@
#include "channel.h"
struct __go_channel*
-__go_new_channel (size_t element_size, size_t entries)
+__go_new_channel (uintptr_t element_size, uintptr_t entries)
{
struct __go_channel* ret;
size_t alloc_size;
int i;
- if ((size_t) (int) entries != entries || entries > (size_t) -1 / element_size)
+ if ((uintptr_t) (int) entries != entries
+ || entries > (uintptr_t) -1 / element_size)
__go_panic_msg ("chan size out of range");
alloc_size = (element_size + sizeof (uint64_t) - 1) / sizeof (uint64_t);
diff --git a/libgo/runtime/go-new-map.c b/libgo/runtime/go-new-map.c
index 519f38f788a..73e8d7dfe79 100644
--- a/libgo/runtime/go-new-map.c
+++ b/libgo/runtime/go-new-map.c
@@ -104,11 +104,11 @@ __go_map_next_prime (unsigned long n)
/* Allocate a new map. */
struct __go_map *
-__go_new_map (const struct __go_map_descriptor *descriptor, size_t entries)
+__go_new_map (const struct __go_map_descriptor *descriptor, uintptr_t entries)
{
struct __go_map *ret;
- if ((size_t) (int) entries != entries)
+ if ((uintptr_t) (int) entries != entries)
__go_panic_msg ("map size out of range");
if (entries == 0)
diff --git a/libgo/runtime/go-new.c b/libgo/runtime/go-new.c
index 8f25c5730ef..657978c30a8 100644
--- a/libgo/runtime/go-new.c
+++ b/libgo/runtime/go-new.c
@@ -9,13 +9,13 @@
#include "malloc.h"
void *
-__go_new (size_t size)
+__go_new (uintptr_t size)
{
return runtime_mallocgc (size, 0, 1, 1);
}
void *
-__go_new_nopointers (size_t size)
+__go_new_nopointers (uintptr_t size)
{
return runtime_mallocgc (size, FlagNoPointers, 1, 1);
}
diff --git a/libgo/runtime/go-select.c b/libgo/runtime/go-select.c
index 9d9f728f2bc..5ea521d423d 100644
--- a/libgo/runtime/go-select.c
+++ b/libgo/runtime/go-select.c
@@ -22,11 +22,11 @@ struct select_channel
/* The channel being selected. */
struct __go_channel* channel;
/* If this channel is selected, the value to return. */
- size_t retval;
+ uintptr_t retval;
/* If this channel is a duplicate of one which appears earlier in
the array, this is the array index of the earlier channel. This
is -1UL if this is not a dup. */
- size_t dup_index;
+ uintptr_t dup_index;
/* An entry to put on the send or receive queue. */
struct __go_channel_select queue_entry;
/* True if selected for send. */
@@ -321,24 +321,24 @@ clear_select_waiting (struct select_channel *sc,
Lock each channels, and set the is_ready flag. Return the number
of ready channels. */
-static size_t
-lock_channels_find_ready (struct select_channel *channels, size_t count)
+static uintptr_t
+lock_channels_find_ready (struct select_channel *channels, uintptr_t count)
{
- size_t ready_count;
- size_t i;
+ uintptr_t ready_count;
+ uintptr_t i;
ready_count = 0;
for (i = 0; i < count; ++i)
{
struct __go_channel *channel = channels[i].channel;
_Bool is_send = channels[i].is_send;
- size_t dup_index = channels[i].dup_index;
+ uintptr_t dup_index = channels[i].dup_index;
int x;
if (channel == NULL)
continue;
- if (dup_index != (size_t) -1UL)
+ if (dup_index != (uintptr_t) -1UL)
{
if (channels[dup_index].is_ready)
{
@@ -370,13 +370,13 @@ lock_channels_find_ready (struct select_channel *channels, size_t count)
All the channels are locked before this routine is called. This
returns the number of ready channels. */
-size_t
-force_selected_channel_ready (struct select_channel *channels, size_t count,
+uintptr_t
+force_selected_channel_ready (struct select_channel *channels, uintptr_t count,
struct __go_channel *selected_channel,
_Bool selected_for_read)
{
- size_t ready_count;
- size_t i;
+ uintptr_t ready_count;
+ uintptr_t i;
ready_count = 0;
for (i = 0; i < count; ++i)
@@ -403,9 +403,9 @@ force_selected_channel_ready (struct select_channel *channels, size_t count,
/* Unlock all the channels. */
static void
-unlock_channels (struct select_channel *channels, size_t count)
+unlock_channels (struct select_channel *channels, uintptr_t count)
{
- size_t i;
+ uintptr_t i;
int x;
for (i = 0; i < count; ++i)
@@ -415,7 +415,7 @@ unlock_channels (struct select_channel *channels, size_t count)
if (channel == NULL)
continue;
- if (channels[i].dup_index != (size_t) -1UL)
+ if (channels[i].dup_index != (uintptr_t) -1UL)
continue;
x = pthread_mutex_unlock (&channel->lock);
@@ -432,23 +432,23 @@ unlock_channels (struct select_channel *channels, size_t count)
with some other select, and that select already synchronized with a
different channel. */
-static size_t
+static uintptr_t
unlock_channels_and_select (struct select_channel *channels,
- size_t count, size_t ready_count,
+ uintptr_t count, uintptr_t ready_count,
_Bool is_selected,
struct __go_channel **selected_pointer)
{
- size_t selected;
- size_t ret;
+ uintptr_t selected;
+ uintptr_t ret;
_Bool needs_broadcast;
- size_t i;
+ uintptr_t i;
int x;
/* Pick which channel we are going to return. */
#if defined(HAVE_RANDOM)
- selected = (size_t) random () % ready_count;
+ selected = (uintptr_t) random () % ready_count;
#else
- selected = (size_t) rand () % ready_count;
+ selected = (uintptr_t) rand () % ready_count;
#endif
ret = 0;
needs_broadcast = 0;
@@ -457,7 +457,7 @@ unlock_channels_and_select (struct select_channel *channels,
duplicated channel until we have seen all its dups. */
for (i = 0; i < count; ++i)
{
- size_t j = count - i - 1;
+ uintptr_t j = count - i - 1;
struct __go_channel *channel = channels[j].channel;
_Bool is_send = channels[j].is_send;
@@ -476,7 +476,7 @@ unlock_channels_and_select (struct select_channel *channels,
--selected;
}
- if (channels[j].dup_index == (size_t) -1UL)
+ if (channels[j].dup_index == (uintptr_t) -1UL)
{
if (selected_pointer != NULL)
clear_select_waiting (&channels[j], selected_pointer);
@@ -511,13 +511,13 @@ unlock_channels_and_select (struct select_channel *channels,
ready. */
static _Bool
-mark_all_channels_waiting (struct select_channel* channels, size_t count,
+mark_all_channels_waiting (struct select_channel* channels, uintptr_t count,
struct __go_channel **selected_pointer,
_Bool *selected_for_read_pointer)
{
_Bool ret;
int x;
- size_t i;
+ uintptr_t i;
ret = 0;
for (i = 0; i < count; ++i)
@@ -528,9 +528,9 @@ mark_all_channels_waiting (struct select_channel* channels, size_t count,
if (channel == NULL)
continue;
- if (channels[i].dup_index != (size_t) -1UL)
+ if (channels[i].dup_index != (uintptr_t) -1UL)
{
- size_t j;
+ uintptr_t j;
/* A channel may be selected for both read and write. */
if (channels[channels[i].dup_index].is_send != is_send)
@@ -574,14 +574,14 @@ mark_all_channels_waiting (struct select_channel* channels, size_t count,
with pairs of arguments: a pointer to a channel, and an int which
is non-zero for send, zero for receive. */
-size_t
-__go_select (size_t count, _Bool has_default,
+uintptr_t
+__go_select (uintptr_t count, _Bool has_default,
struct __go_channel **channel_args, _Bool *is_send_args)
{
struct select_channel stack_buffer[16];
struct select_channel *allocated_buffer;
struct select_channel *channels;
- size_t i;
+ uintptr_t i;
int x;
struct __go_channel *selected_channel;
_Bool selected_for_read;
@@ -606,7 +606,7 @@ __go_select (size_t count, _Bool has_default,
channels[i].channel = (struct __go_channel*) channel_arg;
channels[i].retval = i + 1;
- channels[i].dup_index = (size_t) -1UL;
+ channels[i].dup_index = (uintptr_t) -1UL;
channels[i].queue_entry.next = NULL;
channels[i].queue_entry.selected = NULL;
channels[i].is_send = is_send;
@@ -617,7 +617,7 @@ __go_select (size_t count, _Bool has_default,
for (i = 0; i < count; ++i)
{
- size_t j;
+ uintptr_t j;
for (j = 0; j < i; ++j)
{
@@ -667,7 +667,7 @@ __go_select (size_t count, _Bool has_default,
if (ready_count > 0)
{
- size_t ret;
+ uintptr_t ret;
ret = unlock_channels_and_select (channels, count, ready_count,
is_selected,
diff --git a/libgo/runtime/go-trampoline.c b/libgo/runtime/go-trampoline.c
index 43003e81c93..d6cc29922e8 100644
--- a/libgo/runtime/go-trampoline.c
+++ b/libgo/runtime/go-trampoline.c
@@ -22,7 +22,7 @@
needs to be more system dependent. */
void *
-__go_allocate_trampoline (size_t size, void *closure)
+__go_allocate_trampoline (uintptr_t size, void *closure)
{
unsigned int page_size;
void *ret;
diff --git a/libgo/runtime/map.h b/libgo/runtime/map.h
index a0c834a54ac..9c3fda263a0 100644
--- a/libgo/runtime/map.h
+++ b/libgo/runtime/map.h
@@ -68,7 +68,7 @@ struct __go_hash_iter
};
extern struct __go_map *__go_new_map (const struct __go_map_descriptor *,
- size_t);
+ uintptr_t);
extern unsigned long __go_map_next_prime (unsigned long);