diff mbox

Go patch committed: More 64-bit int preparation

Message ID mcr7gpysecs.fsf@google.com
State New
Headers show

Commit Message

Ian Lance Taylor Nov. 6, 2012, 7:47 p.m. UTC
This patch to the compiler and libgo fixes a number of minor issues in
preparation for converting to 64-bit int.  This is mostly changing from
int to intgo, with a couple of exceptions: we limit new map entries to
int32, and we handle the Go type rune as the C type int32.  Bootstrapped
and ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to
mainline.

Ian
diff mbox

Patch

Index: gcc/go/gofrontend/types.cc
===================================================================
--- gcc/go/gofrontend/types.cc	(revision 193253)
+++ gcc/go/gofrontend/types.cc	(revision 193254)
@@ -2568,8 +2568,12 @@  Integer_type::create_abstract_integer_ty
 {
   static Integer_type* abstract_type;
   if (abstract_type == NULL)
-    abstract_type = new Integer_type(true, false, INT_TYPE_SIZE,
-				     RUNTIME_TYPE_KIND_INT);
+    {
+      Type* int_type = Type::lookup_integer_type("int");
+      abstract_type = new Integer_type(true, false,
+				       int_type->integer_type()->bits(),
+				       RUNTIME_TYPE_KIND_INT);
+    }
   return abstract_type;
 }
 
