|
From: Bart V. A. <bva...@ac...> - 2011-03-03 18:50:08
|
On Thu, Mar 3, 2011 at 7:28 PM, Tony Finch <do...@do...> wrote:
> On Thu, 3 Mar 2011, Bart Van Assche wrote:
>>
>> Does the patch below help ?
>
> Mostly, except it exposes an __attribute__ clause which also upsets
> standard-C compilers.
>
> I did the following patch which has the disadvantage of causing warnings
> about expressions without side-effects.
>
> [ ... ]
Does the second version of this patch (see below) work better ?
Index: include/valgrind.h
===================================================================
--- include/valgrind.h (revision 11577)
+++ include/valgrind.h (working copy)
@@ -4415,14 +4415,7 @@
is the number of characters printed, excluding the "**<pid>** " part at the
start and the backtrace (if present). */
-#if defined(NVALGRIND)
-
-# define VALGRIND_PRINTF(...)
-# define VALGRIND_PRINTF_BACKTRACE(...)
-
-#else /* NVALGRIND */
-
-#if !defined(_MSC_VER)
+#if defined(__GNUC__) || defined(__INTEL_COMPILER)
/* Modern GCC will optimize the static routine out if unused,
and unused attribute will shut down warnings about it. */
static int VALGRIND_PRINTF(const char *format, ...)
@@ -4434,6 +4427,9 @@
#endif
VALGRIND_PRINTF(const char *format, ...)
{
+#if defined(NVALGRIND)
+ return 0;
+#else /* NVALGRIND */
unsigned long _qzz_res;
va_list vargs;
va_start(vargs, format);
@@ -4452,9 +4448,10 @@
#endif
va_end(vargs);
return (int)_qzz_res;
+#endif /* NVALGRIND */
}
-#if !defined(_MSC_VER)
+#if defined(__GNUC__) || defined(__INTEL_COMPILER)
static int VALGRIND_PRINTF_BACKTRACE(const char *format, ...)
__attribute__((format(__printf__, 1, 2), __unused__));
#endif
@@ -4464,6 +4461,9 @@
#endif
VALGRIND_PRINTF_BACKTRACE(const char *format, ...)
{
+#if defined(NVALGRIND)
+ return 0;
+#else /* NVALGRIND */
unsigned long _qzz_res;
va_list vargs;
va_start(vargs, format);
@@ -4482,11 +4482,10 @@
#endif
va_end(vargs);
return (int)_qzz_res;
+#endif /* NVALGRIND */
}
-#endif /* NVALGRIND */
-
/* These requests allow control to move from the simulated CPU to the
real CPU, calling an arbitary function.
|