compiler, runtime: More steps toward separating int and intgo.
authorIan Lance Taylor <ian@gcc.gnu.org>
Thu, 1 Nov 2012 03:02:13 +0000 (03:02 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Thu, 1 Nov 2012 03:02:13 +0000 (03:02 +0000)
From-SVN: r193059

62 files changed:
gcc/go/gofrontend/expressions.cc
gcc/go/gofrontend/gogo-tree.cc
gcc/go/gofrontend/gogo.h
gcc/go/gofrontend/runtime.cc
gcc/go/gofrontend/runtime.def
gcc/go/gofrontend/types.cc
libgo/go/bytes/indexbyte.c
libgo/go/syscall/signame.c
libgo/runtime/array.h
libgo/runtime/go-append.c
libgo/runtime/go-assert-interface.c
libgo/runtime/go-byte-array-to-string.c
libgo/runtime/go-caller.c
libgo/runtime/go-callers.c
libgo/runtime/go-can-convert-interface.c
libgo/runtime/go-cgo.c
libgo/runtime/go-check-interface.c
libgo/runtime/go-construct-map.c
libgo/runtime/go-convert-interface.c
libgo/runtime/go-eface-compare.c
libgo/runtime/go-eface-val-compare.c
libgo/runtime/go-getgoroot.c
libgo/runtime/go-int-array-to-string.c
libgo/runtime/go-int-to-string.c
libgo/runtime/go-interface-compare.c
libgo/runtime/go-interface-eface-compare.c
libgo/runtime/go-interface-val-compare.c
libgo/runtime/go-main.c
libgo/runtime/go-make-slice.c
libgo/runtime/go-map-len.c
libgo/runtime/go-map-range.c
libgo/runtime/go-new-map.c
libgo/runtime/go-panic.c
libgo/runtime/go-panic.h
libgo/runtime/go-print.c
libgo/runtime/go-reflect-call.c
libgo/runtime/go-rune.c
libgo/runtime/go-runtime-error.c
libgo/runtime/go-setenv.c
libgo/runtime/go-strcmp.c
libgo/runtime/go-string-to-byte-array.c
libgo/runtime/go-string-to-int-array.c
libgo/runtime/go-string.h
libgo/runtime/go-strplus.c
libgo/runtime/go-strslice.c
libgo/runtime/go-traceback.c
libgo/runtime/go-type-identity.c
libgo/runtime/go-type-interface.c
libgo/runtime/go-type-string.c
libgo/runtime/go-type.h
libgo/runtime/go-typedesc-equal.c
libgo/runtime/go-typestring.c
libgo/runtime/go-unsafe-pointer.c
libgo/runtime/interface.h
libgo/runtime/malloc.goc
libgo/runtime/panic.c
libgo/runtime/print.c
libgo/runtime/proc.c
libgo/runtime/reflect.goc
libgo/runtime/runtime.c
libgo/runtime/runtime.h
libgo/runtime/string.goc

index eef7ea7c25ecfd70792f4c0fdce923467a0e6b95..8fe61462aee71043a38f544a0d30f098e5dc3af1 100644 (file)
@@ -1832,11 +1832,9 @@ Integer_expression::do_get_tree(Translate_context* context)
       // some reason.  Use a type which will fit the value.  We use <,
       // not <=, because we need an extra bit for the sign bit.
       int bits = mpz_sizeinbase(this->val_, 2);
-      if (bits < INT_TYPE_SIZE)
-       {
-         Type* t = Type::lookup_integer_type("int");
-         type = type_to_tree(t->get_backend(gogo));
-       }
+      Type* int_type = Type::lookup_integer_type("int");
+      if (bits < int_type->integer_type()->bits())
+       type = type_to_tree(int_type->get_backend(gogo));
       else if (bits < 64)
        {
          Type* t = Type::lookup_integer_type("int64");
@@ -3146,7 +3144,10 @@ Type_conversion_expression::do_get_tree(Translate_context* context)
   else if (type->is_string_type()
           && expr_type->integer_type() != NULL)
     {
-      expr_tree = fold_convert(integer_type_node, expr_tree);
+      Type* int_type = Type::lookup_integer_type("int");
+      tree int_type_tree = type_to_tree(int_type->get_backend(gogo));
+
+      expr_tree = fold_convert(int_type_tree, expr_tree);
       if (host_integerp(expr_tree, 0))
        {
          HOST_WIDE_INT intval = tree_low_cst(expr_tree, 0);
@@ -3162,20 +3163,24 @@ Type_conversion_expression::do_get_tree(Translate_context* context)
                               "__go_int_to_string",
                               1,
                               type_tree,
-                              integer_type_node,
-                              fold_convert(integer_type_node, expr_tree));
+                              int_type_tree,
+                              expr_tree);
     }
   else if (type->is_string_type() && expr_type->is_slice_type())
     {
       if (!DECL_P(expr_tree))
        expr_tree = save_expr(expr_tree);
+
+      Type* int_type = Type::lookup_integer_type("int");
+      tree int_type_tree = type_to_tree(int_type->get_backend(gogo));
+
       Array_type* a = expr_type->array_type();
       Type* e = a->element_type()->forwarded();
       go_assert(e->integer_type() != NULL);
       tree valptr = fold_convert(const_ptr_type_node,
                                 a->value_pointer_tree(gogo, expr_tree));
       tree len = a->length_tree(gogo, expr_tree);
-      len = fold_convert_loc(this->location().gcc_location(), integer_type_node,
+      len = fold_convert_loc(this->location().gcc_location(), int_type_tree,
                              len);
       if (e->integer_type()->is_byte())
        {
@@ -3187,7 +3192,7 @@ Type_conversion_expression::do_get_tree(Translate_context* context)
                                   type_tree,
                                   const_ptr_type_node,
                                   valptr,
-                                  integer_type_node,
+                                  int_type_tree,
                                   len);
        }
       else
@@ -3201,7 +3206,7 @@ Type_conversion_expression::do_get_tree(Translate_context* context)
                                   type_tree,
                                   const_ptr_type_node,
                                   valptr,
-                                  integer_type_node,
+                                  int_type_tree,
                                   len);
        }
     }
@@ -3939,6 +3944,7 @@ Unary_expression::do_check_types(Gogo*)
 tree
 Unary_expression::do_get_tree(Translate_context* context)
 {
+  Gogo* gogo = context->gogo();
   Location loc = this->location();
 
   // Taking the address of a set-and-use-temporary expression requires
@@ -4103,7 +4109,7 @@ Unary_expression::do_get_tree(Translate_context* context)
                                               expr,
                                               fold_convert(TREE_TYPE(expr),
                                                            null_pointer_node));
