]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Use ONE_? macros.
authorMartin Liska <mliska@suse.cz>
Wed, 2 Sep 2020 12:34:21 +0000 (14:34 +0200)
committerMartin Liska <mliska@suse.cz>
Mon, 21 Sep 2020 08:09:27 +0000 (10:09 +0200)
gcc/ChangeLog:

* ggc-common.c (ggc_rlimit_bound): Use ONE_? macro.
(ggc_min_expand_heuristic): Likewise.
(ggc_min_heapsize_heuristic): Likewise.
* ggc-page.c (ggc_collect): Likewise.
* system.h (ONE_G): Likewise.

gcc/ggc-common.c
gcc/ggc-page.c
gcc/system.h

index 007a028f5080e72742acb23e872975fced4409ff..571c50e05cceb4077b3a6dbc0aa2051e5be4b4c2 100644 (file)
@@ -742,7 +742,7 @@ ggc_rlimit_bound (double limit)
         appears to be ignored.  Ignore such silliness.  If a limit
         this small was actually effective for mmap, GCC wouldn't even
         start up.  */
-      && rlim.rlim_cur >= 8 * 1024 * 1024)
+      && rlim.rlim_cur >= 8 * ONE_M)
     limit = rlim.rlim_cur;
 # endif /* RLIMIT_AS or RLIMIT_DATA */
 #endif /* HAVE_GETRLIMIT */
@@ -761,7 +761,7 @@ ggc_min_expand_heuristic (void)
 
   /* The heuristic is a percentage equal to 30% + 70%*(RAM/1GB), yielding
      a lower bound of 30% and an upper bound of 100% (when RAM >= 1GB).  */
-  min_expand /= 1024*1024*1024;
+  min_expand /= ONE_G;
   min_expand *= 70;
   min_expand = MIN (min_expand, 70);
   min_expand += 30;
@@ -776,8 +776,8 @@ ggc_min_heapsize_heuristic (void)
   double phys_kbytes = physmem_total ();
   double limit_kbytes = ggc_rlimit_bound (phys_kbytes * 2);
 
-  phys_kbytes /= 1024; /* Convert to Kbytes.  */
-  limit_kbytes /= 1024;
+  phys_kbytes /= ONE_K; /* Convert to Kbytes.  */
+  limit_kbytes /= ONE_K;
 
   /* The heuristic is RAM/8, with a lower bound of 4M and an upper
      bound of 128M (when RAM >= 1GB).  */
@@ -790,7 +790,7 @@ ggc_min_heapsize_heuristic (void)
    struct rlimit rlim;
    if (getrlimit (RLIMIT_RSS, &rlim) == 0
        && rlim.rlim_cur != (rlim_t) RLIM_INFINITY)
-     phys_kbytes = MIN (phys_kbytes, rlim.rlim_cur / 1024);
+     phys_kbytes = MIN (phys_kbytes, rlim.rlim_cur / ONE_K);
  }
 # endif
 
@@ -798,12 +798,12 @@ ggc_min_heapsize_heuristic (void)
      *next* GC would be within 20Mb of the limit or within a quarter of
      the limit, whichever is larger.  If GCC does hit the data limit,
      compilation will fail, so this tries to be conservative.  */
-  limit_kbytes = MAX (0, limit_kbytes - MAX (limit_kbytes / 4, 20 * 1024));
+  limit_kbytes = MAX (0, limit_kbytes - MAX (limit_kbytes / 4, 20 * ONE_K));
   limit_kbytes = (limit_kbytes * 100) / (110 + ggc_min_expand_heuristic ());
   phys_kbytes = MIN (phys_kbytes, limit_kbytes);
 
-  phys_kbytes = MAX (phys_kbytes, 4 * 1024);
-  phys_kbytes = MIN (phys_kbytes, 128 * 1024);
+  phys_kbytes = MAX (phys_kbytes, 4 * ONE_K);
+  phys_kbytes = MIN (phys_kbytes, 128 * ONE_K);
 
   return phys_kbytes;
 }
index 9405f033a7c13180f91d36849d671a6335e6a521..07e108f3e9d370cf49bb5f84ffe5c7ba9110ddb4 100644 (file)
@@ -2184,7 +2184,7 @@ ggc_collect (void)
      total allocations haven't expanded much since the last
      collection.  */
   float allocated_last_gc =
-    MAX (G.allocated_last_gc, (size_t)param_ggc_min_heapsize * 1024);
+    MAX (G.allocated_last_gc, (size_t)param_ggc_min_heapsize * ONE_K);
 
   /* It is also good time to get memory block pool into limits.  */
   memory_block_pool::trim ();
index 4f0482be25d7b06ad329afef17ee02bbd3c16620..b0f3f1dd019d8c32056c3d91b500cc33932e6d8c 100644 (file)
@@ -1237,6 +1237,7 @@ void gcc_stablesort (void *, size_t, size_t,
 
 #define ONE_K 1024
 #define ONE_M (ONE_K * ONE_K)
+#define ONE_G (ONE_K * ONE_M)
 
 /* Display a number as an integer multiple of either:
    - 1024, if said integer is >= to 10 K (in base 2)