From nobody Tue Feb 10 04:03:16 2026 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=1601299194; cv=none; d=zohomail.com; s=zohoarc; b=E2ivmR8+eclDk2n4luEsckohau+xbLLKhg6OIBxAoU54hoSZ0QOWUDmGYr1atnIUoDLNYgDIEc+mf5ZZRBKqT1dwVOHEEgAAsY+bn73CUrNmgQEFZdg89agm3q77RN1GWtjM+NRwYZ/KHbEHMHqjy0IsCZgb5CxjLVJ2EdzfUFY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601299194; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=05siY0cHdlWfeeA7J6d3xMUvet3cGKDwDV5A5FHlLno=; b=CyFUbRZY5mFjLb9fLYYB2x7r7DZfV7bT3kHoVCC8RO00H/RJW0PPadRR/SRGaSLilMqYVQxkahbBRG7WJX/1+Y756sbddG0N3RVK31HWoBRfhFdIzIvJ7vC4qeR8WgaS4YS3rY92RJUWSNN8v37Mvy50QHniaUVsNY3Xa27EUag= 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 160129919438964.53885931217326; Mon, 28 Sep 2020 06:19:54 -0700 (PDT) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-208-YW9OZQCkOt-HcsM25PNF2w-1; Mon, 28 Sep 2020 09:19:49 -0400 Received: by mail-wm1-f70.google.com with SMTP id b14so345613wmj.3 for ; Mon, 28 Sep 2020 06:19:48 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (74.red-83-53-161.dynamicip.rima-tde.net. [83.53.161.74]) by smtp.gmail.com with ESMTPSA id i26sm1370291wmb.17.2020.09.28.06.19.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 06:19:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601299193; 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=05siY0cHdlWfeeA7J6d3xMUvet3cGKDwDV5A5FHlLno=; b=GYAfWeSp2kXrDSJt9mWIHaCDML5UYPCkU1ZsweJpEMdS632NSirujf68F28u8ek6mvf2Y0 euYQWL2Etyo5QVOomLUmhdaw0iWVAGcIS3AyyLbMNUct0z8lxfs8h05j3wylReRS4e6tn7 4374o5ZWnF2pvXzDTB2vU94Z5pZ4wSc= X-MC-Unique: YW9OZQCkOt-HcsM25PNF2w-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=05siY0cHdlWfeeA7J6d3xMUvet3cGKDwDV5A5FHlLno=; b=UlI8WghSDrRg6lX8bJU2QxrIlZ/xhKJ1aAM6pWl5H0TK/UA8QAF9y34CPUbek38GDL N/qhvA7E0MxL6fe+2Di4s2XqEpiVVXj5S3nx8QYga9i70oeMFn9FmbpndPtf6RLko7XI v8oDaI1fBqYL/mbozYWWliNUXxlnIGvck1dM/+u9DctLCMpL1BtD+edL29B38ergHiWo K386qyY1sTmq9lLBbIPQpTPt4fF5pnZxEmfrvePVG/zzid2YzmQ4qHKabteZcrOczVnf VQ83V+JnXBpFlTXbrAy5q5tq84IiJA2tZ1Jxi53XbSsvBt10QkbRyVC/CppAlxcWSPHh 5B2Q== X-Gm-Message-State: AOAM5303IZGUtDXvA7G+lqsjVQWGtZAB8JkdhLeRY4PermIdcdTcpCah IecJR+SfcBto+mda8ev5PX0zZxpl5l739T53fP/hUpq4BoEd4oa9tANgum6m8VTwHktGXwj86CF /SWOScY5S3dJFog== X-Received: by 2002:adf:edcc:: with SMTP id v12mr1674387wro.240.1601299187894; Mon, 28 Sep 2020 06:19:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKLPNwa34IqYdT5WX6CUVduVT7I5vLBBYwH0Iuh4tpURZlygsaB19A+gi4Tj394WDtQd/fyw== X-Received: by 2002:adf:edcc:: with SMTP id v12mr1674369wro.240.1601299187747; Mon, 28 Sep 2020 06:19:47 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Fam Zheng , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Kamil Rytarowski Subject: [PATCH v2 2/8] qemu/bswap: Replace bswapXX() by compiler __builtin_bswap() Date: Mon, 28 Sep 2020 15:19:28 +0200 Message-Id: <20200928131934.739451-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200928131934.739451-1-philmd@redhat.com> References: <20200928131934.739451-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.002 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 Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/qemu/bswap.h | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h index 8b01c38040c..41131d3d76e 100644 --- a/include/qemu/bswap.h +++ b/include/qemu/bswap.h @@ -27,32 +27,13 @@ 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 +#undef bswap16 +#define bswap16(_x) __builtin_bswap16(_x) +#undef bswap32 +#define bswap32(_x) __builtin_bswap32(_x) +#undef bswap64 +#define bswap64(_x) __builtin_bswap64(_x) #endif /* ! CONFIG_MACHINE_BSWAP_H */ =20 static inline void bswap16s(uint16_t *s) --=20 2.26.2