From patchwork Fri Mar 7 16:48:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Mailhol via B4 Relay X-Patchwork-Id: 14006775 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 9BB82C19F32 for ; Fri, 7 Mar 2025 16:49:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 028D410EBF0; Fri, 7 Mar 2025 16:49:45 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="SAIIQp9g"; dkim-atps=neutral Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by gabe.freedesktop.org (Postfix) with ESMTPS id C206C10EBEF; Fri, 7 Mar 2025 16:49:39 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 3C2A2A44224; Fri, 7 Mar 2025 16:44:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 671BBC4CEEC; Fri, 7 Mar 2025 16:49:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741366178; bh=40sefDO3ErWdymEjyIPiUMmoQgDhxbnjHW9ZvkfKYfM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=SAIIQp9gkoMDx9l9b7kkLiIegQSTwEIOIE5sbnccSoClgpLNlk7mmUB4PBBN/RxVR qg3GKEJ/ek2jSOe2f0DkEAO7NwuFT/ys2UsRYUusGmP2nDeBtgF/tWz1Wz81ALK1/u AfPmui7HLzUW8CY3mZ/MOCcNW1B1U68LVV3c4sOLwsXVXcmYU2iI5iaOIphuH0uDa1 yzsgBDJk3ci6R3JXyXxZbMOLzXOmA4YGeobMWEAoVS9NX1YOzF9XHbTakySVMYLBLn Q4Xp7wP8YvCIimLUQLxUFjfoZdbHeOFHL+rpYv7009hCEjhTerp3b9AYBWLQm4v4Lq /YIYWRSFNIDZQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E8BAC19F32; Fri, 7 Mar 2025 16:49:38 +0000 (UTC) From: Vincent Mailhol via B4 Relay Date: Sat, 08 Mar 2025 01:48:54 +0900 Subject: [PATCH v6 7/7] test_bits: add tests for BIT_U*() MIME-Version: 1.0 Message-Id: <20250308-fixed-type-genmasks-v6-7-f59315e73c29@wanadoo.fr> References: <20250308-fixed-type-genmasks-v6-0-f59315e73c29@wanadoo.fr> In-Reply-To: <20250308-fixed-type-genmasks-v6-0-f59315e73c29@wanadoo.fr> To: Yury Norov , Lucas De Marchi , Rasmus Villemoes , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Andrew Morton Cc: linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Andi Shyti , David Laight , Dmitry Baryshkov , Andy Shevchenko , Vincent Mailhol X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1376; i=mailhol.vincent@wanadoo.fr; h=from:subject:message-id; bh=ICSy7DSYe3wHM8cbD8PtyLiEgBieXZJqpYz/Vpj4sZM=; b=owGbwMvMwCV2McXO4Xp97WbG02pJDOmnledszz72Ttn4QdrmR3oPxVZEB1d21Nv/ja1gmhpxK UjFqfFORykLgxgXg6yYIsuyck5uhY5C77BDfy1h5rAygQxh4OIUgInMes3wV/h2xjVDyfyj07tM Y3i/TN5q8yrEI2LOpeqPTVO/JJwLqmdk2FQ3S3b6//OuvL3Wt392VHbut8heay/TV9X7nTn9+i1 5DgA= X-Developer-Key: i=mailhol.vincent@wanadoo.fr; a=openpgp; fpr=ED8F700574E67F20E574E8E2AB5FEB886DBB99C2 X-Endpoint-Received: by B4 Relay for mailhol.vincent@wanadoo.fr/default with auth_id=291 X-Original-From: Vincent Mailhol X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: mailhol.vincent@wanadoo.fr Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Vincent Mailhol Add some additional tests in lib/test_bits.c to cover the expected results of the fixed type BIT_U*() macros. Signed-off-by: Vincent Mailhol --- Changelog: v5 -> v6: - No changes. v4 -> v5: - BIT_U8()/BIT_U16() are now back to u8/u16. v3 -> v4: - New patch. --- lib/test_bits.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/test_bits.c b/lib/test_bits.c index 87112d1895194da33c0ffdf0a6fe6df43ce6b1e7..ab88e50d2edfa2b011f07d50460ac8ea6ff99923 100644 --- a/lib/test_bits.c +++ b/lib/test_bits.c @@ -9,6 +9,16 @@ #define assert_type(t, x) _Generic(x, t: x, default: 0) +static_assert(assert_type(u8, BIT_U8(0)) == 1u); +static_assert(assert_type(u16, BIT_U16(0)) == 1u); +static_assert(assert_type(u32, BIT_U32(0)) == 1u); +static_assert(assert_type(u64, BIT_U64(0)) == 1ull); + +static_assert(assert_type(u8, BIT_U8(7)) == 0x80u); +static_assert(assert_type(u16, BIT_U16(15)) == 0x8000u); +static_assert(assert_type(u32, BIT_U32(31)) == 0x80000000u); +static_assert(assert_type(u64, BIT_U64(63)) == 0x8000000000000000ull); + static_assert(assert_type(unsigned long, GENMASK(31, 0)) == U32_MAX); static_assert(assert_type(unsigned long long, GENMASK_ULL(63, 0)) == U64_MAX); static_assert(assert_type(u8, GENMASK_U8(7, 0)) == U8_MAX);