Patchwork Go patch committed: Update to current Go library

login
register
mail settings
Submitter Ian Taylor
Date May 24, 2011, 8:34 p.m.
Message ID <mcrk4dfhm6q.fsf@coign.corp.google.com>
Download mbox | patch
Permalink /patch/97222/
State New
Headers show

Comments

Ian Taylor - May 24, 2011, 8:34 p.m.
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> <pwd.h> includes <stdio.h>, which leads to
>
> // type ___FILE struct { _cnt int32; _ptr *uint8; _base *uint8; _flag uint8; _magic uint8; __orientation INVALID-bit-field; __ionolock INVALID-bit-field; __seekable INVALID-bit-field; __extendedfd INVALID-bit-field; __xf_nocheck INVALID-bit-field; __filler INVALID-bit-field; }
> // type _FILE struct { _cnt int32; _ptr *uint8; _base *uint8; _flag uint8; _magi
> c uint8; __orientation INVALID-bit-field; __ionolock INVALID-bit-field; __seekab
> le INVALID-bit-field; __extendedfd INVALID-bit-field; __xf_nocheck INVALID-bit-f
> ield; __filler INVALID-bit-field; }
> var ___iob [59+1]___FILE
> var __lastbuf *_FILE
>
> in gen-sysinfo.go.

I just committed a patch to godump.c which I think should fix this
issue.  Let me know if it doesn't.

Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian


2011-05-24  Ian Lance Taylor  <iant@google.com>

	* godump.c (struct godump_container): Add invalid_hash field.
	(go_format_type): Return false if type is found in invalid_hash.
	(go_output_typedef): Add invalid type to invalid_hash.
	(go_finish): Create and delete invalid_hash.
Rainer Orth - May 25, 2011, 5:29 p.m.
Ian Lance Taylor <iant@google.com> writes:

> I just committed a patch to godump.c which I think should fix this
> issue.  Let me know if it doesn't.

There are several issues now:

* While I get

// var ___iob [59+1]___FILE

  now, there's still

var __lastbuf *_FILE

  left, with commented

// type _FILE struct { _cnt int32; _ptr *uint8; _base *uint8; _flag uint8; _file
 uint8; __orientation INVALID-bit-field; __ionolock INVALID-bit-field; __seekabl
e INVALID-bit-field; __extendedfd INVALID-bit-field; __xf_nocheck INVALID-bit-fi
eld; __filler INVALID-bit-field; }

   as before.

* The amd64 sysinfo.go contains several undefined types:

sysinfo.go:2886:53: error: use of undefined type '_fpchip_state'
sysinfo.go:2886:40: error: struct field type is incomplete
sysinfo.go:2886:53: error: use of undefined type '_fpchip_state'
sysinfo.go:2887:47: error: struct field type is incomplete
sysinfo.go:2892:32: error: use of undefined type '_fxsave_state'
sysinfo.go:2892:24: error: struct field type is incomplete

type _fpu struct { fp_reg_set struct { fpchip_state _fpchip_state; }; }
type _fpregset_t struct { fp_reg_set struct { fpchip_state _fpchip_state; }; }
type __kfpu_u struct { kfpu_fx _fxsave_state; }
type _kfpu_t struct { kfpu_u __kfpu_u; kfpu_status uint32; kfpu_xstatus uint32; }

  Both types are commented, due to the use of commented _upad128_t:

// type _upad128_t struct { _q INVALID-float-80; }

// type _fpchip_state struct { cw uint16; sw uint16; fctw uint8; __fx_rsvd uint8; fop uint16; rip uint64; rdp uint64; mxcsr uint32; mxcsr_mask uint32; st [7+1]struct { fpr_16 [4+1]uint16; }; xmm [15+1]_upad128_t; __fx_ign2 [5+1]_upad128_t; status uint32; xstatus uint32; }
// type _fxsave_state struct { fx_fcw uint16; fx_fsw uint16; fx_fctw uint16; fx_fop uint16; fx_rip uint64; fx_rdp uint64; fx_mxcsr uint32; fx_mxcsr_mask uint32; fx_st [7+1]struct { fpr_16 [4+1]uint16; }; fx_xmm [15+1]_upad128_t; __fx_ign2 [5+1]_upad128_t; }

  Unfortunately, this has as ripple effect and I need to omit several
  type declarations to make the problem go away:

