Re[2]: [Gc] Patch for adjusting printf actual param types

Ivan Maidanski ivmai at
Sun Oct 26 03:32:17 PST 2008


Petter Urkedal <urkedal at> wrote:
> On 2008-10-25, Ivan Maidanski wrote:
> > This patch adjusts the types of actual parameters for GC_..._printf() according to its format specifiers.
> Not to disagree with your patch, but how about imitating the C99
> standard and add the following definitions to gc.h (next to the GC_word
> typedef)?
> #define GC_PRIdWORD "ld"
> #define GC_PRIiWORD "li"
> #define GC_PRIoWORD "lo"
> #define GC_PRIuWORD "ld"
> #define GC_PRIxWORD "lx"
> #define GC_PRIXWORD "lX"
> One of the print statements below would then look like
>     GC_printf("Free list %lu (total size %"GC_PRIuWORD");\n",
> 	      i, GC_free_bytes[i]);

This is technically possible... But some tips:
- this really only matters for LLP64 targets (like Win64 where sizeof(ptr)>sizeof(long));
- printing in GC servers really the debugging and profiling purposes only (if someone wants to print, eg., number of free bytes left then he should use GC_get_free_space() call and print it manually);
- hex printing of GC_word value could be done thru "%p" modifier (AFAIK, it's portable);
- there should exist a volunteer to define these macros (across major compilers) and to use them consistently across the whole GC.

> BTW, i is already long above, no cast needed.
"i" var is unsigned (to prevent compiler warning since N_HBLK_FLS is unsigned) in my current snapshot version of GC (not CVS) - Hans still has a backlog of my suggested patches (neither committed nor rejected).


More information about the Gc mailing list