Index: libgo/runtime/go-new-map.c
===================================================================
--- libgo/runtime/go-new-map.c	(revision 193253)
+++ libgo/runtime/go-new-map.c	(revision 193254)
@@ -106,10 +106,11 @@  __go_map_next_prime (uintptr_t n)
 struct __go_map *
 __go_new_map (const struct __go_map_descriptor *descriptor, uintptr_t entries)
 {
-  intgo ientries;
+  int32 ientries;
   struct __go_map *ret;
 
-  ientries = (intgo) entries;
+  /* The master library limits map entries to int32, so we do too.  */
+  ientries = (int32) entries;
   if (ientries < 0 || (uintptr_t) ientries != entries)
     runtime_panicstring ("map size out of range");
 
Index: libgo/runtime/go-rune.c
===================================================================
--- libgo/runtime/go-rune.c	(revision 193253)
+++ libgo/runtime/go-rune.c	(revision 193254)
@@ -14,7 +14,7 @@ 
    characters used from STR.  */
 
 int
-__go_get_rune (const unsigned char *str, size_t len, int *rune)
+__go_get_rune (const unsigned char *str, size_t len, int32 *rune)
 {
   int c, c1, c2, c3, l;
 
Index: libgo/runtime/cpuprof.c
===================================================================
--- libgo/runtime/cpuprof.c	(revision 193253)
+++ libgo/runtime/cpuprof.c	(revision 193254)
@@ -124,7 +124,7 @@  static uintptr eod[3] = {0, 1, 0};
 static void LostProfileData(void) {
 }
 
-extern void runtime_SetCPUProfileRate(int32)
+extern void runtime_SetCPUProfileRate(intgo)
      __asm__("runtime.SetCPUProfileRate");
 
 // SetCPUProfileRate sets the CPU profiling rate.
Index: libgo/runtime/runtime.h
===================================================================
--- libgo/runtime/runtime.h	(revision 193253)
+++ libgo/runtime/runtime.h	(revision 193254)
@@ -341,7 +341,7 @@  int32	runtime_ncpu;
 /*
  * common functions and data
  */
-int32	runtime_findnull(const byte*);
+intgo	runtime_findnull(const byte*);
 void	runtime_dump(byte*, int32);
 
 /*
@@ -614,7 +614,7 @@  extern uintptr runtime_stacks_sys;
 
 struct backtrace_state;
 extern struct backtrace_state *__go_get_backtrace_state(void);
-extern _Bool __go_file_line(uintptr, String*, String*, int *);
+extern _Bool __go_file_line(uintptr, String*, String*, intgo *);
 extern byte* runtime_progname();
 
 int32 getproccount(void);
Index: libgo/runtime/proc.c
===================================================================
--- libgo/runtime/proc.c	(revision 193253)
+++ libgo/runtime/proc.c	(revision 193254)
@@ -610,11 +610,11 @@  runtime_goroutinetrailer(G *g)
 	if(g != nil && g->gopc != 0 && g->goid != 1) {
 		String fn;
 		String file;
-		int line;
+		intgo line;
 
 		if(__go_file_line(g->gopc - 1, &fn, &file, &line)) {
 			runtime_printf("created by %S\n", fn);
-			runtime_printf("\t%S:%d\n", file, line);
+			runtime_printf("\t%S:%D\n", file, (int64) line);
 		}
 	}
 }
Index: libgo/runtime/go-string.h
===================================================================
--- libgo/runtime/go-string.h	(revision 193253)
+++ libgo/runtime/go-string.h	(revision 193254)
@@ -26,6 +26,6 @@  __go_ptr_strings_equal (const String *ps
   return __go_strings_equal (*ps1, *ps2);
 }
 
-extern int __go_get_rune (const unsigned char *, size_t, int *);
+extern int __go_get_rune (const unsigned char *, size_t, int32 *);
 
 #endif /* !defined(LIBGO_GO_STRING_H) */
Index: libgo/runtime/go-traceback.c
===================================================================
--- libgo/runtime/go-traceback.c	(revision 193253)
+++ libgo/runtime/go-traceback.c	(revision 193254)
@@ -29,13 +29,13 @@  runtime_printtrace (uintptr *pcbuf, int3
     {
       String fn;
       String file;
-      int line;
+      intgo line;
 
       if (__go_file_line (pcbuf[i], &fn, &file, &line)
 	  && runtime_showframe (fn.str))
 	{
 	  runtime_printf ("%S\n", fn);
-	  runtime_printf ("\t%S:%d\n", file, line);
+	  runtime_printf ("\t%S:%D\n", file, (int64) line);
 	}
     }
 }
Index: libgo/runtime/string.goc
===================================================================
--- libgo/runtime/string.goc	(revision 193253)
+++ libgo/runtime/string.goc	(revision 193254)
@@ -54,7 +54,7 @@  func stringiter(s String, k int) (retk i
 out:
 }
 
-func stringiter2(s String, k int) (retk int, retv int) {
+func stringiter2(s String, k int) (retk int, retv int32) {
 	if(k >= s.len) {
 		// retk=0 is end of iteration
 		retk = 0;
Index: libgo/go/log/syslog/syslog_c.c
===================================================================
--- libgo/go/log/syslog/syslog_c.c	(revision 193253)
+++ libgo/go/log/syslog/syslog_c.c	(revision 193254)
@@ -6,14 +6,16 @@ 
 
 #include <syslog.h>
 
+#include "runtime.h"
+
 /* We need to use a C function to call the syslog function, because we
    can't represent a C varargs function in Go.  */
 
-void syslog_c(int, const char*)
+void syslog_c(intgo, const char*)
   asm ("log_syslog.syslog_c");
 
 void
-syslog_c (int priority, const char *msg)
+syslog_c (intgo priority, const char *msg)
 {
   syslog (priority, "%s", msg);
 }
Index: libgo/go/bytes/indexbyte.c
===================================================================
--- libgo/go/bytes/indexbyte.c	(revision 193253)
+++ libgo/go/bytes/indexbyte.c	(revision 193254)
@@ -13,11 +13,11 @@ 
    We deliberately don't split the stack in case it does call the
    library function, which shouldn't need much stack space.  */
 
-int IndexByte (struct __go_open_array, char)
+intgo IndexByte (struct __go_open_array, char)
   asm ("bytes.IndexByte")
   __attribute__ ((no_split_stack));
 
-int
+intgo
 IndexByte (struct __go_open_array s, char b)
 {
   char *p;
Index: libgo/go/syscall/signame.c
===================================================================
--- libgo/go/syscall/signame.c	(revision 193253)
+++ libgo/go/syscall/signame.c	(revision 193254)
@@ -10,10 +10,10 @@ 
 #include "arch.h"
 #include "malloc.h"
 
-String Signame (int sig) asm ("syscall.Signame");
+String Signame (intgo sig) asm ("syscall.Signame");
 
 String
-Signame (int sig)
+Signame (intgo sig)
 {
   const char* s = NULL;
   char buf[100];
@@ -27,7 +27,7 @@  Signame (int sig)
 
   if (s == NULL)
     {
-      snprintf(buf, sizeof buf, "signal %d", sig);
+      snprintf(buf, sizeof buf, "signal %ld", (long) sig);
       s = buf;
     }
   len = __builtin_strlen (s);