From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8D2FCAC5B8 for ; Mon, 6 Oct 2025 12:16:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=k0dUe76w+6n5/NfsPbyefGVCom+xh3GGcFcV3Olhmks=; b=VKX39FL6prFGyxKRfwrVUVpTtD sD+20/iDjuhHQNyX0lzp1ZqPKS6x9mwTL7vzBWz60oTWWmBoeCVSGuVWvkiTFur7zUxByuNLbvzgX Kbm7XbVlJsAKsxrLTcY3uRS+2VQahODfVRWFDk67CLMh1+SS5NFiCPq6sc0e2PiNu0zPlo4XgNAvl 8dOpK4OTWte1k/ug0z6/oHljVYoTzjQLVI9JbtTJEcybSUwTgZqt7vk06qGYTmR7xGCTS/RcOcHEw JggdDSvHMIZyTILSa7pNp/suYiq7NvFW86ia4/Prth56ZGtZxFRAA3sPfPFICVHuGU9OM7+5v8v3V 3kk0/Rqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1v5k90-0000000HZSu-1M2N; Mon, 06 Oct 2025 12:16:46 +0000 Received: from fra-out-014.esa.eu-central-1.outbound.mail-perimeter.amazon.com ([18.199.210.3]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uzYQz-00000002ar2-3JqA for linux-um@lists.infradead.org; Fri, 19 Sep 2025 10:33:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1758278025; x=1789814025; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k0dUe76w+6n5/NfsPbyefGVCom+xh3GGcFcV3Olhmks=; b=Bjmh/uTLD1ujHauPWciawLpapiqHlN3eMDt9MtNaRy9sxyCLjJtcCd8A ENxwHJxGZ/ZpC9tic/GJCAmIiTKwOyvhsqflQItVFby/i91nTDeKgvpTm eqWd/taah5NQ2DO3kq8I4RSYTKDRcOuhYaHz2UQ9EyMh/A/E3DQFOTGKl mWvMiZnL/9/IBkxtpJsILtjVVFAniQ14+egmWLeOu1vZ1bx/yoT/kZ4qw 0N7aVrjVO3RyI+o3+L0zu3CdWLrSBRePdI14vA3K3E4W2wB+P/2F3379H WHjKQzPy8zxdsDn3gRg+8/LeHBNz8Oq5jg/miNo0jz37+BA+/ixHCjdfe g==; X-CSE-ConnectionGUID: 3J59BZVfSaKQXIn1vsatCg== X-CSE-MsgGUID: StLEOjOiRsC1c2knBKmbeg== X-IronPort-AV: E=Sophos;i="6.18,277,1751241600"; d="scan'208";a="2265435" Received: from ip-10-6-11-83.eu-central-1.compute.internal (HELO smtpout.naws.eu-central-1.prod.farcaster.email.amazon.dev) ([10.6.11.83]) by internal-fra-out-014.esa.eu-central-1.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Sep 2025 10:33:44 +0000 Received: from EX19MTAEUC001.ant.amazon.com [54.240.197.225:15647] by smtpin.naws.eu-central-1.prod.farcaster.email.amazon.dev [10.0.36.68:2525] with esmtp (Farcaster) id 0e93ee90-d0f0-4845-9149-cd800fa96270; Fri, 19 Sep 2025 10:33:43 +0000 (UTC) X-Farcaster-Flow-ID: 0e93ee90-d0f0-4845-9149-cd800fa96270 Received: from EX19D018EUA004.ant.amazon.com (10.252.50.85) by EX19MTAEUC001.ant.amazon.com (10.252.51.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.20; Fri, 19 Sep 2025 10:33:43 +0000 Received: from dev-dsk-farbere-1a-46ecabed.eu-west-1.amazon.com (172.19.116.181) by EX19D018EUA004.ant.amazon.com (10.252.50.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.20; Fri, 19 Sep 2025 10:33:13 +0000 From: Eliav Farber To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , Arnd Bergmann , Christoph Hellwig , Dan Carpenter , Jens Axboe , Lorenzo Stoakes , "Mateusz Guzik" , Pedro Falcato Subject: [PATCH 27/27 5.10.y] minmax.h: remove some #defines that are only expanded once Date: Fri, 19 Sep 2025 10:17:27 +0000 Message-ID: <20250919101727.16152-28-farbere@amazon.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20250919101727.16152-1-farbere@amazon.com> References: <20250919101727.16152-1-farbere@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.19.116.181] X-ClientProxiedBy: EX19D035UWB001.ant.amazon.com (10.13.138.33) To EX19D018EUA004.ant.amazon.com (10.252.50.85) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250919_033346_123301_A7761247 X-CRM114-Status: GOOD ( 17.42 ) X-Mailman-Approved-At: Mon, 06 Oct 2025 05:16:27 -0700 X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+linux-um=archiver.kernel.org@lists.infradead.org From: David Laight [ Upstream commit 2b97aaf74ed534fb838d09867d09a3ca5d795208 ] The bodies of __signed_type_use() and __unsigned_type_use() are much the same size as their names - so put the bodies in the only line that expands them. Similarly __signed_type() is defined separately for 64bit and then used exactly once just below. Change the test for __signed_type from CONFIG_64BIT to one based on gcc defined macros so that the code is valid if it gets used outside of a kernel build. Link: https://lkml.kernel.org/r/9386d1ebb8974fbabbed2635160c3975@AcuMS.aculab.com Signed-off-by: David Laight Cc: Andy Shevchenko Cc: Arnd Bergmann Cc: Christoph Hellwig Cc: Dan Carpenter Cc: Jason A. Donenfeld Cc: Jens Axboe Cc: Lorenzo Stoakes Cc: Mateusz Guzik Cc: Matthew Wilcox Cc: Pedro Falcato Signed-off-by: Andrew Morton Signed-off-by: Eliav Farber --- include/linux/minmax.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/include/linux/minmax.h b/include/linux/minmax.h index 2bbdd5b5e07e..eaaf5c008e4d 100644 --- a/include/linux/minmax.h +++ b/include/linux/minmax.h @@ -46,10 +46,8 @@ * comparison, and these expressions only need to be careful to not cause * warnings for pointer use. */ -#define __signed_type_use(ux) (2 + __is_nonneg(ux)) -#define __unsigned_type_use(ux) (1 + 2 * (sizeof(ux) < 4)) #define __sign_use(ux) (is_signed_type(typeof(ux)) ? \ - __signed_type_use(ux) : __unsigned_type_use(ux)) + (2 + __is_nonneg(ux)) : (1 + 2 * (sizeof(ux) < 4))) /* * Check whether a signed value is always non-negative. @@ -57,7 +55,7 @@ * A cast is needed to avoid any warnings from values that aren't signed * integer types (in which case the result doesn't matter). * - * On 64-bit any integer or pointer type can safely be cast to 'long'. + * On 64-bit any integer or pointer type can safely be cast to 'long long'. * But on 32-bit we need to avoid warnings about casting pointers to integers * of different sizes without truncating 64-bit values so 'long' or 'long long' * must be used depending on the size of the value. @@ -66,12 +64,12 @@ * them, but we do not use s128 types in the kernel (we do use 'u128', * but they are handled by the !is_signed_type() case). */ -#ifdef CONFIG_64BIT - #define __signed_type(ux) long +#if __SIZEOF_POINTER__ == __SIZEOF_LONG_LONG__ +#define __is_nonneg(ux) statically_true((long long)(ux) >= 0) #else - #define __signed_type(ux) typeof(__builtin_choose_expr(sizeof(ux) > 4, 1LL, 1L)) +#define __is_nonneg(ux) statically_true( \ + (typeof(__builtin_choose_expr(sizeof(ux) > 4, 1LL, 1L)))(ux) >= 0) #endif -#define __is_nonneg(ux) statically_true((__signed_type(ux))(ux) >= 0) #define __types_ok(ux, uy) \ (__sign_use(ux) & __sign_use(uy)) -- 2.47.3