]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add type SizeT (moved here from valgrind's pub_tool_basics.h).
authorFlorian Krohm <florian@eich-krohm.de>
Mon, 29 Dec 2014 19:05:37 +0000 (19:05 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Mon, 29 Dec 2014 19:05:37 +0000 (19:05 +0000)
Enhance vprintf_wrk to print such values (%zu, %zx, %zX).

git-svn-id: svn://svn.valgrind.org/vex/trunk@3046

VEX/priv/main_util.c
VEX/pub/libvex_basictypes.h

index ce93ba516c0a406e6498335600bf5d8c6bf44518..9edbe35f6bbb7019ab536eb97325bb29bfa4f4c3 100644 (file)
@@ -377,7 +377,7 @@ UInt vprintf_wrk ( void(*sink)(HChar),
       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 @@ UInt vprintf_wrk ( void(*sink)(HChar),
       }
 
       saved_format = format;
-      longlong = False;
+      longlong = is_sizet = False;
       ljustify = False;
       padchar = ' ';
       fwidth = 0;
@@ -424,8 +424,11 @@ UInt vprintf_wrk ( void(*sink)(HChar),
          format++;
          if (*format == 'l') {
             format++;
-           longlong = True;
+            longlong = True;
          }
+      } else if (*format == 'z') {
+         format++;
+         is_sizet = True;
       }
 
       switch (*format) {
@@ -454,6 +457,7 @@ UInt vprintf_wrk ( void(*sink)(HChar),
          }
          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 @@ UInt vprintf_wrk ( void(*sink)(HChar),
             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);
index 8ebf5aebbd2ee57bf4c3b8430b39b82316ad2d65..09205bb3af8da967fde516eeafc11480a0de180d 100644 (file)
@@ -59,6 +59,12 @@ typedef    signed int    Int;
 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];