]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Move definition of type SizeT to VEX (see VEX r3046).
authorFlorian Krohm <florian@eich-krohm.de>
Mon, 29 Dec 2014 19:06:40 +0000 (19:06 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Mon, 29 Dec 2014 19:06:40 +0000 (19:06 +0000)
Enhance printeffery to print SizeT values.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14836

coregrind/m_debuglog.c
include/pub_tool_basics.h

index 7cb1ee5db23509b4c7876aa110abcf4787d40b7b..da31ccacf6f29d46b3fe9eb54f6726f9e7b4c8a3 100644 (file)
@@ -731,7 +731,7 @@ VG_(debugLog_vprintf) (
    Int  flags;
    Int  width, precision;
    Int  n_ls = 0;
-   Bool is_long, caps;
+   Bool is_long, is_sizet, caps;
 
    /* We assume that vargs has already been initialised by the 
       caller, using va_start, and that the caller will similarly
@@ -811,9 +811,15 @@ VG_(debugLog_vprintf) (
             }
          }
       }
-      while (format[i] == 'l') {
-         i++;
-         n_ls++;
+
+      is_sizet = False;
+      if (format[i] == 'z') {
+         is_sizet = True;
+      } else {
+         while (format[i] == 'l') {
+            i++;
+            n_ls++;
+         }
       }
 
       //   %d means print a 32-bit integer.
@@ -829,7 +835,10 @@ VG_(debugLog_vprintf) (
                ret += 2;
                send('0',send_arg2);
             }
-            if (is_long)
+            if (is_sizet)
+               ret += myvprintf_int64(send, send_arg2, flags, 8, width, False,
+                                      (ULong)(va_arg (vargs, SizeT)));
+            else if (is_long)
                ret += myvprintf_int64(send, send_arg2, flags, 8, width, False,
                                       (ULong)(va_arg (vargs, ULong)));
             else
@@ -846,7 +855,10 @@ VG_(debugLog_vprintf) (
                                       (ULong)(va_arg (vargs, Int)));
             break;
          case 'u': /* %u */
-            if (is_long)
+            if (is_sizet)
+               ret += myvprintf_int64(send, send_arg2, flags, 10, width, False,
+                                      (ULong)(va_arg (vargs, SizeT)));
+            else if (is_long)
                ret += myvprintf_int64(send, send_arg2, flags, 10, width, False,
                                       (ULong)(va_arg (vargs, ULong)));
             else
@@ -890,7 +902,10 @@ VG_(debugLog_vprintf) (
                send('0',send_arg2);
                send('x',send_arg2);
             }
-            if (is_long)
+            if (is_sizet)
+               ret += myvprintf_int64(send, send_arg2, flags, 16, width, False,
+                                      (ULong)(va_arg (vargs, SizeT)));
+            else if (is_long)
                ret += myvprintf_int64(send, send_arg2, flags, 16, width, caps,
                                       (ULong)(va_arg (vargs, ULong)));
             else
index 1bbabadf00daa5b49a7365a2e074fa84db75827d..cb6beb26c38498b4ce9e119cce96b281a168b869 100644 (file)
@@ -42,7 +42,7 @@
    Other headers to include
    ------------------------------------------------------------------ */
 
-// VEX defines Char, UChar, Short, UShort, Int, UInt, Long, ULong,
+// VEX defines Char, UChar, Short, UShort, Int, UInt, Long, ULong, SizeT,
 // Addr32, Addr64, HWord, HChar, Bool, False and True.
 #include "libvex_basictypes.h"
 
@@ -89,10 +89,8 @@ typedef   signed long           Word;     // 32             64
 // Addr is for holding an address.
 typedef UWord                  Addr;      // 32             64
 
-// Our equivalents of POSIX 'size_t' and 'ssize_t':
-// - size_t is an "unsigned integer type of the result of the sizeof operator".
+// Our equivalent of POSIX 'ssize_t':
 // - ssize_t is "used for a count of bytes or an error indication".
-typedef UWord                  SizeT;     // 32             64
 typedef  Word                 SSizeT;     // 32             64
 
 // Our equivalent of POSIX 'ptrdiff_t':