aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure23
-rw-r--r--coroutine-ucontext.c4
2 files changed, 25 insertions, 2 deletions
diff --git a/configure b/configure
index c65b5f6a55..1d713de8cf 100755
--- a/configure
+++ b/configure
@@ -2873,14 +2873,29 @@ if compile_prog "" "" ; then
fi
########################################
+# check whether we can disable the -Wunused-but-set-variable
+# option with a pragma (this is needed to silence a warning in
+# some versions of the valgrind VALGRIND_STACK_DEREGISTER macro.)
+# This test has to be compiled with -Werror as otherwise an
+# unknown pragma is only a warning.
+pragma_disable_unused_but_set=no
+cat > $TMPC << EOF
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+int main(void) {
+ return 0;
+}
+EOF
+if compile_prog "-Werror" "" ; then
+ pragma_disable_unused_but_set=yes
+fi
+
+########################################
# check if we have valgrind/valgrind.h
valgrind_h=no
cat > $TMPC << EOF
#include <valgrind/valgrind.h>
-#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
int main(void) {
- VALGRIND_STACK_DEREGISTER(0);
return 0;
}
EOF
@@ -3397,6 +3412,10 @@ if test "$linux_magic_h" = "yes" ; then
echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
fi
+if test "$pragma_disable_unused_but_set" = "yes" ; then
+ echo "CONFIG_PRAGMA_DISABLE_UNUSED_BUT_SET=y" >> $config_host_mak
+fi
+
if test "$valgrind_h" = "yes" ; then
echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
fi
diff --git a/coroutine-ucontext.c b/coroutine-ucontext.c
index e3c450b322..784081ab18 100644
--- a/coroutine-ucontext.c
+++ b/coroutine-ucontext.c
@@ -200,14 +200,18 @@ Coroutine *qemu_coroutine_new(void)
}
#ifdef CONFIG_VALGRIND_H
+#ifdef CONFIG_PRAGMA_DISABLE_UNUSED_BUT_SET
/* Work around an unused variable in the valgrind.h macro... */
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#endif
static inline void valgrind_stack_deregister(CoroutineUContext *co)
{
VALGRIND_STACK_DEREGISTER(co->valgrind_stack_id);
}
+#ifdef CONFIG_PRAGMA_DISABLE_UNUSED_BUT_SET
#pragma GCC diagnostic error "-Wunused-but-set-variable"
#endif
+#endif
void qemu_coroutine_delete(Coroutine *co_)
{