From nobody Sun May 5 06:16:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537978077281868.2905861306667; Wed, 26 Sep 2018 09:07:57 -0700 (PDT) Received: from localhost ([::1]:59591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CLz-0003FV-DG for importer@patchew.org; Wed, 26 Sep 2018 12:07:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60273) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5CEa-0004hh-BK for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:00:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5CEV-0002pe-AQ for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:00:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40424) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g5CEU-0002mS-OK for qemu-devel@nongnu.org; Wed, 26 Sep 2018 12:00:10 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2EACDC06021E; Wed, 26 Sep 2018 16:00:09 +0000 (UTC) Received: from thuth.com (ovpn-116-22.ams2.redhat.com [10.36.116.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B2B46B659; Wed, 26 Sep 2018 16:00:06 +0000 (UTC) From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 17:59:46 +0200 Message-Id: <1537977586-21093-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 26 Sep 2018 16:00:09 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] qemu/compiler: Wrap __attribute__((flatten)) in a macro X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Older versions of Clang (before 3.5) and GCC (before 4.1) do not support the "__attribute__((flatten))" yet. Since at least Clang 3.4 is still used in EPEL for RHEL7 / CentOS 7, we should not use this attribute directly but with a wrapper macro instead. Signed-off-by: Thomas Huth Reviewed-by: Richard Henderson --- fpu/softfloat.c | 30 +++++++++++++++--------------- include/qemu/compiler.h | 15 +++++++++++++++ 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 59ca356..b75ca07 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -726,7 +726,7 @@ static FloatParts addsub_floats(FloatParts a, FloatPart= s b, bool subtract, * IEC/IEEE Standard for Binary Floating-Point Arithmetic. */ =20 -float16 __attribute__((flatten)) float16_add(float16 a, float16 b, +float16 QEMU_FLATTEN float16_add(float16 a, float16 b, float_status *status) { FloatParts pa =3D float16_unpack_canonical(a, status); @@ -736,7 +736,7 @@ float16 __attribute__((flatten)) float16_add(float16 a= , float16 b, return float16_round_pack_canonical(pr, status); } =20 -float32 __attribute__((flatten)) float32_add(float32 a, float32 b, +float32 QEMU_FLATTEN float32_add(float32 a, float32 b, float_status *status) { FloatParts pa =3D float32_unpack_canonical(a, status); @@ -746,7 +746,7 @@ float32 __attribute__((flatten)) float32_add(float32 a,= float32 b, return float32_round_pack_canonical(pr, status); } =20 -float64 __attribute__((flatten)) float64_add(float64 a, float64 b, +float64 QEMU_FLATTEN float64_add(float64 a, float64 b, float_status *status) { FloatParts pa =3D float64_unpack_canonical(a, status); @@ -756,7 +756,7 @@ float64 __attribute__((flatten)) float64_add(float64 a,= float64 b, return float64_round_pack_canonical(pr, status); } =20 -float16 __attribute__((flatten)) float16_sub(float16 a, float16 b, +float16 QEMU_FLATTEN float16_sub(float16 a, float16 b, float_status *status) { FloatParts pa =3D float16_unpack_canonical(a, status); @@ -766,7 +766,7 @@ float16 __attribute__((flatten)) float16_sub(float16 a,= float16 b, return float16_round_pack_canonical(pr, status); } =20 -float32 __attribute__((flatten)) float32_sub(float32 a, float32 b, +float32 QEMU_FLATTEN float32_sub(float32 a, float32 b, float_status *status) { FloatParts pa =3D float32_unpack_canonical(a, status); @@ -776,7 +776,7 @@ float32 __attribute__((flatten)) float32_sub(float32 a,= float32 b, return float32_round_pack_canonical(pr, status); } =20 -float64 __attribute__((flatten)) float64_sub(float64 a, float64 b, +float64 QEMU_FLATTEN float64_sub(float64 a, float64 b, float_status *status) { FloatParts pa =3D float64_unpack_canonical(a, status); @@ -835,7 +835,7 @@ static FloatParts mul_floats(FloatParts a, FloatParts b= , float_status *s) g_assert_not_reached(); } =20 -float16 __attribute__((flatten)) float16_mul(float16 a, float16 b, +float16 QEMU_FLATTEN float16_mul(float16 a, float16 b, float_status *status) { FloatParts pa =3D float16_unpack_canonical(a, status); @@ -845,7 +845,7 @@ float16 __attribute__((flatten)) float16_mul(float16 a,= float16 b, return float16_round_pack_canonical(pr, status); } =20 -float32 __attribute__((flatten)) float32_mul(float32 a, float32 b, +float32 QEMU_FLATTEN float32_mul(float32 a, float32 b, float_status *status) { FloatParts pa =3D float32_unpack_canonical(a, status); @@ -855,7 +855,7 @@ float32 __attribute__((flatten)) float32_mul(float32 a,= float32 b, return float32_round_pack_canonical(pr, status); } =20 -float64 __attribute__((flatten)) float64_mul(float64 a, float64 b, +float64 QEMU_FLATTEN float64_mul(float64 a, float64 b, float_status *status) { FloatParts pa =3D float64_unpack_canonical(a, status); @@ -1068,7 +1068,7 @@ static FloatParts muladd_floats(FloatParts a, FloatPa= rts b, FloatParts c, return a; } =20 -float16 __attribute__((flatten)) float16_muladd(float16 a, float16 b, floa= t16 c, +float16 QEMU_FLATTEN float16_muladd(float16 a, float16 b, float16 c, int flags, float_status *s= tatus) { FloatParts pa =3D float16_unpack_canonical(a, status); @@ -1079,7 +1079,7 @@ float16 __attribute__((flatten)) float16_muladd(float= 16 a, float16 b, float16 c, return float16_round_pack_canonical(pr, status); } =20 -float32 __attribute__((flatten)) float32_muladd(float32 a, float32 b, floa= t32 c, +float32 QEMU_FLATTEN float32_muladd(float32 a, float32 b, float32 c, int flags, float_status *s= tatus) { FloatParts pa =3D float32_unpack_canonical(a, status); @@ -1090,7 +1090,7 @@ float32 __attribute__((flatten)) float32_muladd(float= 32 a, float32 b, float32 c, return float32_round_pack_canonical(pr, status); } =20 -float64 __attribute__((flatten)) float64_muladd(float64 a, float64 b, floa= t64 c, +float64 QEMU_FLATTEN float64_muladd(float64 a, float64 b, float64 c, int flags, float_status *s= tatus) { FloatParts pa =3D float64_unpack_canonical(a, status); @@ -2402,21 +2402,21 @@ static FloatParts sqrt_float(FloatParts a, float_st= atus *s, const FloatFmt *p) return a; } =20 -float16 __attribute__((flatten)) float16_sqrt(float16 a, float_status *sta= tus) +float16 QEMU_FLATTEN float16_sqrt(float16 a, float_status *status) { FloatParts pa =3D float16_unpack_canonical(a, status); FloatParts pr =3D sqrt_float(pa, status, &float16_params); return float16_round_pack_canonical(pr, status); } =20 -float32 __attribute__((flatten)) float32_sqrt(float32 a, float_status *sta= tus) +float32 QEMU_FLATTEN float32_sqrt(float32 a, float_status *status) { FloatParts pa =3D float32_unpack_canonical(a, status); FloatParts pr =3D sqrt_float(pa, status, &float32_params); return float32_round_pack_canonical(pr, status); } =20 -float64 __attribute__((flatten)) float64_sqrt(float64 a, float_status *sta= tus) +float64 QEMU_FLATTEN float64_sqrt(float64 a, float_status *status) { FloatParts pa =3D float64_unpack_canonical(a, status); FloatParts pr =3D sqrt_float(pa, status, &float64_params); diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index 5843812..7753ee8 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -119,6 +119,21 @@ #define GCC_FMT_ATTR(n, m) #endif =20 +/* + * Clang 3.4 claims to be compatible with GCC 4.2, but does not have the + * "flatten" attribute, so we've got to handle Clang via __has_attribute h= ere + */ +#if defined(__clang__) && defined(__has_attribute) +# if __has_attribute(flatten) +# define QEMU_FLATTEN __attribute__((flatten)) +# endif +#elif !defined(__clang__) && QEMU_GNUC_PREREQ(4, 1) +# define QEMU_FLATTEN __attribute__((flatten)) +#endif +#ifndef QEMU_FLATTEN +# define QEMU_FLATTEN +#endif + #ifndef __has_feature #define __has_feature(x) 0 /* compatibility with non-clang compilers */ #endif --=20 1.8.3.1