Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10156622rwr; Fri, 12 May 2023 04:46:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7eFjYU4JhBH7EIgoJOFWZY84Y+CFzt/jO60gN/2wRPbFwwTLZ+uJKSSv9fySSJJOZVy1x8 X-Received: by 2002:a05:6a20:7d97:b0:ff:e60c:ee93 with SMTP id v23-20020a056a207d9700b000ffe60cee93mr25647262pzj.26.1683891980133; Fri, 12 May 2023 04:46:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683891980; cv=none; d=google.com; s=arc-20160816; b=XUW39vieeYsPy0WAI4DjRWcTiNtbh4AP/FxjeCUOFC6stZC2S8XNKXjLr147EnPQZN Tf0bdbtHIGlPd90vbMDplmU7tgu1V9wySDHEjRLD7WjyF3KuRBBSeCmegU/aylKK0H9m 9z75LTXgNavD13nENu/bQCs8FoOKoYvQfG5jbEYyS6nqIhHy22Jku3WdEhhxyHOe8mCc 8fdVupRtrdZ51ytU2j3EUodKJ1QkNtLVH8/QypV89VZ3iuYt5qGueaxcoLb4iyS/ZoLc OyNdAZOsVxd+lT1kO+tzYFotRA4BHxc+G6staxMQeWAI4QrqSg9H9dRYl+G14X/PxWUw 7p3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from:dkim-signature; bh=+mnsRcyktLeWy89GJuGrEII65OouyAfZpC5x7CQ1r0o=; b=QgpkBto3NMETDQnUZdOZaATrTklJai8pM1m1ZKtjoSjiy7yL8vVpWr6qT5PFcQOAxv 1CovupnUrat38zhSMI2HUbDlZzPuUWIRzd/v8Wer8LlrrbIRtBVwcUvpC02/J55eG9vb BzMVE/wQjkInzlzaPfb9667trJwqKnVL6xCoJhI9xn72AqO3WSUvLT75MRyw5jTj8Hhq iGRueg2E+W0s05x2nahXpUQkUyhP2kFpfwdPE2dbzUP5PTykKN4gJe91Y3O2f/4uLG52 /S+0ULIMdZ0llmzGl7RThEUKV2DUmVb1ccjV4jX7Mdt9ETAa44iw9yz1Y/c44bjTwe7o DAlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iuOCP06S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p8-20020a17090a4f0800b0024dd0a6c437si31221812pjh.59.2023.05.12.04.46.05; Fri, 12 May 2023 04:46:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iuOCP06S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241073AbjELLZ2 (ORCPT + 99 others); Fri, 12 May 2023 07:25:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240546AbjELLZ1 (ORCPT ); Fri, 12 May 2023 07:25:27 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B059129 for ; Fri, 12 May 2023 04:25:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683890726; x=1715426726; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=DLcxuGg90W0qpFb37T2Z/r5Za1skwRRI/1oJiKzq3+Y=; b=iuOCP06S3ZDrVCk0w2Oe8o+EIJ85iryjnf1BbFj/VouM8FdMjWJbH/vR AUZC1IcIdRWkai4QdMIgDj0Hn9yrup1+IOZMdBStvCmofcoHv+JvjCH2z aZIJ0Ge/+vv32+o1mYrZ0RwC14PFoDJVqFy38Rx8RQj0lA79x3+lK66oJ GgsxGf28B4bNJ4k1vMgcomrXY7XNKld1NBjvKka85Rodpv5nRTu77oJDH 1hLl74TnRPHQ2eb8+JhLwYK2r406iV+ySiEa+NL6fJYXGN/diFa5iduW9 Oh3ufhr2nuNNs3YDPaxcbLVyz2FHxyn5KAA9oFrJLwoQRa7U7ABOWZGqL g==; X-IronPort-AV: E=McAfee;i="6600,9927,10707"; a="335287276" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="335287276" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 04:25:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10707"; a="824331254" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="824331254" Received: from tsavina-mobl2.ger.corp.intel.com (HELO localhost) ([10.252.63.51]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 04:25:21 -0700 From: Jani Nikula To: Andy Shevchenko , Lucas De Marchi Cc: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Thomas Gleixner , linux-kernel@vger.kernel.org, Masahiro Yamada , Andrew Morton , Kevin Brodsky , Alex Deucher , Christian =?utf-8?Q?K=C3=B6nig?= Subject: Re: [PATCH 2/3] linux/bits.h: Add fixed-width GENMASK and BIT macros In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20230509051403.2748545-1-lucas.demarchi@intel.com> <20230509051403.2748545-3-lucas.demarchi@intel.com> Date: Fri, 12 May 2023 14:25:18 +0300 Message-ID: <87pm75kd0h.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 12 May 2023, Andy Shevchenko wrote: > 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? The main reason is that GENMASK() and BIT() size varies for 32/64 bit builds. BR, Jani. > >> 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. -- Jani Nikula, Intel Open Source Graphics Center