-               tree crash = Gogo::runtime_error(RUNTIME_ERROR_NIL_DEREFERENCE,
+               tree crash = gogo->runtime_error(RUNTIME_ERROR_NIL_DEREFERENCE,
                                                 loc);
                expr = fold_build2_loc(loc.gcc_location(), COMPOUND_EXPR,
                                       TREE_TYPE(expr), build3(COND_EXPR,
@@ -4119,7 +4125,7 @@ Unary_expression::do_get_tree(Translate_context* context)
        if (VOID_TYPE_P(target_type_tree))
          {
            Type* pt = this->expr_->type()->points_to();
-           tree ind = type_to_tree(pt->get_backend(context->gogo()));
+           tree ind = type_to_tree(pt->get_backend(gogo));
            expr = fold_convert_loc(loc.gcc_location(),
                                     build_pointer_type(ind), expr);
          }
@@ -5668,6 +5674,8 @@ Binary_expression::do_check_types(Gogo*)
 tree
 Binary_expression::do_get_tree(Translate_context* context)
 {
+  Gogo* gogo = context->gogo();
+
   tree left = this->left_->get_tree(context);
   tree right = this->right_->get_tree(context);
 
@@ -5756,7 +5764,7 @@ Binary_expression::do_get_tree(Translate_context* context)
     {
       go_assert(this->op_ == OPERATOR_PLUS);
       Type* st = Type::make_string_type();
-      tree string_type = type_to_tree(st->get_backend(context->gogo()));
+      tree string_type = type_to_tree(st->get_backend(gogo));
       static tree string_plus_decl;
       return Gogo::call_builtin(&string_plus_decl,
                                this->location(),
@@ -5859,7 +5867,7 @@ Binary_expression::do_get_tree(Translate_context* context)
          // __go_runtime_error(RUNTIME_ERROR_DIVISION_BY_ZERO), 0
          int errcode = RUNTIME_ERROR_DIVISION_BY_ZERO;
          tree panic = fold_build2_loc(gccloc, COMPOUND_EXPR, TREE_TYPE(ret),
-                                      Gogo::runtime_error(errcode,
+                                      gogo->runtime_error(errcode,
                                                           this->location()),
                                       fold_convert_loc(gccloc, TREE_TYPE(ret),
                                                        integer_zero_node));
@@ -6152,6 +6160,9 @@ Expression::comparison_tree(Translate_context* context, Type* result_type,
                            Type* right_type, tree right_tree,
                            Location location)
 {
+  Type* int_type = Type::lookup_integer_type("int");
+  tree int_type_tree = type_to_tree(int_type->get_backend(context->gogo()));
+
   enum tree_code code;
   switch (op)
     {
@@ -6186,12 +6197,12 @@ Expression::comparison_tree(Translate_context* context, Type* result_type,
                                     location,
                                     "__go_strcmp",
                                     2,
-                                    integer_type_node,
+                                    int_type_tree,
                                     string_type,
                                     left_tree,
                                     string_type,
                                     right_tree);
-      right_tree = build_int_cst_type(integer_type_node, 0);
+      right_tree = build_int_cst_type(int_type_tree, 0);
     }
   else if ((left_type->interface_type() != NULL
            && right_type->interface_type() == NULL
@@ -6248,7 +6259,7 @@ Expression::comparison_tree(Translate_context* context, Type* result_type,
                                         location,
                                         "__go_empty_interface_value_compare",
                                         3,
-                                        integer_type_node,
+                                        int_type_tree,
                                         TREE_TYPE(left_tree),
                                         left_tree,
                                         TREE_TYPE(descriptor),
@@ -6267,7 +6278,7 @@ Expression::comparison_tree(Translate_context* context, Type* result_type,
                                         location,
                                         "__go_interface_value_compare",
                                         3,
-                                        integer_type_node,
+                                        int_type_tree,
                                         TREE_TYPE(left_tree),
                                         left_tree,
                                         TREE_TYPE(descriptor),
@@ -6279,7 +6290,7 @@ Expression::comparison_tree(Translate_context* context, Type* result_type,
          // This can panic if the type is not comparable.
          TREE_NOTHROW(interface_value_compare_decl) = 0;
        }
-      right_tree = build_int_cst_type(integer_type_node, 0);
+      right_tree = build_int_cst_type(int_type_tree, 0);
 
       if (make_tmp != NULL_TREE)
        left_tree = build2(COMPOUND_EXPR, TREE_TYPE(left_tree), make_tmp,
@@ -6296,7 +6307,7 @@ Expression::comparison_tree(Translate_context* context, Type* result_type,
                                         location,
                                         "__go_empty_interface_compare",
                                         2,
-                                        integer_type_node,
+                                        int_type_tree,
                                         TREE_TYPE(left_tree),
                                         left_tree,
                                         TREE_TYPE(right_tree),
@@ -6314,7 +6325,7 @@ Expression::comparison_tree(Translate_context* context, Type* result_type,
                                         location,
                                         "__go_interface_compare",
                                         2,
-                                        integer_type_node,
+                                        int_type_tree,
                                         TREE_TYPE(left_tree),
                                         left_tree,
                                         TREE_TYPE(right_tree),
@@ -6339,7 +6350,7 @@ Expression::comparison_tree(Translate_context* context, Type* result_type,
                                         location,
                                         "__go_interface_empty_compare",
                                         2,
-                                        integer_type_node,
+                                        int_type_tree,
                                         TREE_TYPE(left_tree),
                                         left_tree,
                                         TREE_TYPE(right_tree),
@@ -6350,7 +6361,7 @@ Expression::comparison_tree(Translate_context* context, Type* result_type,
          TREE_NOTHROW(interface_empty_compare_decl) = 0;
        }
 
-      right_tree = build_int_cst_type(integer_type_node, 0);
+      right_tree = build_int_cst_type(int_type_tree, 0);
     }
 
   if (left_type->is_nil_type()
@@ -7869,6 +7880,9 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
            arg_tree = build_fold_indirect_ref(arg_tree);
          }
 
+       Type* int_type = Type::lookup_integer_type("int");
+       tree int_type_tree = type_to_tree(int_type->get_backend(gogo));
+
        tree val_tree;
        if (this->code_ == BUILTIN_LEN)
          {
@@ -7893,7 +7907,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
                                              location,
                                              "__go_map_len",
                                              1,
-                                             integer_type_node,
+                                             int_type_tree,
                                              arg_type_tree,
                                              arg_tree);
              }
@@ -7905,7 +7919,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
                                              location,
                                              "__go_chan_len",
                                              1,
-                                             integer_type_node,
+                                             int_type_tree,
                                              arg_type_tree,
                                              arg_tree);
              }
@@ -7934,7 +7948,7 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
                                              location,
                                              "__go_chan_cap",
                                              1,
-                                             integer_type_node,
+                                             int_type_tree,
                                              arg_type_tree,
                                              arg_tree);
              }
@@ -7942,15 +7956,8 @@ Builtin_call_expression::do_get_tree(Translate_context* context)
              go_unreachable();
          }
 
-       if (val_tree == error_mark_node)
-         return error_mark_node;
-
-       Type* int_type = Type::lookup_integer_type("int");
-       tree type_tree = type_to_tree(int_type->get_backend(gogo));
-       if (type_tree == TREE_TYPE(val_tree))
-         return val_tree;
-       else
-         return fold(convert_to_integer(type_tree, val_tree));
+       return fold_convert_loc(location.gcc_location(), int_type_tree,
+                               val_tree);
       }
 
     case BUILTIN_PRINT:
@@ -9872,7 +9879,7 @@ Array_index_expression::do_get_tree(Translate_context* context)
              : (this->end_ == NULL
                 ? RUNTIME_ERROR_SLICE_INDEX_OUT_OF_BOUNDS
                 : RUNTIME_ERROR_SLICE_SLICE_OUT_OF_BOUNDS));
-  tree crash = Gogo::runtime_error(code, loc);
+  tree crash = gogo->runtime_error(code, loc);
 
   if (this->end_ == NULL)
     {
@@ -10185,7 +10192,9 @@ String_index_expression::do_get_tree(Translate_context* context)
 
   tree length_tree = String_type::length_tree(context->gogo(), string_tree);
   length_tree = save_expr(length_tree);
-  tree length_type = TREE_TYPE(length_tree);
+
+  Type* int_type = Type::lookup_integer_type("int");
+  tree length_type = type_to_tree(int_type->get_backend(context->gogo()));
 
   tree bad_index = boolean_false_node;
 
@@ -10205,7 +10214,7 @@ String_index_expression::do_get_tree(Translate_context* context)
   int code = (this->end_ == NULL
              ? RUNTIME_ERROR_STRING_INDEX_OUT_OF_BOUNDS
              : RUNTIME_ERROR_STRING_SLICE_OUT_OF_BOUNDS);
-  tree crash = Gogo::runtime_error(code, loc);
+  tree crash = context->gogo()->runtime_error(code, loc);
 
   if (this->end_ == NULL)
     {
index 0d1746f1c15e753a4e7572c20eeaeb525653ea0a..2b0c26f9bc10f6775c3916c38996ac4100866661 100644 (file)
@@ -2331,14 +2331,17 @@ Gogo::call_builtin(tree* pdecl, Location location, const char* name,
 tree
 Gogo::runtime_error(int code, Location location)
 {
+  Type* int32_type = Type::lookup_integer_type("int32");
+  tree int32_type_tree = type_to_tree(int32_type->get_backend(this));
+
   static tree runtime_error_fndecl;
   tree ret = Gogo::call_builtin(&runtime_error_fndecl,
                                location,
                                "__go_runtime_error",
                                1,
                                void_type_node,
-                               integer_type_node,
-                               build_int_cst(integer_type_node, code));
+                               int32_type_tree,
+                               build_int_cst(int32_type_tree, code));
   if (ret == error_mark_node)
     return error_mark_node;
   // The runtime error function panics and does not return.
index cc707ad2ddeec9d65561463f0b8dddfc1f15f71d..8759d32b6c9c73df5d15d15906bf301646d9934d 100644 (file)
@@ -558,7 +558,7 @@ class Gogo
               tree rettype, ...);
 
   // Build a call to the runtime error function.
-  static tree
+  tree
   runtime_error(int code, Location);
 
   // Build a builtin struct with a list of fields.
index 3da2f3dae264abb32253995de772d39c34ecc91b..059263db44e276a541751a54816773570fa5574a 100644 (file)
@@ -30,7 +30,7 @@ enum Runtime_function_type
   RFT_BOOL,
   // Go type *bool, C type _Bool*.
   RFT_BOOLPTR,
-  // Go type int, C type int.
+  // Go type int, C type intgo.
   RFT_INT,
   // Go type int32, C type int32_t.
   RFT_INT32,
index b9492dc8af2a18531b7a6efb34545529e6a82530..fc720cd9c094929c896c163724bfb975162e6bb0 100644 (file)
@@ -198,7 +198,7 @@ DEF_GO_RUNTIME(CHECK_DEFER, "__go_check_defer", P1(BOOLPTR), R0())
 DEF_GO_RUNTIME(UNDEFER, "__go_undefer", P1(BOOLPTR), R0())
 
 // Panic with a runtime error.
-DEF_GO_RUNTIME(RUNTIME_ERROR, "__go_runtime_error", P1(INT), R0())
+DEF_GO_RUNTIME(RUNTIME_ERROR, "__go_runtime_error", P1(INT32), R0())
 
 
 // Close.
index 1736a32654d657acdf821e5c9e5c34993eff2a25..8a9f7d15df7233d3cd3ecf885d7ca395ab04d3f2 100644 (file)
@@ -2985,7 +2985,7 @@ String_type::length_tree(Gogo*, tree string)
   tree length_field = DECL_CHAIN(TYPE_FIELDS(string_type));
   go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(length_field)),
                    "__length") == 0);
-  return fold_build3(COMPONENT_REF, integer_type_node, string,
+  return fold_build3(COMPONENT_REF, TREE_TYPE(length_field), string,
                     length_field, NULL_TREE);
 }
 
@@ -5524,7 +5524,9 @@ Array_type::get_length_tree(Gogo* gogo)
          tree len = this->length_->get_tree(&context);
          if (len != error_mark_node)
            {
-             len = convert_to_integer(integer_type_node, len);
+             Type* int_type = Type::lookup_integer_type("int");
+             tree int_type_tree = type_to_tree(int_type->get_backend(gogo));
+             len = convert_to_integer(int_type_tree, len);
              len = save_expr(len);
            }
          this->length_tree_ = len;
@@ -5663,10 +5665,12 @@ Array_type::length_tree(Gogo* gogo, tree array)
   if (this->length_ != NULL)
     {
       if (TREE_CODE(array) == SAVE_EXPR)
-       return fold_convert(integer_type_node, this->get_length_tree(gogo));
+       return this->get_length_tree(gogo);
       else
-       return omit_one_operand(integer_type_node,
-                               this->get_length_tree(gogo), array);
+       {
+         tree len = this->get_length_tree(gogo);
+         return omit_one_operand(TREE_TYPE(len), len, array);
+       }
     }
 
   // This is an open array.  We need to read the length field.
@@ -5690,8 +5694,10 @@ tree
 Array_type::capacity_tree(Gogo* gogo, tree array)
 {
   if (this->length_ != NULL)
-    return omit_one_operand(integer_type_node, this->get_length_tree(gogo),
-                           array);
+    {
+      tree len = this->get_length_tree(gogo);
+      return omit_one_operand(TREE_TYPE(len), len, array);
+    }
 
   // This is an open array.  We need to read the capacity field.
 
index 8986d1056e05a0647d7289d91daaf72abdeb7a52..9c72e611a80f02821ab55f5e2654c2fa9a1375bd 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <stddef.h>
 
+#include "runtime.h"
 #include "array.h"
 
 /* This is in C so that the compiler can optimize it appropriately.
index 63422889c3345a50c50c9d79d36871b16a560023..5ff0b09dbb7bfa54356ad44c4fc103229124cc32 100644 (file)
@@ -6,7 +6,6 @@
 
 #include <string.h>
 
-#include "config.h"
 #include "runtime.h"
 #include "arch.h"
 #include "malloc.h"
@@ -19,7 +18,7 @@ Signame (int sig)
   const char* s = NULL;
   char buf[100];
   size_t len;
-  unsigned char *data;
+  byte *data;
   String ret;
 
 #if defined(HAVE_STRSIGNAL)
@@ -34,7 +33,7 @@ Signame (int sig)
   len = __builtin_strlen (s);
   data = runtime_mallocgc (len, FlagNoPointers, 0, 0);
   __builtin_memcpy (data, s, len);
-  ret.__data = data;
-  ret.__length = len;
+  ret.str = data;
+  ret.len = len;
   return ret;
 }
index f6d0261dff95d96beaafe4695438a83fe51a7d55..14a9bb48ff0ae68e92ac069f4decc4220e81f8c9 100644 (file)
@@ -19,10 +19,10 @@ struct __go_open_array
      enough to hold the size of any allocated object.  Using "int"
      saves 8 bytes per slice header on a 64-bit system with 32-bit
      ints.  */
-  int __count;
+  intgo __count;
   /* The capacity of the array--the number of elements that can fit in
      the __VALUES field.  */
-  int __capacity;
+  intgo __capacity;
 };
 
 #endif /* !defined(LIBGO_ARRAY_H) */
index dac4c902c154de5078cf9cb8c6df2cb90b66eeb5..12fe876cb95e7b3a5b92018434c5c289f975686a 100644 (file)
@@ -4,10 +4,10 @@
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.  */
 
-#include "go-type.h"
+#include "runtime.h"
 #include "go-panic.h"
+#include "go-type.h"
 #include "array.h"
-#include "runtime.h"
 #include "arch.h"
 #include "malloc.h"
 
index 94bdaeef42983a8ebbd2b28f0cb23899b92bfc8a..2510f9aef8b797f02a9341a319e6e2da4f2efc03 100644 (file)
@@ -4,11 +4,12 @@
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.  */
 
+#include "runtime.h"
 #include "go-alloc.h"
 #include "go-assert.h"
 #include "go-panic.h"
+#include "go-type.h"
 #include "interface.h"
-#include "runtime.h"
 
 /* This is called by the compiler to implement a type assertion from
    one interface type to another.  This returns the value that should
index cfe190612121dbde9107cc98997d7a3cfb92377a..0cd63c76d8d1bace684013f0c9c4995de3608ee2 100644 (file)
@@ -4,22 +4,21 @@
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.  */
 
-#include "go-string.h"
 #include "runtime.h"
 #include "arch.h"
 #include "malloc.h"
 
-struct __go_string
-__go_byte_array_to_string (const void* p, int len)
+String
+__go_byte_array_to_string (const void* p, intgo len)
 {
   const unsigned char *bytes;
   unsigned char *retdata;
-  struct __go_string ret;
+  String ret;
 
   bytes = (const unsigned char *) p;
-  retdata = runtime_mallocgc (len, FlagNoPointers, 1, 0);
+  retdata = runtime_mallocgc ((uintptr) len, FlagNoPointers, 1, 0);
   __builtin_memcpy (retdata, bytes, len);
-  ret.__data = retdata;
-  ret.__length = len;
+  ret.str = retdata;
+  ret.len = len;
   return ret;
 }
index 8dcf9e4bee9c0d54f2efbba5d8182f3b61c0fff0..d73a408334f51feb91450247c3accfed33e9646d 100644 (file)
@@ -11,7 +11,6 @@
 #include "backtrace.h"
 
 #include "runtime.h"
-#include "go-string.h"
 
 /* Get the function name, file name, and line number for a PC value.
    We use the backtrace library to get this.  */
@@ -20,9 +19,9 @@
 
 struct caller
 {
-  struct __go_string fn;
-  struct __go_string file;
-  int line;
+  String fn;
+  String file;
+  intgo line;
 };
 
 /* Collect file/line information for a PC value.  If this is called
@@ -37,32 +36,32 @@ callback (void *data, uintptr_t pc __attribute__ ((unused)),
 
   if (function == NULL)
     {
-      c->fn.__data = NULL;
-      c->fn.__length = 0;
+      c->fn.str = NULL;
+      c->fn.len = 0;
     }
   else
     {
-      char *s;
+      byte *s;
 
-      c->fn.__length = __builtin_strlen (function);
-      s = runtime_malloc (c->fn.__length);
-      __builtin_memcpy (s, function, c->fn.__length);
-      c->fn.__data = (unsigned char *) s;
+      c->fn.len = __builtin_strlen (function);
+      s = runtime_malloc (c->fn.len);
+      __builtin_memcpy (s, function, c->fn.len);
+      c->fn.str = s;
     }
 
   if (filename == NULL)
     {
-      c->file.__data = NULL;
-      c->file.__length = 0;
+      c->file.str = NULL;
+      c->file.len = 0;
     }
   else
     {
-      char *s;
+      byte *s;
 
-      c->file.__length = __builtin_strlen (filename);
-      s = runtime_malloc (c->file.__length);
-      __builtin_memcpy (s, filename, c->file.__length);
-      c->file.__data = (unsigned char *) s;
+      c->file.len = __builtin_strlen (filename);
+      s = runtime_malloc (c->file.len);
+      __builtin_memcpy (s, filename, c->file.len);
+      c->file.str = s;
     }
 
   c->line = lineno;
@@ -111,8 +110,7 @@ __go_get_backtrace_state ()
 /* Return function/file/line information for PC.  */
 
 _Bool
-__go_file_line (uintptr pc, struct __go_string *fn, struct __go_string *file,
-               int *line)
+__go_file_line (uintptr pc, String *fn, String *file, intgo *line)
 {
   struct caller c;
 
@@ -122,7 +120,7 @@ __go_file_line (uintptr pc, struct __go_string *fn, struct __go_string *file,
   *fn = c.fn;
   *file = c.file;
   *line = c.line;
-  return c.file.__length > 0;
+  return c.file.len > 0;
 }
 
 /* Collect symbol information.  */
@@ -153,8 +151,8 @@ __go_symbol_value (uintptr_t pc, uintptr_t *val)
 struct caller_ret
 {
   uintptr_t pc;
-  struct __go_string file;
-  int line;
+  String file;
+  intgo line;
   _Bool ok;
 };
 
@@ -170,7 +168,7 @@ Caller (int skip)
   struct caller_ret ret;
   uintptr pc;
   int32 n;
-  struct __go_string fn;
+  String fn;
 
   runtime_memclr (&ret, sizeof ret);
   n = runtime_callers (skip + 1, &pc, 1);
@@ -188,9 +186,9 @@ Func *
 FuncForPC (uintptr_t pc)
 {
   Func *ret;
-  struct __go_string fn;
-  struct __go_string file;
-  int line;
+  String fn;
+  String file;
+  intgo line;
   uintptr_t val;
 
   if (!__go_file_line (pc, &fn, &file, &line))
@@ -212,8 +210,8 @@ FuncForPC (uintptr_t pc)
 
 struct funcline_go_return
 {
-  struct __go_string retfile;
-  int retline;
+  String retfile;
+  intgo retline;
 };
 
 struct funcline_go_return
@@ -224,7 +222,7 @@ struct funcline_go_return
 runtime_funcline_go (Func *f __attribute__((unused)), uintptr targetpc)
 {
   struct funcline_go_return ret;
-  struct __go_string fn;
+  String fn;
 
   if (!__go_file_line (targetpc, &fn, &ret.retfile,  &ret.retline))
     runtime_memclr (&ret, sizeof ret);
index 71d69f6ad5d1434e8152fbe99fbf354d5940b362..1dd3e71c8efda563c7b434f5705cb69a4e0d9909 100644 (file)
@@ -9,6 +9,7 @@
 #include "backtrace.h"
 
 #include "runtime.h"
+#include "array.h"
 
 /* Argument passed to callback function.  */
 
index 83217ab95b3a649570e64f695ffcdb64cd8ad6d9..4de558077a7bc4fbdbee88f26465078915911f84 100644 (file)
@@ -4,7 +4,9 @@
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.  */
 
+#include "runtime.h"
 #include "go-assert.h"
+#include "go-string.h"
 #include "go-type.h"
 #include "interface.h"
 
index 173696e737d7af9f5e02976f55e612632eea51e8..d0c89f29459ae729494f34f1b3299a10c5083d48 100644 (file)
@@ -8,7 +8,6 @@
 #include "go-alloc.h"
 #include "interface.h"
 #include "go-panic.h"
-#include "go-string.h"
 
 /* Go memory allocated by code not written in Go.  We keep a linked
    list of these allocations so that the garbage collector can see
@@ -135,9 +134,9 @@ extern const struct __go_type_descriptor string_type_descriptor
 void
 _cgo_panic (const char *p)
 {
-  int len;
+  intgo len;
   unsigned char *data;
-  struct __go_string *ps;
+  String *ps;
   struct __go_empty_interface e;
 
   runtime_exitsyscall ();
@@ -145,8 +144,8 @@ _cgo_panic (const char *p)
   data = alloc_saved (len);
   __builtin_memcpy (data, p, len);
   ps = alloc_saved (sizeof *ps);
-  ps->__data = data;
-  ps->__length = len;
+  ps->str = data;
+  ps->len = len;
   e.__type_descriptor = &string_type_descriptor;
   e.__object = ps;
 
index 963559d8ed0737f28722827fee49dc3840633cc5..c29971adac283dcf1c30321ffa9f2881cd474f62 100644 (file)
@@ -4,9 +4,10 @@
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.  */
 
+#include "runtime.h"
 #include "go-panic.h"
+#include "go-type.h"
 #include "interface.h"
-#include "runtime.h"
 
 /* Check that an interface type matches for a conversion to a
    non-interface type.  This panics if the types are bad.  The actual
index 5e459d07ac4b63f251f75f8bd79e01ac044703d9..4bd79d2005887b1c9032adfc305e215a11e398d9 100644 (file)
@@ -8,6 +8,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 
+#include "runtime.h"
 #include "map.h"
 
 struct __go_map *
index 8ce82ea5ed617930e701aaf18ce6148132d6dd75..3eee6bf4a8fd7ded8ab464e4b363db130c6d0e6c 100644 (file)
@@ -4,11 +4,13 @@
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.  */
 
+#include "runtime.h"
 #include "go-alloc.h"
 #include "go-assert.h"
 #include "go-panic.h"
+#include "go-string.h"
+#include "go-type.h"
 #include "interface.h"
-#include "runtime.h"
 
 /* This is called when converting one interface type into another
    interface type.  LHS_DESCRIPTOR is the type descriptor of the
index d88d50569c24e7c3813bd9072d9052083fde9c80..e738efced80a6bb2b31721894ba7ad70e696404e 100644 (file)
@@ -5,12 +5,13 @@
    license that can be found in the LICENSE file.  */
 
 #include "runtime.h"
+#include "go-type.h"
 #include "interface.h"
 
 /* Compare two interface values.  Return 0 for equal, not zero for not
    equal (return value is like strcmp).  */
 
-int
+intgo
 __go_empty_interface_compare (struct __go_empty_interface left,
                              struct __go_empty_interface right)
 {
index fed3fdb4432a1e8c026eb5a9b9aab12e483a7c38..454ea3ebae9fe197dc5e14c0b97932a9ece3a07a 100644 (file)
@@ -11,7 +11,7 @@
 /* Compare an empty interface with a value.  Return 0 for equal, not
    zero for not equal (return value is like strcmp).  */
 
-int
+intgo
 __go_empty_interface_value_compare (
     struct __go_empty_interface left,
     const struct __go_type_descriptor *right_descriptor,
index 1db4afe30a96d15efdd1ed1c886a2a14e84d5f98..3cb447e4ce886b3ad1d4d487543b2f686f2e1bde 100644 (file)
@@ -6,21 +6,21 @@
 
 #include <stdlib.h>
 
-#include "go-string.h"
+#include "runtime.h"
 
-struct __go_string getgoroot (void) asm ("runtime.getgoroot");
+String getgoroot (void) asm ("runtime.getgoroot");
 
-struct __go_string
+String
 getgoroot ()
 {
   const char *p;
-  struct __go_string ret;
+  String ret;
 
   p = getenv ("GOROOT");
-  ret.__data = (const unsigned char *) p;
-  if (ret.__data == NULL)
-    ret.__length = 0;
+  ret.str = (const byte *) p;
+  if (ret.str == NULL)
+    ret.len = 0;
   else
-    ret.__length = __builtin_strlen (p);
+    ret.len = __builtin_strlen (p);
   return ret;
 }
index 1a37879f312c47642093d7d66a2efd1045b1892f..6cae2fd8ccbe335f19f7c44ca0cfddbf3362ad03 100644 (file)
@@ -5,31 +5,30 @@
    license that can be found in the LICENSE file.  */
 
 #include "go-assert.h"
-#include "go-string.h"
 #include "runtime.h"
 #include "arch.h"
 #include "malloc.h"
 
-struct __go_string
-__go_int_array_to_string (const void* p, int len)
+String
+__go_int_array_to_string (const void* p, intgo len)
 {
-  const int *ints;
-  int slen;
-  int i;
+  const int32 *ints;
+  intgo slen;
+  intgo i;
   unsigned char *retdata;
-  struct __go_string ret;
+  String ret;
   unsigned char *s;
 
-  ints = (const int *) p;
+  ints = (const int32 *) p;
 
   slen = 0;
   for (i = 0; i < len; ++i)
     {
-      int v;
+      int32 v;
 
       v = ints[i];
 
-      if (v > 0x10ffff)
+      if (v < 0 || v > 0x10ffff)
        v = 0xfffd;
 
       if (v <= 0x7f)
@@ -42,20 +41,20 @@ __go_int_array_to_string (const void* p, int len)
        slen += 4;
     }
 
-  retdata = runtime_mallocgc (slen, FlagNoPointers, 1, 0);
-  ret.__data = retdata;
-  ret.__length = slen;
+  retdata = runtime_mallocgc ((uintptr) slen, FlagNoPointers, 1, 0);
+  ret.str = retdata;
+  ret.len = slen;
 
   s = retdata;
   for (i = 0; i < len; ++i)
     {
-      int v;
+      int32 v;
 
       v = ints[i];
 
       /* If V is out of range for UTF-8, substitute the replacement
         character.  */
-      if (v > 0x10ffff)
+      if (v < 0 || v > 0x10ffff)
        v = 0xfffd;
 
       if (v <= 0x7f)
index 17a5fcb04c011f14410a10ad543ad3769d4e53e4..eb441674b6c5c42fc9c0de71efc5e3e7df032564 100644 (file)
@@ -4,18 +4,17 @@
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.  */
 
-#include "go-string.h"
 #include "runtime.h"
 #include "arch.h"
 #include "malloc.h"
 
-struct __go_string
-__go_int_to_string (int v)
+String
+__go_int_to_string (intgo v)
 {
   char buf[4];
   int len;
   unsigned char *retdata;
-  struct __go_string ret;
+  String ret;
 
   /* A negative value is not valid UTF-8; turn it into the replacement
      character.  */
@@ -63,8 +62,8 @@ __go_int_to_string (int v)
 
   retdata = runtime_mallocgc (len, FlagNoPointers, 1, 0);
   __builtin_memcpy (retdata, buf, len);
-  ret.__data = retdata;
-  ret.__length = len;
+  ret.str = retdata;
+  ret.len = len;
 
   return ret;
 }
index 11c75e812ce5517526f104c6aff3c8902f66d79f..6374bd2fb428d72cec873939c234f4d7ac0ab8dd 100644 (file)
@@ -4,6 +4,10 @@
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.  */
 
+#include <stddef.h>
+
+#include "runtime.h"
+#include "go-type.h"
 #include "interface.h"
 
 /* Compare two interface values.  Return 0 for equal, not zero for not
index db03b914c8443dad34d68454ce335595f8dd8423..bb81ff813a607a50919bc456370d404a2f359483 100644 (file)
@@ -5,13 +5,14 @@
    license that can be found in the LICENSE file.  */
 
 #include "runtime.h"
+#include "go-type.h"
 #include "interface.h"
 
 /* Compare a non-empty interface value with an empty interface value.
    Return 0 for equal, not zero for not equal (return value is like
    strcmp).  */
 
-int
+intgo
 __go_interface_empty_compare (struct __go_interface left,
                              struct __go_empty_interface right)
 {
index 15898924ac863545c1cc09638843a47f01e1f977..e2dae6a1892b395f0c63c4860fa43f9456ea1dc3 100644 (file)
@@ -4,13 +4,14 @@
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.  */
 
+#include "runtime.h"
 #include "go-type.h"
 #include "interface.h"
 
 /* Compare two interface values.  Return 0 for equal, not zero for not
    equal (return value is like strcmp).  */
 
-int
+intgo
 __go_interface_value_compare (
     struct __go_interface left,
     const struct __go_type_descriptor *right_descriptor,
index 7e8bb9b234f2ea6f664f98e2dd2057bcb6463954..97d140583502797eb8a9f9b47a2ab2e2070d59c8 100644 (file)
 #include <fpu_control.h>
 #endif
 
+#include "runtime.h"
 #include "go-alloc.h"
 #include "array.h"
-#include "go-string.h"
-
-#include "runtime.h"
 #include "arch.h"
 #include "malloc.h"
 
index 822c9b68f0a43873b1c7f9609a8ba1e8b3deb846..242c9bb72686bfd56ecc70563fadd01b051e66ef 100644 (file)
@@ -6,12 +6,12 @@
 
 #include <stdint.h>
 
+#include "runtime.h"
 #include "go-alloc.h"
 #include "go-assert.h"
 #include "go-panic.h"
 #include "go-type.h"
 #include "array.h"
-#include "runtime.h"
 #include "arch.h"
 #include "malloc.h"
 
@@ -20,8 +20,8 @@ __go_make_slice2 (const struct __go_type_descriptor *td, uintptr_t len,
                  uintptr_t cap)
 {
   const struct __go_slice_type* std;
-  int ilen;
-  int icap;
+  intgo ilen;
+  intgo icap;
   uintptr_t size;
   struct __go_open_array ret;
   unsigned int flag;
@@ -29,11 +29,11 @@ __go_make_slice2 (const struct __go_type_descriptor *td, uintptr_t len,
   __go_assert (td->__code == GO_SLICE);
   std = (const struct __go_slice_type *) td;
 
-  ilen = (int) len;
+  ilen = (intgo) len;
   if (ilen < 0 || (uintptr_t) ilen != len)
     runtime_panicstring ("makeslice: len out of range");
 
-  icap = (int) cap;
+  icap = (intgo) cap;
   if (cap < len
       || (uintptr_t) icap != cap
       || (std->__element_type->__size > 0
index a8922b9f007f9190fdbbf1acb70b00d2e1901d11..7da10c249437216aa3950f0febb31c38ac9b437a 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <stddef.h>
 
+#include "runtime.h"
 #include "go-assert.h"
 #include "map.h"
 
    but I'm doing it as a function for now to make it easy to change
    the map structure.  */
 
-int
+intgo
 __go_map_len (struct __go_map *map)
 {
   if (map == NULL)
     return 0;
-  __go_assert (map->__element_count == (uintptr_t) (int) map->__element_count);
+  __go_assert (map->__element_count
+              == (uintptr_t) (intgo) map->__element_count);
   return map->__element_count;
 }
index 54444bc21048dfdb50c75de9e65a5a6a134815c5..5dbb92ccb89aade9ed3ac11c6a13836b89ec3de2 100644 (file)
@@ -4,6 +4,7 @@
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.  */
 
+#include "runtime.h"
 #include "go-assert.h"
 #include "map.h"
 
index 644661839248098f833239baf6fb9ed4c009cf59..096856e234c90d4cf45fbcd191500f4cb675dedf 100644 (file)
@@ -106,10 +106,10 @@ __go_map_next_prime (uintptr_t n)
 struct __go_map *
 __go_new_map (const struct __go_map_descriptor *descriptor, uintptr_t entries)
 {
-  int ientries;
+  intgo ientries;
   struct __go_map *ret;
 
-  ientries = (int) entries;
+  ientries = (intgo) entries;
   if (ientries < 0 || (uintptr_t) ientries != entries)
     runtime_panicstring ("map size out of range");
 
index 05325b1194f5910883f08ce5ac3de9beff0f88d1..530629ca3390cb319ed5d81b17b03646d348855c 100644 (file)
@@ -13,7 +13,6 @@
 #include "go-alloc.h"
 #include "go-defer.h"
 #include "go-panic.h"
-#include "go-string.h"
 #include "interface.h"
 
 /* Print the panic stack.  This is used when there is no recover.  */
index 76411498759893adb9e6187b651d9de6f922de49..e7031d4040a242f57626ddb289b2a1385a80b8e3 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "interface.h"
 
-struct __go_string;
+struct String;
 struct __go_type_descriptor;
 struct __go_defer_stack;
 
@@ -34,7 +34,7 @@ struct __go_panic_stack
 extern void __go_panic (struct __go_empty_interface)
   __attribute__ ((noreturn));
 
-extern void __go_print_string (struct __go_string);
+extern void __go_print_string (struct String);
 
 extern struct __go_empty_interface __go_recover (void);
 
index 3fe879a48af6b889b44eab989cd57900aa6375d1..4c520de3ce5eb23bcd30f954ec95463664654cfa 100644 (file)
@@ -11,7 +11,6 @@
 #include "runtime.h"
 #include "array.h"
 #include "go-panic.h"
-#include "go-string.h"
 #include "interface.h"
 
 /* This implements the various little functions which are called by
index 688c68e581e6a936aba399ed551a70fe765707a3..6455ff135674a56b5910122652a771547a077ad6 100644 (file)
@@ -8,12 +8,10 @@
 #include <stdint.h>
 #include <stdlib.h>
 
-#include "config.h"
-
+#include "runtime.h"
 #include "go-alloc.h"
 #include "go-assert.h"
 #include "go-type.h"
-#include "runtime.h"
 
 #ifdef USE_LIBFFI
 
@@ -77,13 +75,15 @@ go_slice_to_ffi (
     const struct __go_slice_type *descriptor __attribute__ ((unused)))
 {
   ffi_type *ret;
+  ffi_type *intgo;
 
   ret = (ffi_type *) __go_alloc (sizeof (ffi_type));
   ret->type = FFI_TYPE_STRUCT;
   ret->elements = (ffi_type **) __go_alloc (4 * sizeof (ffi_type *));
   ret->elements[0] = &ffi_type_pointer;
-  ret->elements[1] = &ffi_type_sint;
-  ret->elements[2] = &ffi_type_sint;
+  intgo = sizeof (intgo) == 4 ? &ffi_type_sint32 : &ffi_type_sint64;
+  ret->elements[1] = intgo;
+  ret->elements[2] = intgo;
   ret->elements[3] = NULL;
   return ret;
 }
@@ -110,19 +110,21 @@ go_struct_to_ffi (const struct __go_struct_type *descriptor)
   return ret;
 }
 
-/* Return an ffi_type for a Go string type.  This describes the
-   __go_string struct.  */
+/* Return an ffi_type for a Go string type.  This describes the String
+   struct.  */
 
 static ffi_type *
 go_string_to_ffi (void)
 {
   ffi_type *ret;
+  ffi_type *intgo;
 
   ret = (ffi_type *) __go_alloc (sizeof (ffi_type));
   ret->type = FFI_TYPE_STRUCT;
   ret->elements = (ffi_type **) __go_alloc (3 * sizeof (ffi_type *));
   ret->elements[0] = &ffi_type_pointer;
-  ret->elements[1] = &ffi_type_sint;
+  intgo = sizeof (intgo) == 4 ? &ffi_type_sint32 : &ffi_type_sint64;
+  ret->elements[1] = intgo;
   ret->elements[2] = NULL;
   return ret;
 }
@@ -199,7 +201,7 @@ go_type_to_ffi (const struct __go_type_descriptor *descriptor)
     case GO_INT8:
       return &ffi_type_sint8;
     case GO_INT:
-      return &ffi_type_sint;
+      return sizeof (intgo) == 4 ? &ffi_type_sint32 : &ffi_type_sint64;
     case GO_UINT16:
       return &ffi_type_uint16;
     case GO_UINT32:
@@ -209,7 +211,7 @@ go_type_to_ffi (const struct __go_type_descriptor *descriptor)
     case GO_UINT8:
       return &ffi_type_uint8;
     case GO_UINT:
-      return &ffi_type_uint;
+      return sizeof (uintgo) == 4 ? &ffi_type_uint32 : &ffi_type_uint64;
     case GO_UINTPTR:
       if (sizeof (void *) == 2)
        return &ffi_type_uint16;
index 2caf80061c0de32e567a8e816cdf6bf0f77365a0..ba6d86c501fc0b169e7086233c42ab9d2454fc29 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <stddef.h>
 
+#include "runtime.h"
 #include "go-string.h"
 
 /* Get a character from the UTF-8 string STR, of length LEN.  Store
index 68db8acd8b171e095c648b07989469107afa1942..f5ab4f9196bbabc670bd7190423b49ceaee5fa89 100644 (file)
@@ -55,7 +55,7 @@ enum
 extern void __go_runtime_error () __attribute__ ((noreturn));
 
 void
-__go_runtime_error (int i)
+__go_runtime_error (int32 i)
 {
   switch (i)
     {
index 789ffdf4987f5c7250dfaafd4f984fee5de6a6be..41f14d4b7343c9acf2b5fbffe74e5342d3e70489 100644 (file)
 #include <stdlib.h>
 
 #include "go-alloc.h"
-#include "go-string.h"
+#include "runtime.h"
 
 /* Set the C environment from Go.  This is called by syscall.Setenv.  */
 
-void setenv_c (struct __go_string, struct __go_string)
-  __asm__ ("syscall.setenv_c");
+void setenv_c (String, String) __asm__ ("syscall.setenv_c");
 
 void
-setenv_c (struct __go_string k, struct __go_string v)
+setenv_c (String k, String v)
 {
-  const unsigned char *ks;
+  const byte *ks;
   unsigned char *kn;
-  const unsigned char *vs;
+  const byte *vs;
   unsigned char *vn;
 
-  ks = k.__data;
+  ks = k.str;
   kn = NULL;
-  vs = v.__data;
+  vs = v.str;
   vn = NULL;
 
 #ifdef HAVE_SETENV
 
-  if (ks[k.__length] != 0)
+  if (ks[k.len] != 0)
     {
-      kn = __go_alloc (k.__length + 1);
-      __builtin_memcpy (kn, ks, k.__length);
+      kn = __go_alloc (k.len + 1);
+      __builtin_memcpy (kn, ks, k.len);
       ks = kn;
     }
 
-  if (vs[v.__length] != 0)
+  if (vs[v.len] != 0)
     {
-      vn = __go_alloc (v.__length + 1);
-      __builtin_memcpy (vn, vs, v.__length);
+      vn = __go_alloc (v.len + 1);
+      __builtin_memcpy (vn, vs, v.len);
       vs = vn;
     }
 
@@ -50,11 +49,11 @@ setenv_c (struct __go_string k, struct __go_string v)
 
 #else /* !defined(HAVE_SETENV) */
 
-  kn = __go_alloc (k.__length + v.__length + 2);
-  __builtin_memcpy (kn, ks, k.__length);
-  kn[k.__length] = '=';
-  __builtin_memcpy (kn + k.__length + 1, vs, v.__length);
-  kn[k.__length + v.__length + 1] = '\0';
+  kn = __go_alloc (k.len + v.len + 2);
+  __builtin_memcpy (kn, ks, k.len);
+  kn[k.len] = '=';
+  __builtin_memcpy (kn + k.len + 1, vs, v.len);
+  kn[k.len + v.len + 1] = '\0';
   putenv ((char *) kn);
 
 #endif /* !defined(HAVE_SETENV) */
index 8e6cb1834a28fac9d1563e0dcf4d85d13c8ff158..bcc270bf8a57b0b56f9ba0f4549bde80a705e6c5 100644 (file)
@@ -4,23 +4,21 @@
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.  */
 
-#include "go-string.h"
+#include "runtime.h"
 
-int
-__go_strcmp(struct __go_string s1, struct __go_string s2)
+intgo
+__go_strcmp(String s1, String s2)
 {
   int i;
 
-  i = __builtin_memcmp(s1.__data, s2.__data,
-                      (s1.__length < s2.__length
-                       ? s1.__length
-                       : s2.__length));
+  i = __builtin_memcmp(s1.str, s2.str,
+                      (s1.len < s2.len ? s1.len : s2.len));
   if (i != 0)
     return i;
 
-  if (s1.__length < s2.__length)
+  if (s1.len < s2.len)
     return -1;
-  else if (s1.__length > s2.__length)
+  else if (s1.len > s2.len)
     return 1;
   else
     return 0;
index 8bae54b0c14285c699b97fde130a5d9e1e8ad8e4..75fac1dbfe6c5308cabe4a1f63dfb40792cd6bc3 100644 (file)
@@ -4,22 +4,21 @@
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.  */
 
-#include "go-string.h"
-#include "array.h"
 #include "runtime.h"
+#include "array.h"
 #include "arch.h"
 #include "malloc.h"
 
 struct __go_open_array
-__go_string_to_byte_array (struct __go_string str)
+__go_string_to_byte_array (String str)
 {
   unsigned char *data;
   struct __go_open_array ret;
 
-  data = (unsigned char *) runtime_mallocgc (str.__length, FlagNoPointers, 1, 0);
-  __builtin_memcpy (data, str.__data, str.__length);
+  data = (unsigned char *) runtime_mallocgc (str.len, FlagNoPointers, 1, 0);
+  __builtin_memcpy (data, str.str, str.len);
   ret.__values = (void *) data;
-  ret.__count = str.__length;
-  ret.__capacity = str.__length;
+  ret.__count = str.len;
+  ret.__capacity = str.len;
   return ret;
 }
index aff146872a9e506314499c95ff3a2c689d51e19f..16970bdd042f3c2058cb9ae923ba1fcf79a82a77 100644 (file)
@@ -4,15 +4,15 @@
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.  */
 
+#include "runtime.h"
 #include "go-alloc.h"
 #include "go-string.h"
 #include "array.h"
-#include "runtime.h"
 #include "arch.h"
 #include "malloc.h"
 
 struct __go_open_array
-__go_string_to_int_array (struct __go_string str)
+__go_string_to_int_array (String str)
 {
   size_t c;
   const unsigned char *p;
@@ -22,8 +22,8 @@ __go_string_to_int_array (struct __go_string str)
   struct __go_open_array ret;
 
   c = 0;
-  p = str.__data;
-  pend = p + str.__length;
+  p = str.str;
+  pend = p + str.len;
   while (p < pend)
     {
       int rune;
@@ -34,7 +34,7 @@ __go_string_to_int_array (struct __go_string str)
 
   data = (uint32_t *) runtime_mallocgc (c * sizeof (uint32_t), FlagNoPointers,
                                        1, 0);
-  p = str.__data;
+  p = str.str;
   pd = data;
   while (p < pend)
     {
index 2c8e1acd32388ba95b1cd1946db714b1473b6ca1..f4c149bb54ef32a6972cf01036721a589a3d9ec8 100644 (file)
@@ -9,26 +9,15 @@
 
 #include <stddef.h>
 
-/* A string is an instance of this structure.  */
-
-struct __go_string
-{
-  /* The bytes.  */
-  const unsigned char *__data;
-  /* The length.  */
-  int __length;
-};
-
 static inline _Bool
-__go_strings_equal (struct __go_string s1, struct __go_string s2)
+__go_strings_equal (String s1, String s2)
 {
-  return (s1.__length == s2.__length
-         && __builtin_memcmp (s1.__data, s2.__data, s1.__length) == 0);
+  return (s1.len == s2.len
+         && __builtin_memcmp (s1.str, s2.str, s1.len) == 0);
 }
 
 static inline _Bool
-__go_ptr_strings_equal (const struct __go_string *ps1,
-                       const struct __go_string *ps2)
+__go_ptr_strings_equal (const String *ps1, const String *ps2)
 {
   if (ps1 == NULL)
     return ps2 == NULL;
index bfbe3412a75544b71e6c01b6c3c9945f5c82716d..d6e6df67fcef8109e7bdae17f1109de18fe01b58 100644 (file)
@@ -4,28 +4,27 @@
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.  */
 
-#include "go-string.h"
 #include "runtime.h"
 #include "arch.h"
 #include "malloc.h"
 
-struct __go_string
-__go_string_plus (struct __go_string s1, struct __go_string s2)
+String
+__go_string_plus (String s1, String s2)
 {
   int len;
-  unsigned char *retdata;
-  struct __go_string ret;
+  byte *retdata;
+  String ret;
 
-  if (s1.__length == 0)
+  if (s1.len == 0)
     return s2;
-  else if (s2.__length == 0)
+  else if (s2.len == 0)
     return s1;
 
-  len = s1.__length + s2.__length;
+  len = s1.len + s2.len;
   retdata = runtime_mallocgc (len, FlagNoPointers, 1, 0);
-  __builtin_memcpy (retdata, s1.__data, s1.__length);
-  __builtin_memcpy (retdata + s1.__length, s2.__data, s2.__length);
-  ret.__data = retdata;
-  ret.__length = len;
+  __builtin_memcpy (retdata, s1.str, s1.len);
+  __builtin_memcpy (retdata + s1.len, s2.str, s2.len);
+  ret.str = retdata;
+  ret.len = len;
   return ret;
 }
index 8d916c460840f61f10d789ec12e8cee822924317..21e1bc031daf29e4ce54da0a1c0941d0bbf4cf5b 100644 (file)
@@ -4,24 +4,23 @@
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.  */
 
-#include "go-string.h"
 #include "go-panic.h"
 #include "runtime.h"
 #include "arch.h"
 #include "malloc.h"
 
-struct __go_string
-__go_string_slice (struct __go_string s, int start, int end)
+String
+__go_string_slice (String s, intgo start, intgo end)
 {
-  int len;
-  struct __go_string ret;
+  intgo len;
+  String ret;
 
-  len = s.__length;
+  len = s.len;
   if (end == -1)
     end = len;
   if (start > len || end < start || end > len)
     runtime_panicstring ("string index out of bounds");
-  ret.__data = s.__data + start;
-  ret.__length = end - start;
+  ret.str = s.str + start;
+  ret.len = end - start;
   return ret;
 }
index c1571a378640b59fc55f3bb74eec11bba37505eb..4d5b61a4fd5bb850de826a6d3de1eb8434a406d7 100644 (file)
@@ -7,7 +7,6 @@
 #include "config.h"
 
 #include "runtime.h"
-#include "go-string.h"
 
 /* Print a stack trace for the current goroutine.  */
 
@@ -28,12 +27,12 @@ runtime_printtrace (uintptr *pcbuf, int32 c)
 
   for (i = 0; i < c; ++i)
     {
-      struct __go_string fn;
-      struct __go_string file;
+      String fn;
+      String file;
       int line;
 
       if (__go_file_line (pcbuf[i], &fn, &file, &line)
-         && runtime_showframe (fn.__data))
+         && runtime_showframe (fn.str))
        {
          runtime_printf ("%S\n", fn);
          runtime_printf ("\t%S:%d\n", file, line);
index a50a8a131a1305ed55620452a7f2977f2a064500..ed510f75a725fa5f58f4ee48d08f4b7128767052 100644 (file)
@@ -6,13 +6,9 @@
 
 #include <stddef.h>
 
-#include "config.h"
+#include "runtime.h"
 #include "go-type.h"
 
-/* The 64-bit type.  */
-
-typedef unsigned int DItype __attribute__ ((mode (DI)));
-
 /* An identity hash function for a type.  This is used for types where
    we can simply use the type value itself as a hash code.  This is
    true of, e.g., integers and pointers.  */
@@ -28,7 +24,7 @@ __go_type_hash_identity (const void *key, uintptr_t key_size)
     {
       union
       {
-       DItype v;
+       uint64 v;
        unsigned char a[8];
       } u;
       u.v = 0;
index bc3b37c4ba23514f74e12c38c05417d4f7dc012f..9aad720085c5d8893fb08c2f8a7ec2548655845c 100644 (file)
@@ -4,6 +4,7 @@
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.  */
 
+#include "runtime.h"
 #include "interface.h"
 #include "go-type.h"
 
index 719ecb0e7ea7e8cdf00b673d9d597a254b5f1359..a96af0290b256e29963a1916e34b5c871728b891 100644 (file)
@@ -4,10 +4,9 @@
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.  */
 
-#include <stddef.h>
-
-#include "go-string.h"
+#include "runtime.h"
 #include "go-type.h"
+#include "go-string.h"
 
 /* A string hash function for a map.  */
 
@@ -16,15 +15,15 @@ __go_type_hash_string (const void *vkey,
                       uintptr_t key_size __attribute__ ((unused)))
 {
   uintptr_t ret;
-  const struct __go_string *key;
-  int len;
-  int i;
-  const unsigned char *p;
+  const String *key;
+  intgo len;
+  intgo i;
+  const byte *p;
 
   ret = 5381;
-  key = (const struct __go_string *) vkey;
-  len = key->__length;
-  for (i = 0, p = key->__data; i < len; i++, p++)
+  key = (const String *) vkey;
+  len = key->len;
+  for (i = 0, p = key->str; i < len; i++, p++)
     ret = ret * 33 + *p;
   return ret;
 }
@@ -35,11 +34,10 @@ _Bool
 __go_type_equal_string (const void *vk1, const void *vk2,
                        uintptr_t key_size __attribute__ ((unused)))
 {
-  const struct __go_string *k1;
-  const struct __go_string *k2;
+  const String *k1;
+  const String *k2;
 
-  k1 = (const struct __go_string *) vk1;
-  k2 = (const struct __go_string *) vk2;
-  return (k1->__length == k2->__length
-         && __builtin_memcmp (k1->__data, k2->__data, k1->__length) == 0);
+  k1 = (const String *) vk1;
+  k2 = (const String *) vk2;
+  return __go_ptr_strings_equal (k1, k2);
 }
index 25f096c485174e2e870ee920e1f6c882720009b3..2269ae6339c5b4e5952ba32ee84dfe429733cb7b 100644 (file)
 #include <stddef.h>
 #include <stdint.h>
 
-#include "go-string.h"
 #include "array.h"
 
+struct String;
+
 /* Many of the types in this file must match the data structures
    generated by the compiler, and must also match the Go types which
    appear in go/runtime/type.go and go/reflect/type.go.  */
@@ -94,7 +95,7 @@ struct __go_type_descriptor
 
   /* A string describing this type.  This is only used for
      debugging.  */
-  const struct __go_string *__reflection;
+  const struct String *__reflection;
 
   /* A pointer to fields which are only used for some types.  */
   const struct __go_uncommon_type *__uncommon;
@@ -109,11 +110,11 @@ struct __go_type_descriptor
 struct __go_method
 {
   /* The name of the method.  */
-  const struct __go_string *__name;
+  const struct String *__name;
 
   /* This is NULL for an exported method, or the name of the package
      where it lives.  */
-  const struct __go_string *__pkg_path;
+  const struct String *__pkg_path;
 
   /* The type of the method, without the receiver.  This will be a
      function type.  */
@@ -134,10 +135,10 @@ struct __go_method
 struct __go_uncommon_type
 {
   /* The name of the type.  */
-  const struct __go_string *__name;
+  const struct String *__name;
 
   /* The type's package.  This is NULL for builtin types.  */
-  const struct __go_string *__pkg_path;
+  const struct String *__pkg_path;
 
   /* The type's methods.  This is an array of struct __go_method.  */
   struct __go_open_array __methods;
@@ -216,11 +217,11 @@ struct __go_func_type
 struct __go_interface_method
 {
   /* The name of the method.  */
-  const struct __go_string *__name;
+  const struct String *__name;
 
   /* This is NULL for an exported method, or the name of the package
      where it lives.  */
-  const struct __go_string *__pkg_path;
+  const struct String *__pkg_path;
 
   /* The real type of the method.  */
   struct __go_type_descriptor *__type;
@@ -269,17 +270,17 @@ struct __go_ptr_type
 struct __go_struct_field
 {
   /* The name of the field--NULL for an anonymous field.  */
-  const struct __go_string *__name;
+  const struct String *__name;
 
   /* This is NULL for an exported method, or the name of the package
      where it lives.  */
-  const struct __go_string *__pkg_path;
+  const struct String *__pkg_path;
 
   /* The type of the field.  */
   const struct __go_type_descriptor *__type;
 
   /* The field tag, or NULL.  */
-  const struct __go_string *__tag;
+  const struct String *__tag;
 
   /* The offset of the field in the struct.  */
   uintptr_t __offset;
index 932519aab43ac637f19e4f59a400fe3c27b70258..f8474fc9f6c64eab9ab036bc9d3ab7e50ebfab6e 100644 (file)
@@ -4,6 +4,7 @@
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.  */
 
+#include "runtime.h"
 #include "go-string.h"
 #include "go-type.h"
 
index d40c6ad1b9860c194512faa4594b6c83f4885188..712c333e7cb94aac58ae9a917b70501b0979c0cf 100644 (file)
@@ -4,14 +4,13 @@
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.  */
 
+#include "runtime.h"
 #include "interface.h"
 #include "go-type.h"
-#include "go-string.h"
 
-struct __go_string typestring(struct __go_empty_interface)
-  asm ("runtime.typestring");
+String typestring(struct __go_empty_interface) asm ("runtime.typestring");
 
-struct __go_string
+String
 typestring (struct __go_empty_interface e)
 {
   return *e.__type_descriptor->__reflection;
index cda59361327e8a709581ce627c263fbf3c9249ca..e3a55b4dfb241e377a2373e8f650e25a82c5f973 100644 (file)
@@ -6,7 +6,7 @@
 
 #include <stddef.h>
 
-#include "go-string.h"
+#include "runtime.h"
 #include "go-type.h"
 
 /* This file provides the type descriptor for the unsafe.Pointer type.
@@ -26,9 +26,9 @@ struct field_align
 
 /* The reflection string.  */
 #define REFLECTION "unsafe.Pointer"
-static const struct __go_string reflection_string =
+static const String reflection_string =
 {
-  (const unsigned char *) REFLECTION,
+  (const byte *) REFLECTION,
   sizeof REFLECTION - 1
 };
 
@@ -65,9 +65,9 @@ extern const struct __go_ptr_type pointer_unsafe_Pointer
 
 /* The reflection string.  */
 #define PREFLECTION "*unsafe.Pointer"
-static const struct __go_string preflection_string =
+static const String preflection_string =
 {
-  (const unsigned char *) PREFLECTION,
+  (const byte *) PREFLECTION,
   sizeof PREFLECTION - 1,
 };
 
index 610f208901e26c63e27830682bd40b0987bfe351..f3068a656fab84674e02c352ba2fa1f6320c1274 100644 (file)
@@ -7,7 +7,7 @@
 #ifndef LIBGO_INTERFACE_H
 #define LIBGO_INTERFACE_H
 
-#include "go-type.h"
+struct __go_type_descriptor;
 
 /* A variable of interface type is an instance of this struct, if the
    interface has any methods.  */
index 1b6828fd480510c93702b8d7204dc5a0a80834a9..1a0afede2c184924fcd1fe9d09a491f577be3ae8 100644 (file)
@@ -14,7 +14,6 @@ package runtime
 #include "runtime.h"
 #include "arch.h"
 #include "malloc.h"
-#include "go-string.h"
 #include "interface.h"
 #include "go-type.h"
 #include "race.h"
index 98326c66a6eb52fac75a91095728c254bccd4890..1af9639245648d18c85005c356ca20dcc1a383c6 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "runtime.h"
 #include "go-defer.h"
+#include "go-panic.h"
 
 // Code related to defer, panic and recover.
 
index 690bcaf033130ea90f99a9f820c0469e23e0f160..42717bb951ad6f8d535397982537d7a1ad17748a 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <stdarg.h>
 #include "runtime.h"
+#include "array.h"
 
 //static Lock debuglock;
 
@@ -294,8 +295,8 @@ runtime_printstring(String v)
        //      gwrite("[string too long]", 17);
        //      return;
        // }
-       if(v.__length > 0)
-               gwrite(v.__data, v.__length);
+       if(v.len > 0)
+               gwrite(v.str, v.len);
 }
 
 void
index 620cd10c1c38530cc75113427d655b439b0d2e25..8e82d1287817e556a3b416b0ecb720f44251fbdc 100644 (file)
@@ -586,13 +586,13 @@ void
 runtime_goroutinetrailer(G *g)
 {
        if(g != nil && g->gopc != 0 && g->goid != 1) {
-               struct __go_string fn;
-               struct __go_string file;
+               String fn;
+               String file;
                int line;
 
                if(__go_file_line(g->gopc - 1, &fn, &file, &line)) {
-                       runtime_printf("created by %s\n", fn.__data);
-                       runtime_printf("\t%s:%d\n", file.__data, line);
+                       runtime_printf("created by %S\n", fn);
+                       runtime_printf("\t%S:%d\n", file, line);
                }
        }
 }
index 447b786a8d848436ee5da170676f119d381e7de8..c798b269e0fd4f8e44576371f7a29b4a7ef1a128 100644 (file)
@@ -3,9 +3,9 @@
 // license that can be found in the LICENSE file.
 
 package reflect
+#include "runtime.h"
 #include "go-type.h"
 #include "interface.h"
-#include "runtime.h"
 #include "go-panic.h"
 
 func ifaceE2I(inter *Type, e Eface, ret *Iface) {
index c5716ab8fc1594a1da2185882907845c4399fc0c..3d4865a001a34d63d8363ba1c7a2ec4a2d9f8817 100644 (file)
@@ -9,7 +9,6 @@
 #include "runtime.h"
 #include "array.h"
 #include "go-panic.h"
-#include "go-string.h"
 
 int32
 runtime_gotraceback(void)
@@ -93,9 +92,9 @@ runtime_getenv(const char *s)
        envv = (String*)syscall_Envs.__values;
        envc = syscall_Envs.__count;
        for(i=0; i<envc; i++){
-               if(envv[i].__length <= len)
+               if(envv[i].len <= len)
                        continue;
-               v = (const byte*)envv[i].__data;
+               v = (const byte*)envv[i].str;
                for(j=0; j<len; j++)
                        if(bs[j] != v[j])
                                goto nomatch;
index defe792c761914eac411dd701af1ff4f09732aa9..e6281eaf803b2e3b156c76a38533ebd044ce7f72 100644 (file)
 #include <sys/mman.h>
 #endif
 
-#include "array.h"
+#include "interface.h"
 #include "go-alloc.h"
-#include "go-panic.h"
-#include "go-string.h"
 
 /* This file supports C files copied from the 6g runtime library.
    This is a version of the 6g runtime.h rewritten for gccgo's version
@@ -67,7 +65,7 @@ typedef struct        ParFor          ParFor;
 typedef struct ParForThread    ParForThread;
 
 typedef        struct  __go_open_array         Slice;
-typedef        struct  __go_string             String;
+typedef        struct  String                  String;
 typedef struct __go_interface          Iface;
 typedef        struct  __go_empty_interface    Eface;
 typedef        struct  __go_type_descriptor    Type;
@@ -129,6 +127,11 @@ union      Note
        uint32  key;    // futex-based impl
        M*      waitm;  // waiting M (sema-based impl)
 };
+struct String
+{
+       const byte*     str;
+       intgo           len;
+};
 struct GCStats
 {
        // the struct must consist of only uint64's,
index 4e616c7a165b094a553e5eb831bafdd39a404c3e..d3f0c2d4b9c405e7ccd3a044a74de5630913c995 100644 (file)
@@ -6,10 +6,11 @@ package runtime
 #include "runtime.h"
 #include "arch.h"
 #include "malloc.h"
+#include "go-string.h"
 
 #define charntorune(pv, str, len) __go_get_rune(str, len, pv)
 
-int32
+intgo
 runtime_findnull(const byte *s)
 {
        if(s == nil)
@@ -22,8 +23,8 @@ runtime_gostringnocopy(const byte *str)
 {
        String s;
        
-       s.__data = (const unsigned char *) str;
-       s.__length = runtime_findnull(str);
+       s.str = str;
+       s.len = runtime_findnull(str);
        return s;
 }
 
@@ -35,40 +36,40 @@ enum
 func stringiter(s String, k int) (retk int) {
        int32 l;
 
-       if(k >= s.__length) {
+       if(k >= s.len) {
                // retk=0 is end of iteration
                retk = 0;
                goto out;
        }
 
-       l = s.__data[k];
+       l = s.str[k];
        if(l < Runeself) {
                retk = k+1;
                goto out;
        }
 
        // multi-char rune
-       retk = k + charntorune(&l, s.__data+k, s.__length-k);
+       retk = k + charntorune(&l, s.str+k, s.len-k);
 
 out:
 }
 
 func stringiter2(s String, k int) (retk int, retv int) {
-       if(k >= s.__length) {
+       if(k >= s.len) {
                // retk=0 is end of iteration
                retk = 0;
                retv = 0;
                goto out;
        }
 
-       retv = s.__data[k];
+       retv = s.str[k];
        if(retv < Runeself) {
                retk = k+1;
                goto out;
        }
 
        // multi-char rune
-       retk = k + charntorune(&retv, s.__data+k, s.__length-k);
+       retk = k + charntorune(&retv, s.str+k, s.len-k);
 
 out:
 }