]> granicus.if.org Git - gc/commitdiff
Refactoring: rename GC_PRIdPTR to WARN_PRIdPTR
authorIvan Maidanski <ivmai@mail.ru>
Thu, 29 Dec 2011 06:07:14 +0000 (10:07 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 29 Dec 2011 06:07:14 +0000 (10:07 +0400)
* allchblk.c (GC_allochblk_nth): Rename GC_PRIdPTR to WARN_PRIdPTR.
* alloc.c (GC_collect_or_expand): Likewise.
* include/private/gc_priv.h (GC_PRIdPTR): Likewise.
* pthread_support.c (start_mark_threads, GC_thr_init): Likewise.
* GC_thr_init (GC_delete_thread): Likewise.
* include/private/gc_priv.h (WARN): Add comment about argument format
specifier.
* include/private/gc_priv.h (GC_PRIdPTR): Remove commented out code;
refine comment.

allchblk.c
alloc.c
include/private/gc_priv.h
pthread_support.c
win32_threads.c

index 0abfeaa0465ab102523ddef00dfbfdd76a400868..72faf5fea4fd4ac1989d993136ba0aaae91f9e74 100644 (file)
@@ -731,7 +731,7 @@ GC_allochblk_nth(size_t sz, int kind, unsigned flags, int n,
                 if (++GC_large_alloc_warn_suppressed
                     >= GC_large_alloc_warn_interval) {
                   WARN("Repeated allocation of very large block "
-                       "(appr. size %" GC_PRIdPTR "):\n"
+                       "(appr. size %" WARN_PRIdPTR "):\n"
                        "\tMay lead to memory leak and poor performance.\n",
                        size_needed);
                   GC_large_alloc_warn_suppressed = 0;
diff --git a/alloc.c b/alloc.c
index bab340b8b5121bfa5162fef2ee47d716994f2c9a..609fae0db6f0cd3389ecb5e46e7f51a00b00cf1f 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -1255,7 +1255,7 @@ GC_INNER GC_bool GC_collect_or_expand(word needed_blocks,
         GC_gcollect_inner();
       } else {
 #       if !defined(AMIGA) || !defined(GC_AMIGA_FASTALLOC)
-          WARN("Out of Memory! Heap size: %" GC_PRIdPTR " MiB."
+          WARN("Out of Memory! Heap size: %" WARN_PRIdPTR " MiB."
                " Returning NULL!\n", (GC_heapsize - GC_unmapped_bytes) >> 20);
 #       endif
         RESTORE_CANCEL(cancel_state);
index f5aaed3a797a92c0fda1d075e7f3017b481e7f25..17703040dd0dbbd7ce46a051f009c6130a8f6618 100644 (file)
@@ -455,28 +455,20 @@ typedef char * ptr_t;   /* A generic pointer to which we can add        */
 # endif
 
 /* Print warning message, e.g. almost out of memory.    */
+/* The argument (if any) format specifier should be:    */
+/* "%s", "%p" or "%"WARN_PRIdPTR.                       */
 #define WARN(msg, arg) (*GC_current_warn_proc)("GC Warning: " msg, \
                                                (GC_word)(arg))
 GC_EXTERN GC_warn_proc GC_current_warn_proc;
 
-/* Print format type macro for signed_word.  Currently used for WARN()  */
-/* only.  This could be of use on Win64 but commented out since Win64   */
-/* is only a little-endian architecture (for now) and the WARN format   */
-/* string is, possibly, processed on the client side, so non-standard   */
-/* print type modifiers should be avoided (if possible).                */
-#if defined(_MSC_VER) && defined(_WIN64) && !defined(GC_PRIdPTR)
-/* #define GC_PRIdPTR "I64d" */
-#endif
-
-#if !defined(GC_PRIdPTR) && (defined(_LLP64) || defined(__LLP64__) \
-        || defined(_WIN64))
-/* #include <inttypes.h> */
-/* #define GC_PRIdPTR PRIdPTR */
-#endif
-
-#ifndef GC_PRIdPTR
+/* Print format type macro for decimal signed_word value passed WARN(). */
+/* This could be redefined for Win64 or LLP64, but typically should     */
+/* not be done as the WARN format string is, possibly, processed on the */
+/* client side, so non-standard print type modifiers (like MS "I64d")   */
+/* should be avoided here if possible.                                  */
+#ifndef WARN_PRIdPTR
   /* Assume sizeof(void *) == sizeof(long) (or a little-endian machine) */
-# define GC_PRIdPTR "ld"
+# define WARN_PRIdPTR "ld"
 #endif
 
 /* Get environment entry */
index 610ce4bf4c04f36f4bb2fb9dfb71acffcafc8e8c..da53b5c005b2d3dfa9c8b69b398d69ac502bab85 100644 (file)
@@ -433,7 +433,7 @@ static void start_mark_threads(void)
     for (i = 0; i < GC_markers - 1; ++i) {
       if (0 != REAL_FUNC(pthread_create)(GC_mark_threads + i, &attr,
                               GC_mark_thread, (void *)(word)i)) {
-        WARN("Marker thread creation failed, errno = %" GC_PRIdPTR "\n",
+        WARN("Marker thread creation failed, errno = %" WARN_PRIdPTR "\n",
              errno);
         /* Don't try to create other marker threads.    */
         GC_markers = i + 1;
@@ -959,7 +959,7 @@ GC_INNER void GC_thr_init(void)
 #   endif
   }
   if (GC_nprocs <= 0) {
-    WARN("GC_get_nprocs() returned %" GC_PRIdPTR "\n", GC_nprocs);
+    WARN("GC_get_nprocs() returned %" WARN_PRIdPTR "\n", GC_nprocs);
     GC_nprocs = 2; /* assume dual-core */
 #   ifdef PARALLEL_MARK
       GC_markers = 1;
index c9d4c0f2144ce5fdc3a705d55189fd7eed568e81..414dcc502038988949261f9b9dc16df90be29b12 100644 (file)
@@ -667,7 +667,7 @@ STATIC void GC_delete_thread(DWORD id)
     GC_thread t = GC_lookup_thread_inner(id);
 
     if (0 == t) {
-      WARN("Removing nonexistent thread, id = %" GC_PRIdPTR "\n", id);
+      WARN("Removing nonexistent thread, id = %" WARN_PRIdPTR "\n", id);
     } else {
       GC_delete_gc_thread(t);
     }