[m-rev.] diff: Fix compilation of memprof grades on 32-bit.

Peter Wang novalazy at gmail.com
Thu Aug 9 23:10:57 AEST 2018


runtime/mercury_heap_profile.c:
    Use MR_INTEGER_LENGTH_MODIFIER to get the right format specifier
    when printing size_t fields.

diff --git a/runtime/mercury_heap_profile.c b/runtime/mercury_heap_profile.c
index d648f0113..f1e8ee1c3 100644
--- a/runtime/mercury_heap_profile.c
+++ b/runtime/mercury_heap_profile.c
@@ -479,39 +479,43 @@ finish_reachable_report(const char *label)
 
 static void
 write_attrib_counts(FILE *fp, MR_AttribCount *table, size_t table_size)
 {
     size_t i;
 
     for (i = 0; i < table_size; i++) {
         if (table[i].MR_atc_alloc_site != NULL &&
             table[i].MR_atc_num_cells != 0)
         {
-            fprintf(fp, "%d %lu %lu\n",
+            fprintf(fp, "%d "
+                "%" MR_INTEGER_LENGTH_MODIFIER "u "
+                "%" MR_INTEGER_LENGTH_MODIFIER "u\n",
                 table[i].MR_atc_id,
                 table[i].MR_atc_num_cells,
                 table[i].MR_atc_num_words);
 
             table[i].MR_atc_num_cells = 0;
             table[i].MR_atc_num_words = 0;
         }
     }
 }
 
 static void
 write_var_size_counts(FILE *fp, const char *prefix, MR_VarSizeCount *node)
 {
     while (node != NULL) {
         write_var_size_counts(fp, prefix, node->MR_vsc_left);
 
         if (node->MR_vsc_count != 0) {
-            fprintf(fp, "%s %ld %ld\n",
+            fprintf(fp, "%s "
+                "%" MR_INTEGER_LENGTH_MODIFIER "d "
+                "%" MR_INTEGER_LENGTH_MODIFIER "d\n",
                 prefix,
                 node->MR_vsc_count,
                 node->MR_vsc_size);
             node->MR_vsc_count = 0;
         }
 
         node = node->MR_vsc_right;
     }
 }
 
-- 
2.18.0



More information about the reviews mailing list