From: Florian Krohm Date: Mon, 29 Dec 2014 19:06:40 +0000 (+0000) Subject: Move definition of type SizeT to VEX (see VEX r3046). X-Git-Tag: svn/VALGRIND_3_11_0~750 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e61bbd6a9d78f1b83dc58d58ecfcf7d2400e27d0;p=thirdparty%2Fvalgrind.git Move definition of type SizeT to VEX (see VEX r3046). Enhance printeffery to print SizeT values. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14836 --- diff --git a/coregrind/m_debuglog.c b/coregrind/m_debuglog.c index 7cb1ee5db2..da31ccacf6 100644 --- a/coregrind/m_debuglog.c +++ b/coregrind/m_debuglog.c @@ -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 diff --git a/include/pub_tool_basics.h b/include/pub_tool_basics.h index 1bbabadf00..cb6beb26c3 100644 --- a/include/pub_tool_basics.h +++ b/include/pub_tool_basics.h @@ -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':