From nobody Sun Nov 16 16:18:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600855356; cv=none; d=zohomail.com; s=zohoarc; b=e3rzWlt0f+AuC01eZ3XaDKZMmKXuJ39BGGS3S8ASZtmnwtHYM0FCeZX4yM3LAUeHQb5Ewd4WOixvSGN7MXxUgDwZCEA5YDIPVllhuKJNbfaILOkxlFF0OflE8pYrwPEL4dzbtL1y5aLybLBPym9NVH9Fv6Y7RcTV57M1rgoN2mg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600855356; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=/e6JgH5beo3D4jWhUD/I0gOipenUtz7n5NS7zMmoHHk=; b=S6gpML7wGCBngPchw4K7inIsZZAZ/1csU29bcNIotQKAP6gPA1BSP8P8Ve6KmuKvyw/siDWWLR/bl34X0xlMeIEX9OKe2CREcH43XsD6cY3ELTHMEueYzk2cGd5c1SRn3nwtZA/WCtVUaY/x++Fc5kFLxZ4EqghrLxpPWYZwPcU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1600855356360578.3548008463788; Wed, 23 Sep 2020 03:02:36 -0700 (PDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-276-C8qzJAApNh-INP7aghtDMA-1; Wed, 23 Sep 2020 06:02:33 -0400 Received: by mail-wm1-f69.google.com with SMTP id m125so2024259wmm.7 for ; Wed, 23 Sep 2020 03:02:33 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (65.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.65]) by smtp.gmail.com with ESMTPSA id v9sm31863826wrv.35.2020.09.23.03.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 03:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600855355; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/e6JgH5beo3D4jWhUD/I0gOipenUtz7n5NS7zMmoHHk=; b=OBK5gDSjMR71kt3G04EJPC8mm/WQ1NVZxDaGOsKqp99njtXcHw8Mvoa3XeOpi3grG7L5s/ Q4orLxaoIkWbHjV0vdsLTbU+vDZ2D0Zwo1YGR2m2zHfiXjlaAPxMG85RkN7QB2LpoQ87OV DMEOq7GhSOhO4XAPu8rvWsMKizrT37Q= X-MC-Unique: C8qzJAApNh-INP7aghtDMA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/e6JgH5beo3D4jWhUD/I0gOipenUtz7n5NS7zMmoHHk=; b=phx01RCmPapw6HySFK6FFb1QflWcH/YW+uYdKrmICIIx6uC/Z1X8xTyPe2GeNZYPkF +H1qEPvmXusdB4enjrmkP1U16mJF/d9YYknlzXabXJtFiKk684OEk3pNGSohRPBqykRh V/uNis1v+FyixM6sW+Ik9juAmEZFTuFvwVqBGwcpovcHN1MbeleNKIpThM4jbK9j5L/l 1NFeS1ORGmQ2l+ntX6whcd6KsSrR1DJdsjNPpEiqAIpYUi7iwohT4NB2sv1saCmjcfKu coQTKugcB/a3zdH3yKQuv0EoEyw+XhXIdm+pxKWOcsfX7uZ+bPSpSyHTXHZhulUWfA+7 dNHw== X-Gm-Message-State: AOAM533RwScZxQV0pJGtlKeyAtzy00mM6ES6b3Jf8pA9tRDAKMeMnlQ0 Wm8Eq/rHSP8GYCuhnZcWhmtw0PuCGjrl7Sg/z2zIa2Uk5ypsWI45OV7b63VxHRHJQzkwJTkRiiC mKHhKcfRDMk33qA== X-Received: by 2002:a7b:c151:: with SMTP id z17mr5888037wmi.53.1600855352197; Wed, 23 Sep 2020 03:02:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6O0Qjf8oO9lpF3SbviWLdvjTkbe0E561qxviPht1e1wza+nbmlYbMMN1VHTGZHVXBxIqnsg== X-Received: by 2002:a7b:c151:: with SMTP id z17mr5888021wmi.53.1600855352023; Wed, 23 Sep 2020 03:02:32 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 2/4] qemu/bswap: Replace bswapXX() by compiler __builtin_bswap() Date: Wed, 23 Sep 2020 12:02:18 +0200 Message-Id: <20200923100220.674903-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200923100220.674903-1-philmd@redhat.com> References: <20200923100220.674903-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Use the compiler built-in function to byte swap values, as the compiler is clever and will fold constants. Suggested-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- include/qemu/bswap.h | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h index 8b01c38040c..d1a2f700f2a 100644 --- a/include/qemu/bswap.h +++ b/include/qemu/bswap.h @@ -27,32 +27,10 @@ static inline uint64_t bswap64(uint64_t x) { return bswap_64(x); } -# else -static inline uint16_t bswap16(uint16_t x) -{ - return (((x & 0x00ff) << 8) | - ((x & 0xff00) >> 8)); -} - -static inline uint32_t bswap32(uint32_t x) -{ - return (((x & 0x000000ffU) << 24) | - ((x & 0x0000ff00U) << 8) | - ((x & 0x00ff0000U) >> 8) | - ((x & 0xff000000U) >> 24)); -} - -static inline uint64_t bswap64(uint64_t x) -{ - return (((x & 0x00000000000000ffULL) << 56) | - ((x & 0x000000000000ff00ULL) << 40) | - ((x & 0x0000000000ff0000ULL) << 24) | - ((x & 0x00000000ff000000ULL) << 8) | - ((x & 0x000000ff00000000ULL) >> 8) | - ((x & 0x0000ff0000000000ULL) >> 24) | - ((x & 0x00ff000000000000ULL) >> 40) | - ((x & 0xff00000000000000ULL) >> 56)); -} +#else +# define bswap16(_x) __builtin_bswap16(_x) +# define bswap32(_x) __builtin_bswap32(_x) +# define bswap64(_x) __builtin_bswap64(_x) #endif /* ! CONFIG_MACHINE_BSWAP_H */ =20 static inline void bswap16s(uint16_t *s) --=20 2.26.2