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 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 9F979C7EE2A for ; Fri, 12 May 2023 11:14:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BD00010E67F; Fri, 12 May 2023 11:14:28 +0000 (UTC) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 31D9010E67E; Fri, 12 May 2023 11:14:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683890067; x=1715426067; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=b2bSeUNs7PpWjC5QOLRCXQ3B+M8q/ixInf2CByxcbkc=; b=gj9XEe2VknQn6wEV8Y05OvawKu3ykM1mrh+gPLW2X82B/i6VmAqhuqMK kWkiB1pcCTrcsCrubFa5NqdfXe39bgqUyqiHBoV1HrQZlaJ62W8RlfcCJ BUm/qZFjMUlR3OhshgV5ccUjJPg0xohlBd0HxFkR7PEkanLIEPnoymYke nBkVUtlIpzqzeKa2vXFOrVXha48Y2wOfZhmNgpUSrKqYkN1elKXtxGGJd Q+uQEbSPo7MmvCjy+erntMIXtJxYPjEr7JfRxpOYxSQXdG/hMT/+YUHg8 NuFQERLSq1RbYPIvx/SB0VJM2d8d3j6J5Q7UTnam8GDRAnnwAPbeyADua Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10707"; a="378900273" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378900273" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 04:14:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10707"; a="730785709" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="730785709" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga008.jf.intel.com with ESMTP; 12 May 2023 04:14:22 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1pxQj5-0004b6-3D; Fri, 12 May 2023 14:14:19 +0300 Date: Fri, 12 May 2023 14:14:19 +0300 From: Andy Shevchenko To: Lucas De Marchi Subject: Re: [PATCH 2/3] linux/bits.h: Add fixed-width GENMASK and BIT macros Message-ID: References: <20230509051403.2748545-1-lucas.demarchi@intel.com> <20230509051403.2748545-3-lucas.demarchi@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230509051403.2748545-3-lucas.demarchi@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo 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: , Cc: Andrew Morton , Christian =?iso-8859-1?Q?K=F6nig?= , intel-gfx@lists.freedesktop.org, Kevin Brodsky , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-xe@lists.freedesktop.org, Alex Deucher , Thomas Gleixner , Masahiro Yamada Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Mon, May 08, 2023 at 10:14:02PM -0700, Lucas De Marchi wrote: > Add GENMASK_U32(), GENMASK_U16() and GENMASK_U8() macros to create > masks for fixed-width types and also the corresponding BIT_U32(), > BIT_U16() and BIT_U8(). Why? > All of those depend on a new "U" suffix added to the integer constant. > Due to naming clashes it's better to call the macro U32. Since C doesn't > have a proper suffix for short and char types, the U16 and U18 variants > just use U32 with one additional check in the BIT_* macros to make > sure the compiler gives an error when the those types overflow. > The BIT_U16() and BIT_U8() need the help of GENMASK_INPUT_CHECK(), > as otherwise they would allow an invalid bit to be passed. Hence > implement them in include/linux/bits.h rather than together with > the other BIT* variants. So, we have _Generic() in case you still wish to implement this. -- With Best Regards, Andy Shevchenko