runtime: Copy runtime_panicstring from master library.
From-SVN: r181830
This commit is contained in:
parent
a592211185
commit
b87974949f
@ -32,7 +32,7 @@ __go_append (struct __go_open_array a, void *bvalues, uintptr_t bcount,
|
|||||||
ucount = (uintptr_t) a.__count + bcount;
|
ucount = (uintptr_t) a.__count + bcount;
|
||||||
count = (int) ucount;
|
count = (int) ucount;
|
||||||
if ((uintptr_t) count != ucount || count <= a.__count)
|
if ((uintptr_t) count != ucount || count <= a.__count)
|
||||||
__go_panic_msg ("append: slice overflow");
|
runtime_panicstring ("append: slice overflow");
|
||||||
|
|
||||||
if (count > a.__capacity)
|
if (count > a.__capacity)
|
||||||
{
|
{
|
||||||
|
@ -18,7 +18,7 @@ __go_builtin_close (struct __go_channel *channel)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (channel == NULL)
|
if (channel == NULL)
|
||||||
__go_panic_msg ("close of nil channel");
|
runtime_panicstring ("close of nil channel");
|
||||||
|
|
||||||
i = pthread_mutex_lock (&channel->lock);
|
i = pthread_mutex_lock (&channel->lock);
|
||||||
__go_assert (i == 0);
|
__go_assert (i == 0);
|
||||||
@ -30,7 +30,7 @@ __go_builtin_close (struct __go_channel *channel)
|
|||||||
{
|
{
|
||||||
i = pthread_mutex_unlock (&channel->lock);
|
i = pthread_mutex_unlock (&channel->lock);
|
||||||
__go_assert (i == 0);
|
__go_assert (i == 0);
|
||||||
__go_panic_msg ("close of closed channel");
|
runtime_panicstring ("close of closed channel");
|
||||||
}
|
}
|
||||||
|
|
||||||
channel->is_closed = 1;
|
channel->is_closed = 1;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
Use of this source code is governed by a BSD-style
|
Use of this source code is governed by a BSD-style
|
||||||
license that can be found in the LICENSE file. */
|
license that can be found in the LICENSE file. */
|
||||||
|
|
||||||
#include "go-panic.h"
|
#include "runtime.h"
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
|
|
||||||
/* Compare two interface values. Return 0 for equal, not zero for not
|
/* Compare two interface values. Return 0 for equal, not zero for not
|
||||||
@ -20,7 +20,7 @@ __go_empty_interface_compare (struct __go_empty_interface left,
|
|||||||
|
|
||||||
if (((uintptr_t) left_descriptor & reflectFlags) != 0
|
if (((uintptr_t) left_descriptor & reflectFlags) != 0
|
||||||
|| ((uintptr_t) right.__type_descriptor & reflectFlags) != 0)
|
|| ((uintptr_t) right.__type_descriptor & reflectFlags) != 0)
|
||||||
__go_panic_msg ("invalid interface value");
|
runtime_panicstring ("invalid interface value");
|
||||||
|
|
||||||
if (left_descriptor == NULL && right.__type_descriptor == NULL)
|
if (left_descriptor == NULL && right.__type_descriptor == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
Use of this source code is governed by a BSD-style
|
Use of this source code is governed by a BSD-style
|
||||||
license that can be found in the LICENSE file. */
|
license that can be found in the LICENSE file. */
|
||||||
|
|
||||||
#include "go-panic.h"
|
#include "runtime.h"
|
||||||
#include "go-type.h"
|
#include "go-type.h"
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ __go_empty_interface_value_compare (
|
|||||||
|
|
||||||
left_descriptor = left.__type_descriptor;
|
left_descriptor = left.__type_descriptor;
|
||||||
if (((uintptr_t) left_descriptor & reflectFlags) != 0)
|
if (((uintptr_t) left_descriptor & reflectFlags) != 0)
|
||||||
__go_panic_msg ("invalid interface value");
|
runtime_panicstring ("invalid interface value");
|
||||||
if (left_descriptor == NULL)
|
if (left_descriptor == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
if (!__go_type_descriptors_equal (left_descriptor, right_descriptor))
|
if (!__go_type_descriptors_equal (left_descriptor, right_descriptor))
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
Use of this source code is governed by a BSD-style
|
Use of this source code is governed by a BSD-style
|
||||||
license that can be found in the LICENSE file. */
|
license that can be found in the LICENSE file. */
|
||||||
|
|
||||||
#include "go-panic.h"
|
#include "runtime.h"
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
|
|
||||||
/* Compare a non-empty interface value with an empty interface value.
|
/* Compare a non-empty interface value with an empty interface value.
|
||||||
@ -18,7 +18,7 @@ __go_interface_empty_compare (struct __go_interface left,
|
|||||||
const struct __go_type_descriptor *left_descriptor;
|
const struct __go_type_descriptor *left_descriptor;
|
||||||
|
|
||||||
if (((uintptr_t) right.__type_descriptor & reflectFlags) != 0)
|
if (((uintptr_t) right.__type_descriptor & reflectFlags) != 0)
|
||||||
__go_panic_msg ("invalid interface value");
|
runtime_panicstring ("invalid interface value");
|
||||||
if (left.__methods == NULL && right.__type_descriptor == NULL)
|
if (left.__methods == NULL && right.__type_descriptor == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
if (left.__methods == NULL || right.__type_descriptor == NULL)
|
if (left.__methods == NULL || right.__type_descriptor == NULL)
|
||||||
|
@ -31,14 +31,14 @@ __go_make_slice2 (const struct __go_type_descriptor *td, uintptr_t len,
|
|||||||
|
|
||||||
ilen = (int) len;
|
ilen = (int) len;
|
||||||
if (ilen < 0 || (uintptr_t) ilen != len)
|
if (ilen < 0 || (uintptr_t) ilen != len)
|
||||||
__go_panic_msg ("makeslice: len out of range");
|
runtime_panicstring ("makeslice: len out of range");
|
||||||
|
|
||||||
icap = (int) cap;
|
icap = (int) cap;
|
||||||
if (cap < len
|
if (cap < len
|
||||||
|| (uintptr_t) icap != cap
|
|| (uintptr_t) icap != cap
|
||||||
|| (std->__element_type->__size > 0
|
|| (std->__element_type->__size > 0
|
||||||
&& cap > (uintptr_t) -1U / std->__element_type->__size))
|
&& cap > (uintptr_t) -1U / std->__element_type->__size))
|
||||||
__go_panic_msg ("makeslice: cap out of range");
|
runtime_panicstring ("makeslice: cap out of range");
|
||||||
|
|
||||||
ret.__count = ilen;
|
ret.__count = ilen;
|
||||||
ret.__capacity = icap;
|
ret.__capacity = icap;
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "runtime.h"
|
||||||
#include "go-alloc.h"
|
#include "go-alloc.h"
|
||||||
#include "go-assert.h"
|
#include "go-assert.h"
|
||||||
#include "go-panic.h"
|
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
|
||||||
/* Delete the entry matching KEY from MAP. */
|
/* Delete the entry matching KEY from MAP. */
|
||||||
@ -27,7 +27,7 @@ __go_map_delete (struct __go_map *map, const void *key)
|
|||||||
void **pentry;
|
void **pentry;
|
||||||
|
|
||||||
if (map == NULL)
|
if (map == NULL)
|
||||||
__go_panic_msg ("deletion of entry in nil map");
|
runtime_panicstring ("deletion of entry in nil map");
|
||||||
|
|
||||||
descriptor = map->__descriptor;
|
descriptor = map->__descriptor;
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "runtime.h"
|
||||||
#include "go-alloc.h"
|
#include "go-alloc.h"
|
||||||
#include "go-assert.h"
|
#include "go-assert.h"
|
||||||
#include "go-panic.h"
|
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
|
||||||
/* Rehash MAP to a larger size. */
|
/* Rehash MAP to a larger size. */
|
||||||
@ -89,7 +89,7 @@ __go_map_index (struct __go_map *map, const void *key, _Bool insert)
|
|||||||
if (map == NULL)
|
if (map == NULL)
|
||||||
{
|
{
|
||||||
if (insert)
|
if (insert)
|
||||||
__go_panic_msg ("assignment to entry in nil map");
|
runtime_panicstring ("assignment to entry in nil map");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "runtime.h"
|
||||||
#include "go-alloc.h"
|
#include "go-alloc.h"
|
||||||
#include "go-assert.h"
|
#include "go-assert.h"
|
||||||
#include "go-panic.h"
|
|
||||||
#include "channel.h"
|
#include "channel.h"
|
||||||
|
|
||||||
struct __go_channel*
|
struct __go_channel*
|
||||||
@ -34,7 +34,7 @@ __go_new_channel (const struct __go_type_descriptor *channel_type,
|
|||||||
if (ientries < 0
|
if (ientries < 0
|
||||||
|| (uintptr_t) ientries != entries
|
|| (uintptr_t) ientries != entries
|
||||||
|| (element_size > 0 && entries > (uintptr_t) -1 / element_size))
|
|| (element_size > 0 && entries > (uintptr_t) -1 / element_size))
|
||||||
__go_panic_msg ("chan size out of range");
|
runtime_panicstring ("chan size out of range");
|
||||||
|
|
||||||
alloc_size = (element_size + sizeof (uint64_t) - 1) / sizeof (uint64_t);
|
alloc_size = (element_size + sizeof (uint64_t) - 1) / sizeof (uint64_t);
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
Use of this source code is governed by a BSD-style
|
Use of this source code is governed by a BSD-style
|
||||||
license that can be found in the LICENSE file. */
|
license that can be found in the LICENSE file. */
|
||||||
|
|
||||||
|
#include "runtime.h"
|
||||||
#include "go-alloc.h"
|
#include "go-alloc.h"
|
||||||
#include "go-panic.h"
|
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
|
||||||
/* List of prime numbers, copied from libstdc++/src/hashtable.c. */
|
/* List of prime numbers, copied from libstdc++/src/hashtable.c. */
|
||||||
@ -111,7 +111,7 @@ __go_new_map (const struct __go_map_descriptor *descriptor, uintptr_t entries)
|
|||||||
|
|
||||||
ientries = (int) entries;
|
ientries = (int) entries;
|
||||||
if (ientries < 0 || (uintptr_t) ientries != entries)
|
if (ientries < 0 || (uintptr_t) ientries != entries)
|
||||||
__go_panic_msg ("map size out of range");
|
runtime_panicstring ("map size out of range");
|
||||||
|
|
||||||
if (entries == 0)
|
if (entries == 0)
|
||||||
entries = 5;
|
entries = 5;
|
||||||
|
@ -105,22 +105,3 @@ __go_panic (struct __go_empty_interface arg)
|
|||||||
__printpanics (g->panic);
|
__printpanics (g->panic);
|
||||||
runtime_dopanic (0);
|
runtime_dopanic (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is used by the runtime library. */
|
|
||||||
|
|
||||||
void
|
|
||||||
__go_panic_msg (const char* msg)
|
|
||||||
{
|
|
||||||
size_t len;
|
|
||||||
unsigned char *sdata;
|
|
||||||
struct __go_string s;
|
|
||||||
struct __go_empty_interface arg;
|
|
||||||
|
|
||||||
len = __builtin_strlen (msg);
|
|
||||||
sdata = runtime_mallocgc (len, FlagNoPointers, 0, 0);
|
|
||||||
__builtin_memcpy (sdata, msg, len);
|
|
||||||
s.__data = sdata;
|
|
||||||
s.__length = len;
|
|
||||||
newErrorString(s, &arg);
|
|
||||||
__go_panic (arg);
|
|
||||||
}
|
|
||||||
|
@ -34,9 +34,6 @@ struct __go_panic_stack
|
|||||||
extern void __go_panic (struct __go_empty_interface)
|
extern void __go_panic (struct __go_empty_interface)
|
||||||
__attribute__ ((noreturn));
|
__attribute__ ((noreturn));
|
||||||
|
|
||||||
extern void __go_panic_msg (const char* msg)
|
|
||||||
__attribute__ ((noreturn));
|
|
||||||
|
|
||||||
extern void __go_print_string (struct __go_string);
|
extern void __go_print_string (struct __go_string);
|
||||||
|
|
||||||
extern struct __go_empty_interface __go_recover (void);
|
extern struct __go_empty_interface __go_recover (void);
|
||||||
@ -55,7 +52,8 @@ extern void newTypeAssertionError(const struct __go_type_descriptor *pt1,
|
|||||||
struct __go_empty_interface *ret)
|
struct __go_empty_interface *ret)
|
||||||
__asm__ ("libgo_runtime.runtime.NewTypeAssertionError");
|
__asm__ ("libgo_runtime.runtime.NewTypeAssertionError");
|
||||||
|
|
||||||
extern void newErrorString(struct __go_string, struct __go_empty_interface *)
|
extern void runtime_newErrorString(struct __go_string,
|
||||||
|
struct __go_empty_interface *)
|
||||||
__asm__ ("libgo_runtime.runtime.NewErrorString");
|
__asm__ ("libgo_runtime.runtime.NewErrorString");
|
||||||
|
|
||||||
extern void printany(struct __go_empty_interface)
|
extern void printany(struct __go_empty_interface)
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "runtime.h"
|
||||||
#include "go-alloc.h"
|
#include "go-alloc.h"
|
||||||
#include "go-assert.h"
|
#include "go-assert.h"
|
||||||
#include "go-panic.h"
|
|
||||||
#include "go-type.h"
|
#include "go-type.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ mapassign (struct __go_map_type *mt, uintptr_t m, uintptr_t key_i,
|
|||||||
__go_assert (mt->__common.__code == GO_MAP);
|
__go_assert (mt->__common.__code == GO_MAP);
|
||||||
|
|
||||||
if (map == NULL)
|
if (map == NULL)
|
||||||
__go_panic_msg ("assignment to entry in nil map");
|
runtime_panicstring ("assignment to entry in nil map");
|
||||||
|
|
||||||
key_descriptor = mt->__key_type;
|
key_descriptor = mt->__key_type;
|
||||||
if (__go_is_pointer_type (key_descriptor))
|
if (__go_is_pointer_type (key_descriptor))
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "runtime.h"
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
#include "go-alloc.h"
|
#include "go-alloc.h"
|
||||||
#include "go-panic.h"
|
|
||||||
#include "go-string.h"
|
#include "go-string.h"
|
||||||
#include "go-type.h"
|
#include "go-type.h"
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ Reflect (struct __go_empty_interface e)
|
|||||||
struct reflect_ret ret;
|
struct reflect_ret ret;
|
||||||
|
|
||||||
if (((uintptr_t) e.__type_descriptor & reflectFlags) != 0)
|
if (((uintptr_t) e.__type_descriptor & reflectFlags) != 0)
|
||||||
__go_panic_msg ("invalid interface value");
|
runtime_panicstring ("invalid interface value");
|
||||||
|
|
||||||
if (e.__type_descriptor == NULL)
|
if (e.__type_descriptor == NULL)
|
||||||
{
|
{
|
||||||
@ -170,7 +170,7 @@ Typeof (const struct __go_empty_interface e)
|
|||||||
struct __go_empty_interface ret;
|
struct __go_empty_interface ret;
|
||||||
|
|
||||||
if (((uintptr_t) e.__type_descriptor & reflectFlags) != 0)
|
if (((uintptr_t) e.__type_descriptor & reflectFlags) != 0)
|
||||||
__go_panic_msg ("invalid interface value");
|
runtime_panicstring ("invalid interface value");
|
||||||
|
|
||||||
if (e.__type_descriptor == NULL)
|
if (e.__type_descriptor == NULL)
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
Use of this source code is governed by a BSD-style
|
Use of this source code is governed by a BSD-style
|
||||||
license that can be found in the LICENSE file. */
|
license that can be found in the LICENSE file. */
|
||||||
|
|
||||||
#include "go-panic.h"
|
#include "runtime.h"
|
||||||
|
|
||||||
/* The compiler generates calls to this function. This enum values
|
/* The compiler generates calls to this function. This enum values
|
||||||
are known to the compiler and used by compiled code. Any change
|
are known to the compiler and used by compiled code. Any change
|
||||||
@ -59,26 +59,26 @@ __go_runtime_error (int i)
|
|||||||
case SLICE_INDEX_OUT_OF_BOUNDS:
|
case SLICE_INDEX_OUT_OF_BOUNDS:
|
||||||
case ARRAY_INDEX_OUT_OF_BOUNDS:
|
case ARRAY_INDEX_OUT_OF_BOUNDS:
|
||||||
case STRING_INDEX_OUT_OF_BOUNDS:
|
case STRING_INDEX_OUT_OF_BOUNDS:
|
||||||
__go_panic_msg ("index out of range");
|
runtime_panicstring ("index out of range");
|
||||||
|
|
||||||
case SLICE_SLICE_OUT_OF_BOUNDS:
|
case SLICE_SLICE_OUT_OF_BOUNDS:
|
||||||
case ARRAY_SLICE_OUT_OF_BOUNDS:
|
case ARRAY_SLICE_OUT_OF_BOUNDS:
|
||||||
case STRING_SLICE_OUT_OF_BOUNDS:
|
case STRING_SLICE_OUT_OF_BOUNDS:
|
||||||
__go_panic_msg ("slice bounds out of range");
|
runtime_panicstring ("slice bounds out of range");
|
||||||
|
|
||||||
case NIL_DEREFERENCE:
|
case NIL_DEREFERENCE:
|
||||||
__go_panic_msg ("nil pointer dereference");
|
runtime_panicstring ("nil pointer dereference");
|
||||||
|
|
||||||
case MAKE_SLICE_OUT_OF_BOUNDS:
|
case MAKE_SLICE_OUT_OF_BOUNDS:
|
||||||
__go_panic_msg ("make slice len or cap out of range");
|
runtime_panicstring ("make slice len or cap out of range");
|
||||||
|
|
||||||
case MAKE_MAP_OUT_OF_BOUNDS:
|
case MAKE_MAP_OUT_OF_BOUNDS:
|
||||||
__go_panic_msg ("make map len out of range");
|
runtime_panicstring ("make map len out of range");
|
||||||
|
|
||||||
case MAKE_CHAN_OUT_OF_BOUNDS:
|
case MAKE_CHAN_OUT_OF_BOUNDS:
|
||||||
__go_panic_msg ("make chan len out of range");
|
runtime_panicstring ("make chan len out of range");
|
||||||
|
|
||||||
default:
|
default:
|
||||||
__go_panic_msg ("unknown runtime error");
|
runtime_panicstring ("unknown runtime error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ __go_send_nonblocking_acquire (struct __go_channel *channel)
|
|||||||
{
|
{
|
||||||
i = pthread_mutex_unlock (&channel->lock);
|
i = pthread_mutex_unlock (&channel->lock);
|
||||||
__go_assert (i == 0);
|
__go_assert (i == 0);
|
||||||
__go_panic_msg ("send on closed channel");
|
runtime_panicstring ("send on closed channel");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel->num_entries > 0)
|
if (channel->num_entries > 0)
|
||||||
|
@ -31,7 +31,7 @@ __go_send_acquire (struct __go_channel *channel, _Bool for_select)
|
|||||||
channel->selected_for_send = 0;
|
channel->selected_for_send = 0;
|
||||||
i = pthread_mutex_unlock (&channel->lock);
|
i = pthread_mutex_unlock (&channel->lock);
|
||||||
__go_assert (i == 0);
|
__go_assert (i == 0);
|
||||||
__go_panic_msg ("send on closed channel");
|
runtime_panicstring ("send on closed channel");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If somebody else has the channel locked for sending, we have
|
/* If somebody else has the channel locked for sending, we have
|
||||||
|
@ -178,7 +178,7 @@ sighandler (int sig)
|
|||||||
i = sigprocmask (SIG_UNBLOCK, &clear, NULL);
|
i = sigprocmask (SIG_UNBLOCK, &clear, NULL);
|
||||||
__go_assert (i == 0);
|
__go_assert (i == 0);
|
||||||
|
|
||||||
__go_panic_msg (msg);
|
runtime_panicstring (msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; signals[i].sig != -1; ++i)
|
for (i = 0; signals[i].sig != -1; ++i)
|
||||||
|
@ -20,7 +20,7 @@ __go_string_slice (struct __go_string s, int start, int end)
|
|||||||
if (end == -1)
|
if (end == -1)
|
||||||
end = len;
|
end = len;
|
||||||
if (start > len || end < start || end > len)
|
if (start > len || end < start || end > len)
|
||||||
__go_panic_msg ("string index out of bounds");
|
runtime_panicstring ("string index out of bounds");
|
||||||
ret.__data = s.__data + start;
|
ret.__data = s.__data + start;
|
||||||
ret.__length = end - start;
|
ret.__length = end - start;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
Use of this source code is governed by a BSD-style
|
Use of this source code is governed by a BSD-style
|
||||||
license that can be found in the LICENSE file. */
|
license that can be found in the LICENSE file. */
|
||||||
|
|
||||||
|
#include "runtime.h"
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
#include "go-panic.h"
|
|
||||||
#include "go-type.h"
|
#include "go-type.h"
|
||||||
|
|
||||||
/* A hash function for an empty interface. */
|
/* A hash function for an empty interface. */
|
||||||
@ -46,7 +46,7 @@ __go_type_equal_empty_interface (const void *vv1, const void *vv2,
|
|||||||
v2_descriptor = v2->__type_descriptor;
|
v2_descriptor = v2->__type_descriptor;
|
||||||
if (((uintptr_t) v1_descriptor & reflectFlags) != 0
|
if (((uintptr_t) v1_descriptor & reflectFlags) != 0
|
||||||
|| ((uintptr_t) v2_descriptor & reflectFlags) != 0)
|
|| ((uintptr_t) v2_descriptor & reflectFlags) != 0)
|
||||||
__go_panic_msg ("invalid interface value");
|
runtime_panicstring ("invalid interface value");
|
||||||
if (v1_descriptor == NULL || v2_descriptor == NULL)
|
if (v1_descriptor == NULL || v2_descriptor == NULL)
|
||||||
return v1_descriptor == v2_descriptor;
|
return v1_descriptor == v2_descriptor;
|
||||||
if (!__go_type_descriptors_equal (v1_descriptor, v2_descriptor))
|
if (!__go_type_descriptors_equal (v1_descriptor, v2_descriptor))
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
Use of this source code is governed by a BSD-style
|
Use of this source code is governed by a BSD-style
|
||||||
license that can be found in the LICENSE file. */
|
license that can be found in the LICENSE file. */
|
||||||
|
|
||||||
|
#include "runtime.h"
|
||||||
#include "go-type.h"
|
#include "go-type.h"
|
||||||
#include "go-panic.h"
|
|
||||||
|
|
||||||
/* A hash function used for a type which does not support hash
|
/* A hash function used for a type which does not support hash
|
||||||
functions. */
|
functions. */
|
||||||
@ -14,7 +14,7 @@ size_t
|
|||||||
__go_type_hash_error (const void *val __attribute__ ((unused)),
|
__go_type_hash_error (const void *val __attribute__ ((unused)),
|
||||||
size_t key_size __attribute__ ((unused)))
|
size_t key_size __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
__go_panic_msg ("hash of unhashable type");
|
runtime_panicstring ("hash of unhashable type");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* An equality function for an interface. */
|
/* An equality function for an interface. */
|
||||||
@ -24,5 +24,5 @@ __go_type_equal_error (const void *v1 __attribute__ ((unused)),
|
|||||||
const void *v2 __attribute__ ((unused)),
|
const void *v2 __attribute__ ((unused)),
|
||||||
size_t key_size __attribute__ ((unused)))
|
size_t key_size __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
__go_panic_msg ("comparing uncomparable types");
|
runtime_panicstring ("comparing uncomparable types");
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
Use of this source code is governed by a BSD-style
|
Use of this source code is governed by a BSD-style
|
||||||
license that can be found in the LICENSE file. */
|
license that can be found in the LICENSE file. */
|
||||||
|
|
||||||
|
#include "runtime.h"
|
||||||
#include "go-alloc.h"
|
#include "go-alloc.h"
|
||||||
#include "go-panic.h"
|
|
||||||
#include "go-type.h"
|
#include "go-type.h"
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ Unreflect (struct __go_empty_interface type, void *object)
|
|||||||
struct __go_empty_interface ret;
|
struct __go_empty_interface ret;
|
||||||
|
|
||||||
if (((uintptr_t) type.__type_descriptor & reflectFlags) != 0)
|
if (((uintptr_t) type.__type_descriptor & reflectFlags) != 0)
|
||||||
__go_panic_msg ("invalid interface value");
|
runtime_panicstring ("invalid interface value");
|
||||||
|
|
||||||
/* FIXME: We should check __type_descriptor to verify that this is
|
/* FIXME: We should check __type_descriptor to verify that this is
|
||||||
really a type descriptor. */
|
really a type descriptor. */
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
Use of this source code is governed by a BSD-style
|
Use of this source code is governed by a BSD-style
|
||||||
license that can be found in the LICENSE file. */
|
license that can be found in the LICENSE file. */
|
||||||
|
|
||||||
|
#include "runtime.h"
|
||||||
#include "go-alloc.h"
|
#include "go-alloc.h"
|
||||||
#include "go-panic.h"
|
|
||||||
#include "go-type.h"
|
#include "go-type.h"
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ New (struct __go_empty_interface type)
|
|||||||
const struct __go_type_descriptor *descriptor;
|
const struct __go_type_descriptor *descriptor;
|
||||||
|
|
||||||
if (((uintptr_t) type.__type_descriptor & reflectFlags) != 0)
|
if (((uintptr_t) type.__type_descriptor & reflectFlags) != 0)
|
||||||
__go_panic_msg ("invalid interface value");
|
runtime_panicstring ("invalid interface value");
|
||||||
|
|
||||||
/* FIXME: We should check __type_descriptor to verify that this is
|
/* FIXME: We should check __type_descriptor to verify that this is
|
||||||
really a type descriptor. */
|
really a type descriptor. */
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
Use of this source code is governed by a BSD-style
|
Use of this source code is governed by a BSD-style
|
||||||
license that can be found in the LICENSE file. */
|
license that can be found in the LICENSE file. */
|
||||||
|
|
||||||
|
#include "runtime.h"
|
||||||
#include "go-alloc.h"
|
#include "go-alloc.h"
|
||||||
#include "go-panic.h"
|
|
||||||
#include "go-type.h"
|
#include "go-type.h"
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ NewArray (struct __go_empty_interface type, int n)
|
|||||||
const struct __go_type_descriptor *descriptor;
|
const struct __go_type_descriptor *descriptor;
|
||||||
|
|
||||||
if (((uintptr_t) type.__type_descriptor & reflectFlags) != 0)
|
if (((uintptr_t) type.__type_descriptor & reflectFlags) != 0)
|
||||||
__go_panic_msg ("invalid interface value");
|
runtime_panicstring ("invalid interface value");
|
||||||
|
|
||||||
/* FIXME: We should check __type_descriptor to verify that this is
|
/* FIXME: We should check __type_descriptor to verify that this is
|
||||||
really a type descriptor. */
|
really a type descriptor. */
|
||||||
|
@ -3,12 +3,10 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package runtime
|
package runtime
|
||||||
#include "go-panic.h"
|
#include "runtime.h"
|
||||||
#include "go-type.h"
|
#include "go-type.h"
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
#define nil NULL
|
|
||||||
|
|
||||||
typedef _Bool bool;
|
|
||||||
typedef struct __go_type_descriptor descriptor;
|
typedef struct __go_type_descriptor descriptor;
|
||||||
typedef const struct __go_type_descriptor const_descriptor;
|
typedef const struct __go_type_descriptor const_descriptor;
|
||||||
typedef struct __go_interface interface;
|
typedef struct __go_interface interface;
|
||||||
@ -35,7 +33,7 @@ func ifacetype(i interface) (d *const_descriptor) {
|
|||||||
// Convert an empty interface to an empty interface.
|
// Convert an empty interface to an empty interface.
|
||||||
func ifaceE2E2(e empty_interface) (ret empty_interface, ok bool) {
|
func ifaceE2E2(e empty_interface) (ret empty_interface, ok bool) {
|
||||||
if(((uintptr_t)e.__type_descriptor&reflectFlags) != 0)
|
if(((uintptr_t)e.__type_descriptor&reflectFlags) != 0)
|
||||||
__go_panic_msg("invalid interface value");
|
runtime_panicstring("invalid interface value");
|
||||||
ret = e;
|
ret = e;
|
||||||
ok = ret.__type_descriptor != nil;
|
ok = ret.__type_descriptor != nil;
|
||||||
}
|
}
|
||||||
@ -56,7 +54,7 @@ func ifaceI2E2(i interface) (ret empty_interface, ok bool) {
|
|||||||
// Convert an empty interface to a non-empty interface.
|
// Convert an empty interface to a non-empty interface.
|
||||||
func ifaceE2I2(inter *descriptor, e empty_interface) (ret interface, ok bool) {
|
func ifaceE2I2(inter *descriptor, e empty_interface) (ret interface, ok bool) {
|
||||||
if(((uintptr_t)e.__type_descriptor&reflectFlags) != 0)
|
if(((uintptr_t)e.__type_descriptor&reflectFlags) != 0)
|
||||||
__go_panic_msg("invalid interface value");
|
runtime_panicstring("invalid interface value");
|
||||||
if (e.__type_descriptor == nil) {
|
if (e.__type_descriptor == nil) {
|
||||||
ret.__methods = nil;
|
ret.__methods = nil;
|
||||||
ret.__object = nil;
|
ret.__object = nil;
|
||||||
@ -87,7 +85,7 @@ func ifaceI2I2(inter *descriptor, i interface) (ret interface, ok bool) {
|
|||||||
// Convert an empty interface to a pointer type.
|
// Convert an empty interface to a pointer type.
|
||||||
func ifaceE2T2P(inter *descriptor, e empty_interface) (ret *void, ok bool) {
|
func ifaceE2T2P(inter *descriptor, e empty_interface) (ret *void, ok bool) {
|
||||||
if(((uintptr_t)e.__type_descriptor&reflectFlags) != 0)
|
if(((uintptr_t)e.__type_descriptor&reflectFlags) != 0)
|
||||||
__go_panic_msg("invalid interface value");
|
runtime_panicstring("invalid interface value");
|
||||||
if (!__go_type_descriptors_equal(inter, e.__type_descriptor)) {
|
if (!__go_type_descriptors_equal(inter, e.__type_descriptor)) {
|
||||||
ret = nil;
|
ret = nil;
|
||||||
ok = 0;
|
ok = 0;
|
||||||
@ -112,7 +110,7 @@ func ifaceI2T2P(inter *descriptor, i interface) (ret *void, ok bool) {
|
|||||||
// Convert an empty interface to a non-pointer type.
|
// Convert an empty interface to a non-pointer type.
|
||||||
func ifaceE2T2(inter *descriptor, e empty_interface, ret *void) (ok bool) {
|
func ifaceE2T2(inter *descriptor, e empty_interface, ret *void) (ok bool) {
|
||||||
if(((uintptr_t)e.__type_descriptor&reflectFlags) != 0)
|
if(((uintptr_t)e.__type_descriptor&reflectFlags) != 0)
|
||||||
__go_panic_msg("invalid interface value");
|
runtime_panicstring("invalid interface value");
|
||||||
if (!__go_type_descriptors_equal(inter, e.__type_descriptor)) {
|
if (!__go_type_descriptors_equal(inter, e.__type_descriptor)) {
|
||||||
__builtin_memset(ret, 0, inter->__size);
|
__builtin_memset(ret, 0, inter->__size);
|
||||||
ok = 0;
|
ok = 0;
|
||||||
|
@ -17,9 +17,6 @@ package runtime
|
|||||||
#include "go-string.h"
|
#include "go-string.h"
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
#include "go-type.h"
|
#include "go-type.h"
|
||||||
typedef struct __go_empty_interface Eface;
|
|
||||||
typedef struct __go_type_descriptor Type;
|
|
||||||
typedef struct __go_func_type FuncType;
|
|
||||||
|
|
||||||
MHeap runtime_mheap;
|
MHeap runtime_mheap;
|
||||||
extern MStats mstats; // defined in extern.go
|
extern MStats mstats; // defined in extern.go
|
||||||
|
@ -3,13 +3,9 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package runtime
|
package runtime
|
||||||
|
#include "runtime.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#define nil NULL
|
|
||||||
|
|
||||||
typedef unsigned char byte;
|
|
||||||
typedef _Bool bool;
|
|
||||||
|
|
||||||
typedef struct __go_map_type MapType;
|
|
||||||
typedef struct __go_map Hmap;
|
typedef struct __go_map Hmap;
|
||||||
typedef struct __go_hash_iter hiter;
|
typedef struct __go_hash_iter hiter;
|
||||||
|
|
||||||
|
@ -8,10 +8,6 @@ package reflect
|
|||||||
#include "runtime.h"
|
#include "runtime.h"
|
||||||
#include "go-panic.h"
|
#include "go-panic.h"
|
||||||
|
|
||||||
typedef struct __go_type_descriptor Type;
|
|
||||||
typedef struct __go_interface Iface;
|
|
||||||
typedef struct __go_empty_interface Eface;
|
|
||||||
|
|
||||||
func ifaceE2I(inter *Type, e Eface, ret *Iface) {
|
func ifaceE2I(inter *Type, e Eface, ret *Iface) {
|
||||||
const Type *t;
|
const Type *t;
|
||||||
Eface err;
|
Eface err;
|
||||||
|
@ -70,6 +70,19 @@ runtime_throw(const char *s)
|
|||||||
runtime_exit(1); // even more not reached
|
runtime_exit(1); // even more not reached
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
runtime_panicstring(const char *s)
|
||||||
|
{
|
||||||
|
Eface err;
|
||||||
|
|
||||||
|
if(runtime_m()->gcing) {
|
||||||
|
runtime_printf("panic: %s\n", s);
|
||||||
|
runtime_throw("panic during gc");
|
||||||
|
}
|
||||||
|
runtime_newErrorString(runtime_gostringnocopy((const byte*)s), &err);
|
||||||
|
runtime_panic(err);
|
||||||
|
}
|
||||||
|
|
||||||
static int32 argc;
|
static int32 argc;
|
||||||
static byte** argv;
|
static byte** argv;
|
||||||
|
|
||||||
@ -95,7 +108,7 @@ runtime_goargs(void)
|
|||||||
|
|
||||||
s = runtime_malloc(argc*sizeof s[0]);
|
s = runtime_malloc(argc*sizeof s[0]);
|
||||||
for(i=0; i<argc; i++)
|
for(i=0; i<argc; i++)
|
||||||
s[i] = runtime_gostringnocopy((byte*)argv[i]);
|
s[i] = runtime_gostringnocopy((const byte*)argv[i]);
|
||||||
os_Args.__values = (void*)s;
|
os_Args.__values = (void*)s;
|
||||||
os_Args.__count = argc;
|
os_Args.__count = argc;
|
||||||
os_Args.__capacity = argc;
|
os_Args.__capacity = argc;
|
||||||
|
@ -57,10 +57,16 @@ typedef struct MCache MCache;
|
|||||||
typedef struct FixAlloc FixAlloc;
|
typedef struct FixAlloc FixAlloc;
|
||||||
|
|
||||||
typedef struct __go_defer_stack Defer;
|
typedef struct __go_defer_stack Defer;
|
||||||
|
typedef struct __go_interface Iface;
|
||||||
|
typedef struct __go_empty_interface Eface;
|
||||||
|
typedef struct __go_type_descriptor Type;
|
||||||
typedef struct __go_panic_stack Panic;
|
typedef struct __go_panic_stack Panic;
|
||||||
typedef struct __go_open_array Slice;
|
typedef struct __go_open_array Slice;
|
||||||
typedef struct __go_string String;
|
typedef struct __go_string String;
|
||||||
|
|
||||||
|
typedef struct __go_func_type FuncType;
|
||||||
|
typedef struct __go_map_type MapType;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* per-cpu declaration.
|
* per-cpu declaration.
|
||||||
*/
|
*/
|
||||||
@ -211,10 +217,11 @@ void runtime_osinit();
|
|||||||
void runtime_goargs(void);
|
void runtime_goargs(void);
|
||||||
void runtime_goenvs(void);
|
void runtime_goenvs(void);
|
||||||
void runtime_throw(const char*);
|
void runtime_throw(const char*);
|
||||||
|
void runtime_panicstring(const char*) __attribute__ ((noreturn));
|
||||||
void* runtime_mal(uintptr);
|
void* runtime_mal(uintptr);
|
||||||
void runtime_schedinit(void);
|
void runtime_schedinit(void);
|
||||||
void runtime_initsig(int32);
|
void runtime_initsig(int32);
|
||||||
String runtime_gostringnocopy(byte*);
|
String runtime_gostringnocopy(const byte*);
|
||||||
void* runtime_mstart(void*);
|
void* runtime_mstart(void*);
|
||||||
G* runtime_malg(int32, byte**, size_t*);
|
G* runtime_malg(int32, byte**, size_t*);
|
||||||
void runtime_minit(void);
|
void runtime_minit(void);
|
||||||
@ -274,8 +281,13 @@ void runtime_semawakeup(M*);
|
|||||||
void runtime_futexsleep(uint32*, uint32, int64);
|
void runtime_futexsleep(uint32*, uint32, int64);
|
||||||
void runtime_futexwakeup(uint32*, uint32);
|
void runtime_futexwakeup(uint32*, uint32);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* runtime go-called
|
||||||
|
*/
|
||||||
|
void runtime_panic(Eface);
|
||||||
|
|
||||||
/* Functions. */
|
/* Functions. */
|
||||||
|
#define runtime_panic __go_panic
|
||||||
#define runtime_printf printf
|
#define runtime_printf printf
|
||||||
#define runtime_malloc(s) __go_alloc(s)
|
#define runtime_malloc(s) __go_alloc(s)
|
||||||
#define runtime_free(p) __go_free(p)
|
#define runtime_free(p) __go_free(p)
|
||||||
|
@ -15,7 +15,7 @@ runtime_findnull(const byte *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
String
|
String
|
||||||
runtime_gostringnocopy(byte *str)
|
runtime_gostringnocopy(const byte *str)
|
||||||
{
|
{
|
||||||
String s;
|
String s;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user