From: Julian Seward Date: Mon, 7 Feb 2005 03:11:17 +0000 (+0000) Subject: More typechecker police. Hopefully this doesn't break anything. X-Git-Tag: svn/VALGRIND_3_0_1^2~473 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2955c11bc3475cc45199ea5a6919d4f9b00681f6;p=thirdparty%2Fvalgrind.git More typechecker police. Hopefully this doesn't break anything. git-svn-id: svn://svn.valgrind.org/vex/trunk@861 --- diff --git a/VEX/priv/guest-amd64/gdefs.h b/VEX/priv/guest-amd64/gdefs.h index 568444fd3a..4763aa0dfa 100644 --- a/VEX/priv/guest-amd64/gdefs.h +++ b/VEX/priv/guest-amd64/gdefs.h @@ -54,7 +54,7 @@ IRBB* bbToIR_AMD64 ( UChar* amd64code, /* Used by the optimiser to specialise calls to helpers. */ extern -IRExpr* guest_amd64_spechelper ( Char* function_name, +IRExpr* guest_amd64_spechelper ( HChar* function_name, IRExpr** args ); /* Describes to the optimiser which part of the guest state require diff --git a/VEX/priv/guest-amd64/ghelpers.c b/VEX/priv/guest-amd64/ghelpers.c index 1c15a3e474..7ea8c013b7 100644 --- a/VEX/priv/guest-amd64/ghelpers.c +++ b/VEX/priv/guest-amd64/ghelpers.c @@ -73,7 +73,7 @@ ULong amd64g_calculate_condition ( } -IRExpr* guest_amd64_spechelper ( Char* function_name, +IRExpr* guest_amd64_spechelper ( HChar* function_name, IRExpr** args ) { return NULL; diff --git a/VEX/priv/guest-arm/gdefs.h b/VEX/priv/guest-arm/gdefs.h index 7377fcf827..101e69eb06 100644 --- a/VEX/priv/guest-arm/gdefs.h +++ b/VEX/priv/guest-arm/gdefs.h @@ -55,7 +55,7 @@ IRBB* bbToIR_ARM ( UChar* armCode, /* Used by the optimiser to specialise calls to helpers. */ extern -IRExpr* guest_arm_spechelper ( Char* function_name, +IRExpr* guest_arm_spechelper ( HChar* function_name, IRExpr** args ); /* Describes to the optimser which part of the guest state require diff --git a/VEX/priv/guest-arm/ghelpers.c b/VEX/priv/guest-arm/ghelpers.c index 9c5ea4ce56..de19f2d905 100644 --- a/VEX/priv/guest-arm/ghelpers.c +++ b/VEX/priv/guest-arm/ghelpers.c @@ -296,7 +296,7 @@ static Bool isU32 ( IRExpr* e, UInt n ) && e->Iex.Const.con->Ico.U32 == n; } #endif -IRExpr* guest_arm_spechelper ( Char* function_name, +IRExpr* guest_arm_spechelper ( HChar* function_name, IRExpr** args ) { return NULL; diff --git a/VEX/priv/guest-ppc32/gdefs.h b/VEX/priv/guest-ppc32/gdefs.h index 5f4887e644..188ee4c9cb 100644 --- a/VEX/priv/guest-ppc32/gdefs.h +++ b/VEX/priv/guest-ppc32/gdefs.h @@ -55,8 +55,8 @@ IRBB* bbToIR_PPC32 ( UChar* ppc32code, /* Used by the optimiser to specialise calls to helpers. */ extern -IRExpr* guest_ppc32_spechelper ( Char* function_name, - IRExpr** args ); +IRExpr* guest_ppc32_spechelper ( HChar* function_name, + IRExpr** args ); /* Describes to the optimser which part of the guest state require precise memory exceptions. This is logically part of the guest diff --git a/VEX/priv/guest-ppc32/ghelpers.c b/VEX/priv/guest-ppc32/ghelpers.c index b30f117a45..efc8f2d268 100644 --- a/VEX/priv/guest-ppc32/ghelpers.c +++ b/VEX/priv/guest-ppc32/ghelpers.c @@ -187,8 +187,8 @@ static Bool isU32 ( IRExpr* e, UInt n ) && e->Iex.Const.con->Ico.U32 == n; } #endif -IRExpr* guest_ppc32_spechelper ( Char* function_name, - IRExpr** args ) +IRExpr* guest_ppc32_spechelper ( HChar* function_name, + IRExpr** args ) { return NULL; } diff --git a/VEX/priv/guest-x86/gdefs.h b/VEX/priv/guest-x86/gdefs.h index 413881c0cd..c698353283 100644 --- a/VEX/priv/guest-x86/gdefs.h +++ b/VEX/priv/guest-x86/gdefs.h @@ -57,7 +57,7 @@ IRBB* bbToIR_X86 ( UChar* x86code, /* Used by the optimiser to specialise calls to helpers. */ extern -IRExpr* guest_x86_spechelper ( Char* function_name, +IRExpr* guest_x86_spechelper ( HChar* function_name, IRExpr** args ); /* Describes to the optimser which part of the guest state require diff --git a/VEX/priv/guest-x86/ghelpers.c b/VEX/priv/guest-x86/ghelpers.c index 3cb86bfabe..c3ba8ea7e2 100644 --- a/VEX/priv/guest-x86/ghelpers.c +++ b/VEX/priv/guest-x86/ghelpers.c @@ -730,7 +730,7 @@ static Bool isU32 ( IRExpr* e, UInt n ) && e->Iex.Const.con->Ico.U32 == n; } -IRExpr* guest_x86_spechelper ( Char* function_name, +IRExpr* guest_x86_spechelper ( HChar* function_name, IRExpr** args ) { # define unop(_op,_a1) IRExpr_Unop((_op),(_a1)) diff --git a/VEX/priv/host-generic/h_generic_regs.h b/VEX/priv/host-generic/h_generic_regs.h index e41c9c4306..fb92bbb1ed 100644 --- a/VEX/priv/host-generic/h_generic_regs.h +++ b/VEX/priv/host-generic/h_generic_regs.h @@ -122,7 +122,7 @@ static inline UInt hregNumber ( HReg r ) { } static inline Bool hregIsVirtual ( HReg r ) { - return (((UInt)r) & (1<<24)) ? True : False; + return toBool(((UInt)r) & (1<<24)); } diff --git a/VEX/priv/main/vex_globals.c b/VEX/priv/main/vex_globals.c index a5141aa2ca..4cd1a75fb3 100644 --- a/VEX/priv/main/vex_globals.c +++ b/VEX/priv/main/vex_globals.c @@ -50,7 +50,7 @@ __attribute__ ((noreturn)) void (*vex_failure_exit) ( void ) = NULL; /* logging output function */ -void (*vex_log_bytes) ( Char*, Int nbytes ) = NULL; +void (*vex_log_bytes) ( HChar*, Int nbytes ) = NULL; /* debug paranoia level */ Int vex_debuglevel = 0; diff --git a/VEX/priv/main/vex_globals.h b/VEX/priv/main/vex_globals.h index 50c211239f..a31a29655a 100644 --- a/VEX/priv/main/vex_globals.h +++ b/VEX/priv/main/vex_globals.h @@ -51,7 +51,7 @@ __attribute__ ((noreturn)) extern void (*vex_failure_exit) ( void ); /* logging output function */ -extern void (*vex_log_bytes) ( Char*, Int nbytes ); +extern void (*vex_log_bytes) ( HChar*, Int nbytes ); /* debug paranoia level */ extern Int vex_debuglevel; diff --git a/VEX/priv/main/vex_util.c b/VEX/priv/main/vex_util.c index 3cac891ad2..70f3386962 100644 --- a/VEX/priv/main/vex_util.c +++ b/VEX/priv/main/vex_util.c @@ -92,7 +92,7 @@ void* LibVEX_Alloc ( Int nbytes ) vassert(vex_initdone); vassert(nbytes >= 0); if (vex_valgrind_support) { - /* ugly hack */ + /* ugly hack -- do not remove */ extern void* malloc ( int ); return malloc(nbytes); } else { @@ -144,8 +144,8 @@ void LibVEX_ShowAllocStats ( void ) /*---------------------------------------------------------*/ __attribute__ ((noreturn)) -void vex_assert_fail ( const Char* expr, - const Char* file, Int line, const Char* fn ) +void vex_assert_fail ( const HChar* expr, + const HChar* file, Int line, const HChar* fn ) { vex_printf( "\nvex: %s:%d (%s): Assertion `%s' failed.\n", file, line, fn, expr ); @@ -180,22 +180,22 @@ void vpanic ( HChar* str ) (Checker itself was GPL'd.) ------------------------------------------------------------------ */ -static Char vex_toupper ( Char c ) +static HChar vex_toupper ( HChar c ) { if (c >= 'a' && c <= 'z') - return c + ('A' - 'a'); + return toHChar(c + ('A' - 'a')); else return c; } -static Int vex_strlen ( const Char* str ) +static Int vex_strlen ( const HChar* str ) { Int i = 0; while (str[i] != 0) i++; return i; } -Bool vex_streq ( const Char* s1, const Char* s2 ) +Bool vex_streq ( const HChar* s1, const HChar* s2 ) { while (True) { if (*s1 == 0 && *s2 == 0) @@ -216,10 +216,10 @@ Bool vex_streq ( const Char* s1, const Char* s2 ) /* Copy a string into the buffer. */ static UInt -myvprintf_str ( void(*send)(Char), Int flags, Int width, Char* str, +myvprintf_str ( void(*send)(HChar), Int flags, Int width, HChar* str, Bool capitalise ) { -# define MAYBE_TOUPPER(ch) (capitalise ? vex_toupper(ch) : (ch)) +# define MAYBE_TOUPPER(ch) toHChar(capitalise ? vex_toupper(ch) : (ch)) UInt ret = 0; Int i, extra; Int len = vex_strlen(str); @@ -265,14 +265,14 @@ myvprintf_str ( void(*send)(Char), Int flags, Int width, Char* str, * WIDTH is the width of the field. */ static UInt -myvprintf_int64 ( void(*send)(Char), Int flags, Int base, Int width, ULong p) +myvprintf_int64 ( void(*send)(HChar), Int flags, Int base, Int width, ULong p) { - Char buf[40]; - Int ind = 0; - Int i, nc = 0; - Bool neg = False; - Char *digits = "0123456789ABCDEF"; - UInt ret = 0; + HChar buf[40]; + Int ind = 0; + Int i, nc = 0; + Bool neg = False; + HChar *digits = "0123456789ABCDEF"; + UInt ret = 0; if (base < 2 || base > 16) return ret; @@ -303,7 +303,7 @@ myvprintf_int64 ( void(*send)(Char), Int flags, Int base, Int width, ULong p) if (width > 0 && !(flags & VG_MSG_LJUSTIFY)) { for(; ind < width; ind++) { vassert(ind < 39); - buf[ind] = (flags & VG_MSG_ZJUSTIFY) ? '0': ' '; + buf[ind] = toHChar((flags & VG_MSG_ZJUSTIFY) ? '0': ' '); } } @@ -324,7 +324,7 @@ myvprintf_int64 ( void(*send)(Char), Int flags, Int base, Int width, ULong p) /* A simple vprintf(). */ static -UInt vprintf_wrk ( void(*send)(Char), const Char *format, va_list vargs ) +UInt vprintf_wrk ( void(*send)(HChar), const HChar *format, va_list vargs ) { UInt ret = 0; int i; @@ -420,12 +420,13 @@ UInt vprintf_wrk ( void(*send)(Char), const Char *format, va_list vargs ) break; case 'c': /* %c */ ret++; - send(va_arg (vargs, int)); + send(toHChar(va_arg (vargs, int))); break; case 's': case 'S': { /* %s */ char *str = va_arg (vargs, char *); if (str == (char*) 0) str = "(null)"; - ret += myvprintf_str(send, flags, width, str, format[i]=='S'); + ret += myvprintf_str(send, flags, width, str, + toBool(format[i]=='S')); break; } # if 0 @@ -459,10 +460,10 @@ UInt vprintf_wrk ( void(*send)(Char), const Char *format, va_list vargs ) debugging info should be sent via here. The official route is to to use vg_message(). This interface is deprecated. */ -static Char myprintf_buf[1000]; -static Int n_myprintf_buf; +static HChar myprintf_buf[1000]; +static Int n_myprintf_buf; -static void add_to_myprintf_buf ( Char c ) +static void add_to_myprintf_buf ( HChar c ) { if (c == '\n' || n_myprintf_buf >= 1000-10 /*paranoia*/ ) { (*vex_log_bytes)( myprintf_buf, vex_strlen(myprintf_buf) ); @@ -495,9 +496,9 @@ UInt vex_printf ( const char *format, ... ) /* A general replacement for sprintf(). */ -static Char *vg_sprintf_ptr; +static HChar *vg_sprintf_ptr; -static void add_to_vg_sprintf_buf ( Char c ) +static void add_to_vg_sprintf_buf ( HChar c ) { *vg_sprintf_ptr++ = c; } diff --git a/VEX/priv/main/vex_util.h b/VEX/priv/main/vex_util.h index 22d1e9543c..c71e12cc14 100644 --- a/VEX/priv/main/vex_util.h +++ b/VEX/priv/main/vex_util.h @@ -55,8 +55,8 @@ __PRETTY_FUNCTION__), 0))) __attribute__ ((__noreturn__)) -extern void vex_assert_fail ( const Char* expr, const Char* file, - Int line, const Char* fn ); +extern void vex_assert_fail ( const HChar* expr, const HChar* file, + Int line, const HChar* fn ); __attribute__ ((__noreturn__)) extern void vpanic ( HChar* str ); @@ -72,7 +72,7 @@ extern UInt vex_sprintf ( HChar* buf, const HChar *format, ... ); /* String ops */ -extern Bool vex_streq ( const Char* s1, const Char* s2 ); +extern Bool vex_streq ( const HChar* s1, const HChar* s2 ); /* Storage management: clear the area, and allocate from it. */ diff --git a/VEX/pub/libvex.h b/VEX/pub/libvex.h index 54159cbd60..97709397ab 100644 --- a/VEX/pub/libvex.h +++ b/VEX/pub/libvex.h @@ -203,7 +203,7 @@ extern void LibVEX_Init ( __attribute__ ((noreturn)) void (*failure_exit) ( void ), /* logging output function */ - void (*log_bytes) ( Char*, Int nbytes ), + void (*log_bytes) ( HChar*, Int nbytes ), /* debug paranoia level */ Int debuglevel, /* Are we supporting valgrind checking? */ diff --git a/VEX/pub/libvex_basictypes.h b/VEX/pub/libvex_basictypes.h index ab08ea06af..ce8182be4d 100644 --- a/VEX/pub/libvex_basictypes.h +++ b/VEX/pub/libvex_basictypes.h @@ -82,6 +82,10 @@ static inline UChar toUChar ( Int x ) { x &= 0xFF; return (UChar)x; } +static inline HChar toHChar ( Int x ) { + x &= 0xFF; + return (HChar)x; +} static inline UShort toUShort ( Int x ) { x &= 0xFFFF; return (UShort)x; diff --git a/VEX/test_main.c b/VEX/test_main.c index 449c4c33e3..e7c23b5845 100644 --- a/VEX/test_main.c +++ b/VEX/test_main.c @@ -31,7 +31,7 @@ void failure_exit ( void ) } static -void log_bytes ( Char* bytes, Int nbytes ) +void log_bytes ( HChar* bytes, Int nbytes ) { fwrite ( bytes, 1, nbytes, stdout ); }