OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [runtime/] [go-runtime-error.c] - Blame information for rev 764

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
/* go-runtime-error.c -- Go runtime error.
2
 
3
   Copyright 2010 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 "runtime.h"
8
 
9
/* The compiler generates calls to this function.  This enum values
10
   are known to the compiler and used by compiled code.  Any change
11
   here must be reflected in the compiler.  */
12
 
13
enum
14
{
15
  /* Slice index out of bounds: negative or larger than the length of
16
     the slice.  */
17
  SLICE_INDEX_OUT_OF_BOUNDS = 0,
18
 
19
  /* Array index out of bounds.  */
20
  ARRAY_INDEX_OUT_OF_BOUNDS = 1,
21
 
22
  /* String index out of bounds.  */
23
  STRING_INDEX_OUT_OF_BOUNDS = 2,
24
 
25
  /* Slice slice out of bounds: negative or larger than the length of
26
     the slice or high bound less than low bound.  */
27
  SLICE_SLICE_OUT_OF_BOUNDS = 3,
28
 
29
  /* Array slice out of bounds.  */
30
  ARRAY_SLICE_OUT_OF_BOUNDS = 4,
31
 
32
  /* String slice out of bounds.  */
33
  STRING_SLICE_OUT_OF_BOUNDS = 5,
34
 
35
  /* Dereference of nil pointer.  This is used when there is a
36
     dereference of a pointer to a very large struct or array, to
37
     ensure that a gigantic array is not used a proxy to access random
38
     memory locations.  */
39
  NIL_DEREFERENCE = 6,
40
 
41
  /* Slice length or capacity out of bounds in make: negative or
42
     overflow or length greater than capacity.  */
43
  MAKE_SLICE_OUT_OF_BOUNDS = 7,
44
 
45
  /* Map capacity out of bounds in make: negative or overflow.  */
46
  MAKE_MAP_OUT_OF_BOUNDS = 8,
47
 
48
  /* Channel capacity out of bounds in make: negative or overflow.  */
49
  MAKE_CHAN_OUT_OF_BOUNDS = 9
50
};
51
 
52
extern void __go_runtime_error () __attribute__ ((noreturn));
53
 
54
void
55
__go_runtime_error (int i)
56
{
57
  switch (i)
58
    {
59
    case SLICE_INDEX_OUT_OF_BOUNDS:
60
    case ARRAY_INDEX_OUT_OF_BOUNDS:
61
    case STRING_INDEX_OUT_OF_BOUNDS:
62
      runtime_panicstring ("index out of range");
63
 
64
    case SLICE_SLICE_OUT_OF_BOUNDS:
65
    case ARRAY_SLICE_OUT_OF_BOUNDS:
66
    case STRING_SLICE_OUT_OF_BOUNDS:
67
      runtime_panicstring ("slice bounds out of range");
68
 
69
    case NIL_DEREFERENCE:
70
      runtime_panicstring ("nil pointer dereference");
71
 
72
    case MAKE_SLICE_OUT_OF_BOUNDS:
73
      runtime_panicstring ("make slice len or cap out of range");
74
 
75
    case MAKE_MAP_OUT_OF_BOUNDS:
76
      runtime_panicstring ("make map len out of range");
77
 
78
    case MAKE_CHAN_OUT_OF_BOUNDS:
79
      runtime_panicstring ("make chan len out of range");
80
 
81
    default:
82
      runtime_panicstring ("unknown runtime error");
83
    }
84
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.