From patchwork Thu Jul 8 18:17:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 471283 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp533596jao; Thu, 8 Jul 2021 11:18:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4k9N1D46yXOfnmfchF5u97cLuoqW4mcRVyxCZ2j/RmMEOGcwHPb3bkEAGU+98E24KSByx X-Received: by 2002:a17:907:e8e:: with SMTP id ho14mr32035892ejc.330.1625768315393; Thu, 08 Jul 2021 11:18:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625768315; cv=none; d=google.com; s=arc-20160816; b=mAxMXToOzsqqbQGwsZt6MKznU1PTdJKdUhZ3OvJPkTSDgfsKGzt69XgME0PQJdJiOB EqfaHgiCIcpIczl7rDQc0tG58Ci0i4SvFdNHddvJc+1Z8j6Ujsw+/jH6HoWXHBZCrLBD SZgSvbZOt5EvPG4mMVxJ1zl2uP5L1MZjcy+ltSIaAbLaXwP4B76D7ihJB5vYMVQkI3eh N+Wsk9i7boUHsijmMKlN+6nMupdcTqWxAmyIrijBrlySFRMtE+WYR0n43mMTkOtBN6wV /LMPrdHvthASziAzyKWF6bBtIi+s2SJri4B2uBBaqj0iMyX4PgKPgg3Ey5dvtMDWGXXC Wekg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature; bh=VKlOdzea9GIUuCIW92Q/dNU3AERYUe8yKlo7djvVlCY=; b=kTiEGOeTP7u+kOXcc68R3ExKs+C0/khwMNQnGRdVx64fz9rbv/QN5jyu2hM7wAbThU Zdip9RqWBSECWEL96afKvxeco31v8dCdaWEDi2EAwshmE9Ys4Rww62E2mtz+Km9AJwm/ mRkyqIDpD+Pnv1EBSPNm001XmV8ETkFzGDtTBdXdRS3mRMz+FijUnC1XaVjEy96Pq4t8 c5o8R9mIydtX+paY2EsQqgSirLLYK72hk+asU15HUWKVZS8iNJ6JL6FVIBmQ9YmAT3zU XjIT+0pgfk1DFunkpGrPd8jJlTs0ZQi9a4TcUvPjVYOE4W2bDLuQSJGTR57KT9I4yaL3 vJMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cyFt4aTW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u5si3358042eju.85.2021.07.08.11.18.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 08 Jul 2021 11:18:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cyFt4aTW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:37586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1Yba-0006pY-Di for patch@linaro.org; Thu, 08 Jul 2021 14:18:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1Yaq-0006nC-G6 for qemu-devel@nongnu.org; Thu, 08 Jul 2021 14:17:48 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:42707) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m1Yao-0005K6-Cn for qemu-devel@nongnu.org; Thu, 08 Jul 2021 14:17:48 -0400 Received: by mail-pl1-x62d.google.com with SMTP id v13so3518845ple.9 for ; Thu, 08 Jul 2021 11:17:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=VKlOdzea9GIUuCIW92Q/dNU3AERYUe8yKlo7djvVlCY=; b=cyFt4aTWo22AwumWb0Ia3ol5JR1mb5i6KJuMfZu68JTLKLT13vOR06v4iRGteX+bSp dw1QMXuhLKZ1RHArrMNTxfETbwR0I39nIohgKONA9ZLXes8dOqwh6q3KX0fnyQoE93kx d+apiMYuP+C5gwaQGSl19rE/TVszlgNwilpk2kZlKErrQI07/EquAyxuvNvw0A31+QKf pJU2SJwASvuUwdazS/b+PMTxhZYBNtJDCDFtDeqCDE2CaaVNgg3Iix4O85pR86apD6JY BRyP/Ksu4gLqZqlk0uQozG6qP1unCRJIRBF5xHgmK/u4p6S5YnR1glw8aGODfxri3J8c HUbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=VKlOdzea9GIUuCIW92Q/dNU3AERYUe8yKlo7djvVlCY=; b=KqzbBKwxnyOwniwbJLi3Jy2BKG2My7281vJrJcUcTZxsmEOdICYg2m2u18UXbBwuPf YjSmM/gpq2E5dTl0QaeXiZFvTLQ7/rdU0mPlsfclCrBJYJFW95bEmLKoXliW1UwiaNzE F86WINNw8PlD1SRfRXSqsDiZjZlYiAGQ42LvCgzHQDeXzF7gTrw0qFxADkUc/d07kq6l eezr8vf0qVod0y21a8WzqfbN4gdZgIpeiaQdFdJF4UDKphTKL3vdlzKyt1oRHx4yC9DP ExwWMaFiRX2qhQgw2blY54Nn0FHzqHRu2NNTqcgsXkpgoLW1CEWOQqdGHFJAsJGvz9ZQ 4M3w== X-Gm-Message-State: AOAM530ONLvcU33dtFRctOmNMdBf3bou0uA5WABbdTJvF45ahk/SCnyf vThLNtWvmCuvDRtosh8Nt2X82RKbsNf76Q== X-Received: by 2002:a17:90a:5e01:: with SMTP id w1mr17133705pjf.200.1625768264796; Thu, 08 Jul 2021 11:17:44 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id p14sm3416949pfo.101.2021.07.08.11.17.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jul 2021 11:17:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH] include/qemu: Use builtins for bswap Date: Thu, 8 Jul 2021 11:17:43 -0700 Message-Id: <20210708181743.750220-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" All supported compilers have builtins for this. Drop all of the complicated system detection stuff. Signed-off-by: Richard Henderson --- meson.build | 6 ----- include/qemu/bswap.h | 53 +++----------------------------------------- 2 files changed, 3 insertions(+), 56 deletions(-) -- 2.25.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/meson.build b/meson.build index 7e12de01be..6024f2d6fb 100644 --- a/meson.build +++ b/meson.build @@ -1290,8 +1290,6 @@ config_host_data.set('HAVE_STRCHRNUL', cc.has_function('strchrnul')) config_host_data.set('HAVE_SYSTEM_FUNCTION', cc.has_function('system', prefix: '#include ')) # has_header_symbol -config_host_data.set('CONFIG_BYTESWAP_H', - cc.has_header_symbol('byteswap.h', 'bswap_32')) config_host_data.set('CONFIG_EPOLL_CREATE1', cc.has_header_symbol('sys/epoll.h', 'epoll_create1')) config_host_data.set('CONFIG_HAS_ENVIRON', @@ -1311,10 +1309,6 @@ config_host_data.set('CONFIG_INOTIFY', cc.has_header_symbol('sys/inotify.h', 'inotify_init')) config_host_data.set('CONFIG_INOTIFY1', cc.has_header_symbol('sys/inotify.h', 'inotify_init1')) -config_host_data.set('CONFIG_MACHINE_BSWAP_H', - cc.has_header_symbol('machine/bswap.h', 'bswap32', - prefix: '''#include - #include ''')) config_host_data.set('CONFIG_PRCTL_PR_SET_TIMERSLACK', cc.has_header_symbol('sys/prctl.h', 'PR_SET_TIMERSLACK')) config_host_data.set('CONFIG_RTNETLINK', diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h index 2d3bb8bbed..9e12bd8073 100644 --- a/include/qemu/bswap.h +++ b/include/qemu/bswap.h @@ -1,73 +1,26 @@ #ifndef BSWAP_H #define BSWAP_H -#ifdef CONFIG_MACHINE_BSWAP_H -# include -# include -#elif defined(__FreeBSD__) -# include -#elif defined(__HAIKU__) -# include -#elif defined(CONFIG_BYTESWAP_H) -# include -#define BSWAP_FROM_BYTESWAP -# else -#define BSWAP_FROM_FALLBACKS -#endif /* ! CONFIG_MACHINE_BSWAP_H */ - #ifdef __cplusplus extern "C" { #endif #include "fpu/softfloat-types.h" -#ifdef BSWAP_FROM_BYTESWAP static inline uint16_t bswap16(uint16_t x) { - return bswap_16(x); + return __builtin_bswap16(x); } static inline uint32_t bswap32(uint32_t x) { - return bswap_32(x); + return __builtin_bswap32(x); } static inline uint64_t bswap64(uint64_t x) { - return bswap_64(x); + return __builtin_bswap64(x); } -#endif - -#ifdef BSWAP_FROM_FALLBACKS -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)); -} -#endif - -#undef BSWAP_FROM_BYTESWAP -#undef BSWAP_FROM_FALLBACKS static inline void bswap16s(uint16_t *s) {