tests/tcg/multiarch/float_helpers.c | 13 ++++++++++++- tests/tcg/multiarch/linux-test.c | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-)
Signed-off-by: Taylor Simpson <tsimpson@quicinc.com>
---
tests/tcg/multiarch/float_helpers.c | 13 ++++++++++++-
tests/tcg/multiarch/linux-test.c | 2 +-
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/tests/tcg/multiarch/float_helpers.c b/tests/tcg/multiarch/float_helpers.c
index 8ee7903..437247c 100644
--- a/tests/tcg/multiarch/float_helpers.c
+++ b/tests/tcg/multiarch/float_helpers.c
@@ -26,6 +26,17 @@
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+/*----------------------------------------------------------------------------
+| The macro QEMU_GNUC_PREREQ tests for minimum version of the GNU C compiler.
+| The code is a copy of SOFTFLOAT_GNUC_PREREQ, see softfloat-macros.h.
+*----------------------------------------------------------------------------*/
+#if defined(__GNUC__) && defined(__GNUC_MINOR__)
+# define QEMU_GNUC_PREREQ(maj, min) \
+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+#else
+# define QEMU_GNUC_PREREQ(maj, min) 0
+#endif
+
/*
* Half Precision Numbers
*
@@ -79,7 +90,7 @@ char *fmt_16(uint16_t num)
#ifndef SNANF
/* Signaling NaN macros, if supported. */
-# if __GNUC_PREREQ(3, 3)
+# if defined(__clang__) || QEMU_GNUC_PREREQ(3, 3)
# define SNANF (__builtin_nansf (""))
# define SNAN (__builtin_nans (""))
# define SNANL (__builtin_nansl (""))
diff --git a/tests/tcg/multiarch/linux-test.c b/tests/tcg/multiarch/linux-test.c
index 673d7c8..edfc02c 100644
--- a/tests/tcg/multiarch/linux-test.c
+++ b/tests/tcg/multiarch/linux-test.c
@@ -485,7 +485,7 @@ static void test_signal(void)
act.sa_flags = SA_SIGINFO;
chk_error(sigaction(SIGSEGV, &act, NULL));
if (setjmp(jmp_env) == 0) {
- *(uint8_t *)0 = 0;
+ *(volatile uint8_t *)0 = 0;
}
act.sa_handler = SIG_DFL;
--
2.7.4
Patchew URL: https://patchew.org/QEMU/1573792691-398-1-git-send-email-tsimpson@quicinc.com/ Hi, This series seems to have some coding style problems. See output below for more information: Subject: [PATCH] Modify tests to work with clang Type: series Message-id: 1573792691-398-1-git-send-email-tsimpson@quicinc.com === TEST SCRIPT BEGIN === #!/bin/bash git rev-parse base > /dev/null || exit 0 git config --local diff.renamelimit 0 git config --local diff.renames True git config --local diff.algorithm histogram ./scripts/checkpatch.pl --mailback base.. === TEST SCRIPT END === Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test' 40fa5c0 Modify tests to work with clang === OUTPUT BEGIN === WARNING: Block comments use a leading /* on a separate line #18: FILE: tests/tcg/multiarch/float_helpers.c:29: +/*---------------------------------------------------------------------------- WARNING: Block comments use * on subsequent lines #19: FILE: tests/tcg/multiarch/float_helpers.c:30: +/*---------------------------------------------------------------------------- +| The macro QEMU_GNUC_PREREQ tests for minimum version of the GNU C compiler. WARNING: Block comments use a trailing */ on a separate line #21: FILE: tests/tcg/multiarch/float_helpers.c:32: +*----------------------------------------------------------------------------*/ WARNING: architecture specific defines should be avoided #22: FILE: tests/tcg/multiarch/float_helpers.c:33: +#if defined(__GNUC__) && defined(__GNUC_MINOR__) WARNING: architecture specific defines should be avoided #37: FILE: tests/tcg/multiarch/float_helpers.c:93: +# if defined(__clang__) || QEMU_GNUC_PREREQ(3, 3) ERROR: Use of volatile is usually wrong, please add a comment #50: FILE: tests/tcg/multiarch/linux-test.c:488: + *(volatile uint8_t *)0 = 0; total: 1 errors, 5 warnings, 33 lines checked Commit 40fa5c0d7a1b (Modify tests to work with clang) has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS. === OUTPUT END === Test command exited with code: 1 The full log is available at http://patchew.org/logs/1573792691-398-1-git-send-email-tsimpson@quicinc.com/testing.checkpatch/?type=message. --- Email generated automatically by Patchew [https://patchew.org/]. Please send your feedback to patchew-devel@redhat.com
On 15/11/2019 05.38, Taylor Simpson wrote: > Signed-off-by: Taylor Simpson <tsimpson@quicinc.com> > --- > tests/tcg/multiarch/float_helpers.c | 13 ++++++++++++- > tests/tcg/multiarch/linux-test.c | 2 +- > 2 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/tests/tcg/multiarch/float_helpers.c b/tests/tcg/multiarch/float_helpers.c > index 8ee7903..437247c 100644 > --- a/tests/tcg/multiarch/float_helpers.c > +++ b/tests/tcg/multiarch/float_helpers.c > @@ -26,6 +26,17 @@ > > #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) > > +/*---------------------------------------------------------------------------- > +| The macro QEMU_GNUC_PREREQ tests for minimum version of the GNU C compiler. > +| The code is a copy of SOFTFLOAT_GNUC_PREREQ, see softfloat-macros.h. > +*----------------------------------------------------------------------------*/ > +#if defined(__GNUC__) && defined(__GNUC_MINOR__) > +# define QEMU_GNUC_PREREQ(maj, min) \ > + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) > +#else > +# define QEMU_GNUC_PREREQ(maj, min) 0 > +#endif > + > /* > * Half Precision Numbers > * > @@ -79,7 +90,7 @@ char *fmt_16(uint16_t num) > > #ifndef SNANF > /* Signaling NaN macros, if supported. */ > -# if __GNUC_PREREQ(3, 3) > +# if defined(__clang__) || QEMU_GNUC_PREREQ(3, 3) IIRC clearly, Clang reports itself as GCC 4.2, so you certainly don't need the defined(__clang__) here. But additionally, we require at least GCC 4.8 to compile QEMU these days (see the check in the configure script), so you can even remove this #if statement completely, so that the following #defines are simply always used. Thomas
Taylor Simpson <tsimpson@quicinc.com> writes: > Signed-off-by: Taylor Simpson <tsimpson@quicinc.com> > --- > tests/tcg/multiarch/float_helpers.c | 13 ++++++++++++- > tests/tcg/multiarch/linux-test.c | 2 +- > 2 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/tests/tcg/multiarch/float_helpers.c b/tests/tcg/multiarch/float_helpers.c > index 8ee7903..437247c 100644 > --- a/tests/tcg/multiarch/float_helpers.c > +++ b/tests/tcg/multiarch/float_helpers.c <snip> > diff --git a/tests/tcg/multiarch/linux-test.c b/tests/tcg/multiarch/linux-test.c > index 673d7c8..edfc02c 100644 > --- a/tests/tcg/multiarch/linux-test.c > +++ b/tests/tcg/multiarch/linux-test.c > @@ -485,7 +485,7 @@ static void test_signal(void) > act.sa_flags = SA_SIGINFO; > chk_error(sigaction(SIGSEGV, &act, NULL)); > if (setjmp(jmp_env) == 0) { > - *(uint8_t *)0 = 0; > + *(volatile uint8_t *)0 = 0; This looks suspicious - volatile is almost never the answer to a question. What are we trying to achieve here? > } > > act.sa_handler = SIG_DFL; -- Alex Bennée
Without volatile, clang turns that statement into a call to abort. It is discussed here (Chris Lattner's blog from 2011) http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html Here is the relevant paragraph If you're using an LLVM-based compiler, you can dereference a "volatile" null pointer to get a crash if that's what you're looking for, since volatile loads and stores are generally not touched by the optimizer. There is currently no flag that enables random NULL pointer loads to be treated as valid accesses or to make random loads know that their pointer is "allowed to be null". Taylor -----Original Message----- From: Alex Bennée <alex.bennee@linaro.org> Sent: Friday, November 15, 2019 6:17 AM To: Taylor Simpson <tsimpson@quicinc.com> Cc: qemu-devel@nongnu.org Subject: Re: [PATCH] Modify tests to work with clang ------------------------------------------------------------------------- CAUTION: This email originated from outside of the organization. ------------------------------------------------------------------------- Taylor Simpson <tsimpson@quicinc.com> writes: > Signed-off-by: Taylor Simpson <tsimpson@quicinc.com> > --- > tests/tcg/multiarch/float_helpers.c | 13 ++++++++++++- > tests/tcg/multiarch/linux-test.c | 2 +- > 2 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/tests/tcg/multiarch/float_helpers.c > b/tests/tcg/multiarch/float_helpers.c > index 8ee7903..437247c 100644 > --- a/tests/tcg/multiarch/float_helpers.c > +++ b/tests/tcg/multiarch/float_helpers.c <snip> > diff --git a/tests/tcg/multiarch/linux-test.c > b/tests/tcg/multiarch/linux-test.c > index 673d7c8..edfc02c 100644 > --- a/tests/tcg/multiarch/linux-test.c > +++ b/tests/tcg/multiarch/linux-test.c > @@ -485,7 +485,7 @@ static void test_signal(void) > act.sa_flags = SA_SIGINFO; > chk_error(sigaction(SIGSEGV, &act, NULL)); > if (setjmp(jmp_env) == 0) { > - *(uint8_t *)0 = 0; > + *(volatile uint8_t *)0 = 0; This looks suspicious - volatile is almost never the answer to a question. What are we trying to achieve here? > } > > act.sa_handler = SIG_DFL; -- Alex Bennée
© 2016 - 2024 Red Hat, Inc.