+  grep -v '^type _fpu' | \
+  grep -v '^type _fpregset_t' | \
+  grep -v '^type _mcontext_t' | \
+  grep -v '^type _ucontext' | \
+  grep -v '^type __kfpu_u' | \
+  grep -v '^type _kfpu_t' | \

  <sys/types.h> has

typedef union {
        long double     _q;
        uint32_t        _l[4];
} upad128_t;

  I already have to provide a _upad128_t replacement for other uses, but
  it would really help to support this directly.

With those types and __lastbuf omitted from sysinfo.go, I can
successfully bootstrap on i386-pc-solaris2.1[01].  On Solaris 11/x86,
the libgo results are clean, on Solaris 10/x86 there are still 37
failures for the amd64 multilib which I still need to debug.

Thanks.
	Rainer

Patch

Index: godump.c
===================================================================
--- godump.c	(revision 174138)
+++ godump.c	(working copy)
@@ -464,6 +464,9 @@  struct godump_container
   /* Global type definitions.  */
   htab_t type_hash;
 
+  /* Invalid types.  */
+  htab_t invalid_hash;
+
   /* Obstack used to write out a type definition.  */
   struct obstack type_obstack;
 };
@@ -500,20 +503,20 @@  go_format_type (struct godump_container 
 	  || TREE_CODE (type) == FUNCTION_TYPE))
     {
       tree name;
+      void **slot;
 
       name = TYPE_NAME (type);
-      if (TREE_CODE (name) == IDENTIFIER_NODE)
-	{
-	  obstack_1grow (ob, '_');
-	  go_append_string (ob, name);
-	  return ret;
-	}
-      else if (TREE_CODE (name) == TYPE_DECL)
-	{
-	  obstack_1grow (ob, '_');
-	  go_append_string (ob, DECL_NAME (name));
-	  return ret;
-	}
+      if (TREE_CODE (name) == TYPE_DECL)
+	name = DECL_NAME (name);
+
+      slot = htab_find_slot (container->invalid_hash, IDENTIFIER_POINTER (name),
+			     NO_INSERT);
+      if (slot != NULL)
+	ret = false;
+
+      obstack_1grow (ob, '_');
+      go_append_string (ob, name);
+      return ret;
     }
 
   pointer_set_insert (container->decls_seen, type);
@@ -879,7 +882,11 @@  go_output_typedef (struct godump_contain
       *slot = CONST_CAST (void *, (const void *) type);
 
       if (!go_format_type (container, TREE_TYPE (decl), false, false))
-	fprintf (go_dump_file, "// ");
+	{
+	  fprintf (go_dump_file, "// ");
+	  slot = htab_find_slot (container->invalid_hash, type, INSERT);
+	  *slot = CONST_CAST (void *, (const void *) type);
+	}
       fprintf (go_dump_file, "type _%s ",
 	       IDENTIFIER_POINTER (DECL_NAME (decl)));
       go_output_type (container);
@@ -898,7 +905,11 @@  go_output_typedef (struct godump_contain
        *slot = CONST_CAST (void *, (const void *) type);
 
        if (!go_format_type (container, TREE_TYPE (decl), false, false))
-	 fprintf (go_dump_file, "// ");
+	 {
+	   fprintf (go_dump_file, "// ");
+	   slot = htab_find_slot (container->invalid_hash, type, INSERT);
+	   *slot = CONST_CAST (void *, (const void *) type);
+	 }
        fprintf (go_dump_file, "type _%s ",
 	       IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))));
        go_output_type (container);
@@ -1010,6 +1021,8 @@  go_finish (const char *filename)
   container.pot_dummy_types = pointer_set_create ();
   container.type_hash = htab_create (100, htab_hash_string,
                                      string_hash_eq, NULL);
+  container.invalid_hash = htab_create (10, htab_hash_string,
+					string_hash_eq, NULL);
   container.keyword_hash = htab_create (50, htab_hash_string,
                                         string_hash_eq, NULL);
   obstack_init (&container.type_obstack);
@@ -1044,6 +1057,7 @@  go_finish (const char *filename)
   pointer_set_destroy (container.decls_seen);
   pointer_set_destroy (container.pot_dummy_types);
   htab_delete (container.type_hash);
+  htab_delete (container.invalid_hash);
   htab_delete (container.keyword_hash);
   obstack_free (&container.type_obstack, NULL);