|
From: <sv...@va...> - 2014-12-29 19:05:44
|
Author: florian
Date: Mon Dec 29 19:05:37 2014
New Revision: 3046
Log:
Add type SizeT (moved here from valgrind's pub_tool_basics.h).
Enhance vprintf_wrk to print such values (%zu, %zx, %zX).
Modified:
trunk/priv/main_util.c
trunk/pub/libvex_basictypes.h
Modified: trunk/priv/main_util.c
==============================================================================
--- trunk/priv/main_util.c (original)
+++ trunk/priv/main_util.c Mon Dec 29 19:05:37 2014
@@ -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);
Modified: trunk/pub/libvex_basictypes.h
==============================================================================
--- trunk/pub/libvex_basictypes.h (original)
+++ trunk/pub/libvex_basictypes.h Mon Dec 29 19:05:37 2014
@@ -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];
|