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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98E2FCA0ED8 for ; Mon, 11 Sep 2023 22:09:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357881AbjIKWGn (ORCPT ); Mon, 11 Sep 2023 18:06:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242556AbjIKPta (ORCPT ); Mon, 11 Sep 2023 11:49:30 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E86D121 for ; Mon, 11 Sep 2023 08:49:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694447365; x=1725983365; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=fAQ1A8o1SJX97jbRKYZcBqL6qAgq5mvSwnltLXheQa8=; b=Hh7+vegJpV47W+Tnm989wbn86VGNIuFY1qwpGCcYPCxoL+OFLpAIcwKG LeN4/pZvaN2brb5am40RgTpBMeWl7LgkxxUXA3xeV5Qerlf6V2wbByj2v Q/jsRTn+vpYYn2BngnEh1HXUgJ69iSN9x8zwXFd/wRNSLdYRq/rX9kkv2 Gsaxvq9onqeuirma1bmH1Lb2jtvR69DdRSQql62azU+2z2OZQPm0dxbAN Z3ulA17WiFZ5jlBE4YwBOWk1FfTzfhphdDhNHc2TTP4W46eYUNYCRE5UD nEg/JeDJeKO4QlmLoppz1g4e3HNO6HoRNgnpQOm8VCDdM+xlaw4WMe/LR g==; X-IronPort-AV: E=McAfee;i="6600,9927,10830"; a="377030357" X-IronPort-AV: E=Sophos;i="6.02,244,1688454000"; d="scan'208";a="377030357" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2023 08:49:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10830"; a="720019143" X-IronPort-AV: E=Sophos;i="6.02,244,1688454000"; d="scan'208";a="720019143" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 11 Sep 2023 08:49:16 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 33C9413F; Mon, 11 Sep 2023 18:49:14 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-kernel@vger.kernel.org Cc: Rasmus Villemoes , Andrew Morton , Herve Codina Subject: [PATCH v2 1/1] minmax: Deduplicate __unconst_integer_typeof() Date: Mon, 11 Sep 2023 18:49:13 +0300 Message-Id: <20230911154913.4176033-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It appears that compiler_types.h already have an implementation of the __unconst_integer_typeof() called __unqual_scalar_typeof(). Use it instead of the copy. Acked-by: Herve Codina Signed-off-by: Andy Shevchenko --- v2: added tag (Herve), Cc'ed to Andrew as initial commit now in upstream include/linux/minmax.h | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/include/linux/minmax.h b/include/linux/minmax.h index 83aebc244cba..69bbe987fa87 100644 --- a/include/linux/minmax.h +++ b/include/linux/minmax.h @@ -2,6 +2,7 @@ #ifndef _LINUX_MINMAX_H #define _LINUX_MINMAX_H +#include #include #include @@ -134,27 +135,6 @@ */ #define max_t(type, x, y) __careful_cmp((type)(x), (type)(y), >) -/* - * Remove a const qualifier from integer types - * _Generic(foo, type-name: association, ..., default: association) performs a - * comparison against the foo type (not the qualified type). - * Do not use the const keyword in the type-name as it will not match the - * unqualified type of foo. - */ -#define __unconst_integer_type_cases(type) \ - unsigned type: (unsigned type)0, \ - signed type: (signed type)0 - -#define __unconst_integer_typeof(x) typeof( \ - _Generic((x), \ - char: (char)0, \ - __unconst_integer_type_cases(char), \ - __unconst_integer_type_cases(short), \ - __unconst_integer_type_cases(int), \ - __unconst_integer_type_cases(long), \ - __unconst_integer_type_cases(long long), \ - default: (x))) - /* * Do not check the array parameter using __must_be_array(). * In the following legit use-case where the "array" passed is a simple pointer, @@ -169,13 +149,13 @@ * 'int *buff' and 'int buff[N]' types. * * The array can be an array of const items. - * typeof() keeps the const qualifier. Use __unconst_integer_typeof() in order + * typeof() keeps the const qualifier. Use __unqual_scalar_typeof() in order * to discard the const qualifier for the __element variable. */ #define __minmax_array(op, array, len) ({ \ typeof(&(array)[0]) __array = (array); \ typeof(len) __len = (len); \ - __unconst_integer_typeof(__array[0]) __element = __array[--__len]; \ + __unqual_scalar_typeof(__array[0]) __element = __array[--__len];\ while (__len--) \ __element = op(__element, __array[__len]); \ __element; }) -- 2.40.0.1.gaa8946217a0b