Patchwork extern "C" fixes for sunCC

login
register
mail settings
Submitter Marc Glisse
Date Dec. 11, 2012, 9:40 p.m.
Message ID <alpine.DEB.2.02.1212112220230.21043@stedding.saclay.inria.fr>
Download mbox | patch
Permalink /patch/205305/
State New
Headers show

Comments

Marc Glisse - Dec. 11, 2012, 9:40 p.m.
Hello,

this patch should help if we ever want to use sunCC to initiate a 
bootstrap, though I didn't test with sunCC. Note that using gmp_fprintf 
means we have to include stdio.h before gmp.h. I didn't investigate how, 
but this seems to already be the case :-) The reallocator cast is just a 
hack, but the point here is only to help sunCC, making gcc extern 
"C"-clean is a larger task...

Passes bootstrap+testsuite on x86_64-linux using the system's gcc 
(graphite is enabled, don't know if this particular code is exercised).

2012-12-12  Marc Glisse  <marc.glisse@inria.fr>

 	PR bootstrap/50167
 	PR bootstrap/50177
libcpp/
 	* line-map.c (get_combined_adhoc_loc): Cast to extern "C" type.
gcc/
 	* graphite-interchange.c (pdr_stride_in_loop): Use gmp_fprintf.
 	* graphite-poly.c (debug_gmp_value): Likewise.
Marc Glisse - Jan. 2, 2013, 1:45 p.m.
Ping
http://gcc.gnu.org/ml/gcc-patches/2012-12/msg00746.html
(I'll re-test since there have been changes around gmp.h inclusion)

On Tue, 11 Dec 2012, Marc Glisse wrote:

> Hello,
>
> this patch should help if we ever want to use sunCC to initiate a bootstrap, 
> though I didn't test with sunCC. Note that using gmp_fprintf means we have to 
> include stdio.h before gmp.h. I didn't investigate how, but this seems to 
> already be the case :-) The reallocator cast is just a hack, but the point 
> here is only to help sunCC, making gcc extern "C"-clean is a larger task...
>
> Passes bootstrap+testsuite on x86_64-linux using the system's gcc (graphite 
> is enabled, don't know if this particular code is exercised).
>
> 2012-12-12  Marc Glisse  <marc.glisse@inria.fr>
>
> 	PR bootstrap/50167
> 	PR bootstrap/50177
> libcpp/
> 	* line-map.c (get_combined_adhoc_loc): Cast to extern "C" type.
> gcc/
> 	* graphite-interchange.c (pdr_stride_in_loop): Use gmp_fprintf.
> 	* graphite-poly.c (debug_gmp_value): Likewise.
Richard Guenther - Jan. 2, 2013, 2:09 p.m.
On Wed, Jan 2, 2013 at 2:45 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
> Ping
> http://gcc.gnu.org/ml/gcc-patches/2012-12/msg00746.html
> (I'll re-test since there have been changes around gmp.h inclusion)

The graphite changes are ok.

Thanks,
Richard.

>
> On Tue, 11 Dec 2012, Marc Glisse wrote:
>
>> Hello,
>>
>> this patch should help if we ever want to use sunCC to initiate a
>> bootstrap, though I didn't test with sunCC. Note that using gmp_fprintf
>> means we have to include stdio.h before gmp.h. I didn't investigate how, but
>> this seems to already be the case :-) The reallocator cast is just a hack,
>> but the point here is only to help sunCC, making gcc extern "C"-clean is a
>> larger task...
>>
>> Passes bootstrap+testsuite on x86_64-linux using the system's gcc
>> (graphite is enabled, don't know if this particular code is exercised).
>>
>> 2012-12-12  Marc Glisse  <marc.glisse@inria.fr>
>>
>>         PR bootstrap/50167
>>         PR bootstrap/50177
>> libcpp/
>>         * line-map.c (get_combined_adhoc_loc): Cast to extern "C" type.
>> gcc/
>>         * graphite-interchange.c (pdr_stride_in_loop): Use gmp_fprintf.
>>         * graphite-poly.c (debug_gmp_value): Likewise.
>
>
> --
> Marc Glisse
Tom Tromey - Jan. 3, 2013, 3:44 p.m.
>>>>> "Marc" == Marc Glisse <marc.glisse@inria.fr> writes:

Marc> libcpp/
Marc> 	* line-map.c (get_combined_adhoc_loc): Cast to extern "C" type.

Yucky.

Marc>  	  line_map_realloc reallocator
Marc> -	      = set->reallocator ? set->reallocator : xrealloc;
Marc> +	      = set->reallocator ? set->reallocator
Marc> +				 : (line_map_realloc) xrealloc;

The indentation is wrong here, and it needs extra parens, per the GNU
coding standards.

I think it should have a comment as well.

Tom

Patch

Index: gcc/graphite-poly.c

===================================================================
--- gcc/graphite-poly.c	(revision 194404)

+++ gcc/graphite-poly.c	(working copy)

@@ -48,26 +48,21 @@  along with GCC; see the file COPYING3.

 #include "graphite-poly.h"
 
 #define OPENSCOP_MAX_STRING 256
 
 
 /* Print to STDERR the GMP value VAL.  */
 
 DEBUG_FUNCTION void
 debug_gmp_value (mpz_t val)
 {
-  char *str = mpz_get_str (0, 10, val);

-  void (*gmp_free) (void *, size_t);

-

-  fprintf (stderr, "%s", str);

-  mp_get_memory_functions (NULL, NULL, &gmp_free);

-  (*gmp_free) (str, strlen (str) + 1);

+  gmp_fprintf (stderr, "%Zd", val);

 }
 
 /* Return the maximal loop depth in SCOP.  */
 
 int
 scop_max_loop_depth (scop_p scop)
 {
   int i;
   poly_bb_p pbb;
   int max_nb_loops = 0;
Index: gcc/graphite-interchange.c

===================================================================
--- gcc/graphite-interchange.c	(revision 194404)

+++ gcc/graphite-interchange.c	(working copy)

@@ -233,29 +233,22 @@  pdr_stride_in_loop (mpz_t stride, graphi

   aff = isl_aff_set_coefficient_si (aff, isl_dim_in, offset + offset - 1, 1);
   isl_int_init (islstride);
   isl_set_max (set, aff, &islstride);
   isl_int_get_gmp (islstride, stride);
   isl_int_clear (islstride);
   isl_aff_free (aff);
   isl_set_free (set);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
-      char *str;

-      void (*gmp_free) (void *, size_t);

-

-      fprintf (dump_file, "\nStride in BB_%d, DR_%d, depth %d:",

-	       pbb_index (pbb), PDR_ID (pdr), (int) depth);

-      str = mpz_get_str (0, 10, stride);

-      fprintf (dump_file, "  %s ", str);

-      mp_get_memory_functions (NULL, NULL, &gmp_free);

-      (*gmp_free) (str, strlen (str) + 1);

+      gmp_fprintf (dump_file, "\nStride in BB_%d, DR_%d, depth %d:  %Zd ",

+		   pbb_index (pbb), PDR_ID (pdr), (int) depth, stride);

     }
 }
 
 /* Sets STRIDES to the sum of all the strides of the data references
    accessed in LOOP at DEPTH.  */
 
 static void
 memory_strides_in_loop_1 (lst_p loop, graphite_dim_t depth, mpz_t strides)
 {
   int i, j;
Index: libcpp/line-map.c

===================================================================
--- libcpp/line-map.c	(revision 194404)

+++ libcpp/line-map.c	(working copy)

@@ -116,21 +116,22 @@  get_combined_adhoc_loc (struct line_maps

   slot = (struct location_adhoc_data **)
       htab_find_slot (set->location_adhoc_data_map.htab, &lb, INSERT);
   if (*slot == NULL)
     {
       if (set->location_adhoc_data_map.curr_loc >=
 	  set->location_adhoc_data_map.allocated)
 	{
 	  char *orig_data = (char *) set->location_adhoc_data_map.data;
 	  long long offset;
 	  line_map_realloc reallocator
-	      = set->reallocator ? set->reallocator : xrealloc;

+	      = set->reallocator ? set->reallocator

+				 : (line_map_realloc) xrealloc;

 
 	  if (set->location_adhoc_data_map.allocated == 0)
 	    set->location_adhoc_data_map.allocated = 128;
 	  else
 	    set->location_adhoc_data_map.allocated *= 2;
 	  set->location_adhoc_data_map.data = (struct location_adhoc_data *)
 	      reallocator (set->location_adhoc_data_map.data,
 			   set->location_adhoc_data_map.allocated
 			   * sizeof (struct location_adhoc_data));
 	  offset = (char *) (set->location_adhoc_data_map.data) - orig_data;