Add type SizeT (moved here from valgrind's pub_tool_basics.h).
Enhance vprintf_wrk to print such values (%zu, %zx, %zX).


git-svn-id: svn://svn.valgrind.org/vex/trunk@3046 8f6e269a-dfd6-0310-a8e1-e2731360e62c
diff --git a/priv/main_util.c b/priv/main_util.c
index ce93ba5..9edbe35 100644
--- a/priv/main_util.c
+++ b/priv/main_util.c
@@ -377,7 +377,7 @@
       while (0)
 
    const HChar* saved_format;
-   Bool   longlong, ljustify;
+   Bool   longlong, ljustify, is_sizet;
    HChar  padchar;
    Int    fwidth, nout, len1, len2, len3;
    HChar  intbuf[100];  /* big enough for a 64-bit # in base 2 */
@@ -397,7 +397,7 @@
       }
 
       saved_format = format;
-      longlong = False;
+      longlong = is_sizet = False;
       ljustify = False;
       padchar = ' ';
       fwidth = 0;
@@ -424,8 +424,11 @@
          format++;
          if (*format == 'l') {
             format++;
-           longlong = True;
+            longlong = True;
          }
+      } else if (*format == 'z') {
+         format++;
+         is_sizet = True;
       }
 
       switch (*format) {
@@ -454,6 +457,7 @@
          }
          case 'd': {
             Long l;
+            vassert(is_sizet == False); // %zd is obscure; we don't allow it
             if (longlong) {
                l = va_arg(ap, Long);
             } else {
@@ -474,7 +478,9 @@
             Int   base = *format == 'u' ? 10 : 16;
             Bool  hexcaps = True; /* *format == 'X'; */
             ULong l;
-            if (longlong) {
+            if (is_sizet) {
+               l = (ULong)va_arg(ap, SizeT);
+            } else if (longlong) {
                l = va_arg(ap, ULong);
             } else {
                l = (ULong)va_arg(ap, UInt);
diff --git a/pub/libvex_basictypes.h b/pub/libvex_basictypes.h
index 8ebf5ae..09205bb 100644
--- a/pub/libvex_basictypes.h
+++ b/pub/libvex_basictypes.h
@@ -59,6 +59,12 @@
 typedef  unsigned long long int   ULong;
 typedef    signed long long int   Long;
 
+/* Equivalent of C's size_t type. The type is unsigned and has this
+   storage requirement:
+   32 bits on a 32-bit architecture
+   64 bits on a 64-bit architecture. */
+typedef  unsigned long SizeT;
+
 /* Always 128 bits. */
 typedef  UInt  U128[4];